Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Clean up lightly.api docs #1385

Merged
merged 1 commit into from
Sep 11, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions lightly/api/api_workflow_client.py
Original file line number Diff line number Diff line change
Expand Up @@ -218,6 +218,8 @@ def get_filenames(self) -> List[str]:

Returns:
Names of files in the current dataset.

:meta private: # Skip docstring generation
"""
filenames_on_server = self._mappings_api.get_sample_mappings_by_dataset_id(
dataset_id=self.dataset_id, field="fileName"
Expand Down Expand Up @@ -247,6 +249,7 @@ def upload_file_with_signed_url(
Returns:
The response of the put request.

:meta private: # Skip docstring generation
"""

# check to see if server side encryption for S3 is desired
Expand Down
2 changes: 2 additions & 0 deletions lightly/api/api_workflow_compute_worker.py
Original file line number Diff line number Diff line change
Expand Up @@ -207,6 +207,8 @@ def create_compute_worker_config(
>>> config_id = client.create_compute_worker_config(
... selection_config=selection_config,
... )

:meta private: # Skip docstring generation
"""
if isinstance(selection_config, dict):
selection = selection_config_from_dict(cfg=selection_config)
Expand Down
11 changes: 11 additions & 0 deletions lightly/api/api_workflow_datasources.py
Original file line number Diff line number Diff line change
Expand Up @@ -130,6 +130,8 @@ def download_raw_samples(
>>> client.set_dataset_id_by_name("my-dataset")
>>> client.download_raw_samples()
[('image-1.png', 'https://......'), ('image-2.png', 'https://......')]

:meta private: # Skip docstring generation
"""
samples = self._download_raw_files(
download_function=self._datasources_api.get_list_of_raw_samples_from_datasource_by_dataset_id,
Expand Down Expand Up @@ -198,6 +200,8 @@ def download_raw_predictions(
>>> client.download_raw_predictions(task_name=task_name)
[('.lightly/predictions/object-detection/image-1.json', 'https://......'),
('.lightly/predictions/object-detection/image-2.json', 'https://......')]

:meta private: # Skip docstring generation
"""
if run_id is not None and relevant_filenames_artifact_id is None:
raise ValueError(
Expand Down Expand Up @@ -281,6 +285,8 @@ def download_raw_metadata(
>>> client.download_raw_metadata()
[('.lightly/metadata/object-detection/image-1.json', 'https://......'),
('.lightly/metadata/object-detection/image-2.json', 'https://......')]

:meta private: # Skip docstring generation
"""
if run_id is not None and relevant_filenames_artifact_id is None:
raise ValueError(
Expand Down Expand Up @@ -370,6 +376,8 @@ def get_processed_until_timestamp(self) -> int:
>>> client.set_dataset_id_by_name("my-dataset")
>>> client.get_processed_until_timestamp()
1684750513

:meta private: # Skip docstring generation
"""
response: DatasourceProcessedUntilTimestampResponse = self._datasources_api.get_datasource_processed_until_timestamp_by_dataset_id(
dataset_id=self.dataset_id
Expand Down Expand Up @@ -721,6 +729,7 @@ def get_prediction_read_url(
A read-url to the file. Note that a URL will be returned even if the file does not
exist.

:meta private: # Skip docstring generation
"""
return self._datasources_api.get_prediction_file_read_url_from_datasource_by_dataset_id(
dataset_id=self.dataset_id,
Expand All @@ -741,6 +750,7 @@ def get_metadata_read_url(
A read-url to the file. Note that a URL will be returned even if the file does not
exist.

:meta private: # Skip docstring generation
"""
return self._datasources_api.get_metadata_file_read_url_from_datasource_by_dataset_id(
dataset_id=self.dataset_id,
Expand All @@ -761,6 +771,7 @@ def get_custom_embedding_read_url(
A read-url to the file. Note that a URL will be returned even if the file does not
exist.

:meta private: # Skip docstring generation
"""
return self._datasources_api.get_custom_embedding_file_read_url_from_datasource_by_dataset_id(
dataset_id=self.dataset_id,
Expand Down
4 changes: 3 additions & 1 deletion lightly/api/api_workflow_predictions.py
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ def create_or_update_prediction_task_schema(
>>> )
>>> client.create_or_update_prediction_task_schema(schema=schema)


:meta private: # Skip docstring generation
"""
self._predictions_api.create_or_update_prediction_task_schema_by_dataset_id(
prediction_task_schema=schema,
Expand All @@ -71,6 +71,8 @@ def create_or_update_prediction(

prediction_singletons:
Predictions to be uploaded for the designated sample.

:meta private: # Skip docstring generation
"""
self._predictions_api.create_or_update_prediction_by_sample_id(
prediction_singleton=prediction_singletons,
Expand Down
3 changes: 3 additions & 0 deletions lightly/api/api_workflow_selection.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,8 @@ def upload_scores(
and score arrays. The length of each score array must match samples
in the designated tag.
query_tag_id: ID of the desired tag.

:meta private: # Skip docstring generation
"""
# iterate over all available score types and upload them
for score_type, score_values in al_scores.items():
Expand Down Expand Up @@ -79,6 +81,7 @@ def selection(
When `initial-tag` does not exist in the dataset.
When the selection task fails.

:meta private: # Skip docstring generation
"""

warnings.warn(
Expand Down
2 changes: 2 additions & 0 deletions lightly/api/api_workflow_tags.py
Original file line number Diff line number Diff line change
Expand Up @@ -124,6 +124,8 @@ def get_filenames_in_tag(
>>> tag = client.get_tag_by_name("cool-tag")
>>> client.get_filenames_in_tag(tag_data=tag)
['image-1.png', 'image-2.png']

:meta private: # Skip docstring generation
"""

if exclude_parent_tag:
Expand Down
7 changes: 6 additions & 1 deletion lightly/api/api_workflow_upload_embeddings.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,10 @@ def _get_csv_reader_from_read_url(self, read_url: str) -> None:
return reader

def set_embedding_id_to_latest(self) -> None:
"""Sets the embedding ID in the API client to the latest embedding ID in the current dataset."""
"""Sets the embedding ID in the API client to the latest embedding ID in the current dataset.

:meta private: # Skip docstring generation
"""
embeddings_on_server: List[
DatasetEmbeddingData
] = self._embeddings_api.get_embeddings_by_dataset_id(
Expand Down Expand Up @@ -104,6 +107,7 @@ def upload_embeddings(self, path_to_embeddings_csv: str, name: str) -> None:
The name of the embedding. If an embedding with such a name already exists on the server,
the upload is aborted.

:meta private: # Skip docstring generation
"""
io_utils.check_embeddings(
path_to_embeddings_csv, remove_additional_columns=True
Expand Down Expand Up @@ -185,6 +189,7 @@ def append_embeddings(self, path_to_embeddings_csv: str, embedding_id: str) -> N
If the number of columns in the local embeddings file and that of the remote
embeddings file mismatch.

:meta private: # Skip docstring generation
"""

# read embedding from API
Expand Down
4 changes: 3 additions & 1 deletion lightly/api/api_workflow_upload_metadata.py
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,7 @@ def index_custom_metadata_by_filename(
If there are no annotations for a filename, the custom metadata
is None instead.

:meta private: # Skip docstring generation
"""

# The mapping is filename -> image_id -> custom_metadata
Expand Down Expand Up @@ -141,6 +142,7 @@ def upload_custom_metadata(
max_workers:
Maximum number of concurrent threads during upload.

:meta private: # Skip docstring generation
"""

self.verify_custom_metadata_format(custom_metadata)
Expand Down Expand Up @@ -241,7 +243,7 @@ def create_custom_metadata_config(
>>> [entry],
>>> )


:meta private: # Skip docstring generation
"""
config_set_request = ConfigurationSetRequest(name=name, configs=configs)
resp = self._metadata_configurations_api.create_meta_data_configuration(
Expand Down
7 changes: 6 additions & 1 deletion lightly/utils/io.py
Original file line number Diff line number Diff line change
Expand Up @@ -262,7 +262,10 @@ def load_embeddings_as_dict(


class COCO_ANNOTATION_KEYS:
"""Enum of coco annotation keys complemented with a key for custom metadata."""
"""Enum of coco annotation keys complemented with a key for custom metadata.

:meta private: # Skip docstring generation
"""

# image keys
images: str = "images"
Expand Down Expand Up @@ -298,6 +301,7 @@ def format_custom_metadata(
>>> > 'metadata': [{'image_id': 0, 'number_of_people': 1}, {'image_id': 1, 'number_of_people': 3}]
>>> > }

:meta private: # Skip docstring generation
"""
formatted: Dict[str, List[Any]] = {
COCO_ANNOTATION_KEYS.images: [],
Expand Down Expand Up @@ -330,6 +334,7 @@ def save_custom_metadata(path: str, custom_metadata: List[Tuple[str, Any]]) -> N
custom_metadata:
List of tuples (filename, metadata) where metadata is a dictionary.

:meta private: # Skip docstring generation
"""
formatted = format_custom_metadata(custom_metadata)
with open(path, "w") as f:
Expand Down
Loading