Skip to content

Commit

Permalink
docs: Docstrings for classes
Browse files Browse the repository at this point in the history
  • Loading branch information
JesperDramsch committed Sep 23, 2024
1 parent b069986 commit 122c44e
Show file tree
Hide file tree
Showing 10 changed files with 31 additions and 1 deletion.
4 changes: 3 additions & 1 deletion src/anemoi/registry/entry/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,8 @@ class CatalogueEntryNotFound(Exception):


class CatalogueEntry:
"""Base class for a Anemoi catalogue entry."""

record = None
path = None
key = None
Expand All @@ -36,7 +38,7 @@ class CatalogueEntry:
def url(self):
return f"{config()['web_url']}/{self.collection}/{self.key}"

def __init__(self, key=None, path=None, must_exist=True):
def __init__(self, key=None, path=None, must_exist=True) -> None:
assert key is not None or path is not None, "key or path must be provided"
assert key is None or path is None, "key and path are mutually exclusive"

Expand Down
4 changes: 4 additions & 0 deletions src/anemoi/registry/entry/dataset.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,8 @@


class DatasetCatalogueEntryList(RestItemList):
"""List of dataset catalogue entries."""

def __init__(self, **kwargs):
super().__init__(COLLECTION, **kwargs)

Expand All @@ -33,6 +35,8 @@ def __iter__(self):


class DatasetCatalogueEntry(CatalogueEntry):
"""A dataset catalogue entry."""

collection = COLLECTION
main_key = "name"

Expand Down
4 changes: 4 additions & 0 deletions src/anemoi/registry/entry/experiment.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,8 @@


class ExperimentCatalogueEntryList(RestItemList):
"""List of ExperimentCatalogueEntry objects."""

def __init__(self, **kwargs):
super().__init__(COLLECTION, **kwargs)

Expand All @@ -37,6 +39,8 @@ def __iter__(self):


class ExperimentCatalogueEntry(CatalogueEntry):
"""Catalogue entry for an experiment."""

collection = COLLECTION
main_key = "expver"

Expand Down
2 changes: 2 additions & 0 deletions src/anemoi/registry/entry/weights.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,8 @@


class WeightsCatalogueEntryList(RestItemList):
"""List of weights catalogue entries."""

def __init__(self, **kwargs):
super().__init__(COLLECTION, **kwargs)

Expand Down
6 changes: 6 additions & 0 deletions src/anemoi/registry/rest.py
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,8 @@ def trace_info():


class Rest:
"""REST API client."""

def __init__(self):
self.session = requests.Session()
self.session.headers.update({"Authorization": f"Bearer {self.token}"})
Expand Down Expand Up @@ -148,6 +150,8 @@ def raise_for_status(self, r, errors={}):


class RestItem:
"""Single catalogue entry from REST API."""

def __init__(self, collection, key):
self.collection = collection
self.key = key
Expand Down Expand Up @@ -179,6 +183,8 @@ def __repr__(self):


class RestItemList:
"""List of catalogue entries from REST API."""

def __init__(self, collection):
self.collection = collection
self.rest = Rest()
Expand Down
2 changes: 2 additions & 0 deletions src/anemoi/registry/tasks.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,8 @@


class TaskCatalogueEntryList:
"""List of task catalogue entries."""

collection = "tasks"
main_key = "uuid"

Expand Down
2 changes: 2 additions & 0 deletions src/anemoi/registry/workers/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,8 @@


class Worker:
"""Base class for a worker that processes tasks in the queue."""

name = None

def __init__(
Expand Down
2 changes: 2 additions & 0 deletions src/anemoi/registry/workers/delete_dataset.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,8 @@


class DeleteDatasetWorker(Worker):
"""Worker to delete a dataset from a platform."""

name = "delete-dataset"

def __init__(
Expand Down
2 changes: 2 additions & 0 deletions src/anemoi/registry/workers/dummy.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@


class DummyWorker(Worker):
"""A debug worker that logs the task it receives."""

name = "dummy"

def __init__(self, arg, **kwargs):
Expand Down
4 changes: 4 additions & 0 deletions src/anemoi/registry/workers/transfer_dataset.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,8 @@


class Progress:
"""Progress reporter for transfer tasks."""

latest = None

def __init__(self, task, frequency=60):
Expand Down Expand Up @@ -62,6 +64,8 @@ def __call__(self, number_of_files, total_size, total_transferred, transfering,


class TransferDatasetWorker(Worker):
"""Worker to transfer a dataset from one platform to another."""

name = "transfer-dataset"

def __init__(
Expand Down

0 comments on commit 122c44e

Please sign in to comment.