The lightly.api module provides access to the Lightly web-app.
ApiWorkflowClient(token: str, dataset_id: str = None, embedding_id: str = None)¶
Provides a uniform interface to communicate with the api
The APIWorkflowClient is used to communicaate with the Lightly API. The client can run also more complex workflows which include multiple API calls at once.
The client can be used in combination with the active learning agent.
the token of the user, provided in webapp
the id of the dataset, provided in webapp. If it is not set, but used by a workflow, the last modfied dataset is taken by default.
the id of the embedding to use. If it is not set, but used by a workflow, the newest embedding is taken by default
The current dataset_id.
If the dataset_id is set, it is returned. If it is not set, then the dataset_id of the last modified dataset is selected.
The list of the filenames in the dataset.
upload_file_with_signed_url(file: io.IOBase, signed_write_url: str, max_backoff: int = 32, max_retries: int = 5) → requests.models.Response¶
Uploads a file to a url via a put request.
The file to upload.
The url to upload the file to. As no authorization is used, the url must be a signed write url.
Maximal backoff before retrying.
Maximum number of retries before timing out.
The response of the put request, usually a 200 for the success case.
PIL_to_bytes(img, ext: str = 'png', quality: int = None)¶
Return the PIL image as byte stream. Useful to send image via requests.
Checks the length of the filename.
Basename of the file.
getenv(key: str, default: str)¶
Return the value of the environment variable key if it exists, or default if it doesn’t.
retry(func, *args, **kwargs)¶
Repeats a function until it completes successfully or fails too often.
The function call to repeat.
The arguments which are passed to the function.
Key-word arguments which are passed to the function.
What func returns.
RuntimeError when number of retries has been exceeded.