Skip to content

Commit

Permalink
Add download_compute_worker_run_report_v2_json (#1417)
Browse files Browse the repository at this point in the history
* Add download_compute_worker_run_report_v2_json
* Add deprecation warning to download_compute_worker_run_report_json
  • Loading branch information
guarin authored Oct 19, 2023
1 parent f3d8e9d commit 4fbb18e
Showing 1 changed file with 53 additions and 0 deletions.
53 changes: 53 additions & 0 deletions lightly/api/api_workflow_artifacts.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import os
import warnings

from lightly.api import download
from lightly.openapi_generated.swagger_client.models import (
Expand Down Expand Up @@ -145,6 +146,10 @@ def download_compute_worker_run_report_json(
) -> None:
"""Download the report in json format from a run.
DEPRECATED: This method is deprecated and will be removed in the future. Use
download_compute_worker_run_report_v2_json to download the new report_v2.json
instead.
Args:
run:
Run from which to download the report.
Expand All @@ -171,13 +176,61 @@ def download_compute_worker_run_report_json(
>>> client.download_compute_worker_run_report_json(run=run, output_path="report.json")
"""
warnings.warn(
DeprecationWarning(
"This method downloads the deprecated report.json file and will be "
"removed in the future. Use download_compute_worker_run_report_v2_json "
"to download the new report_v2.json file instead."
)
)
self._download_compute_worker_run_artifact_by_type(
run=run,
artifact_type=DockerRunArtifactType.REPORT_JSON,
output_path=output_path,
timeout=timeout,
)

def download_compute_worker_run_report_v2_json(
self,
run: DockerRunData,
output_path: str,
timeout: int = 60,
) -> None:
"""Download the report in json format from a run.
Args:
run:
Run from which to download the report.
output_path:
Path where report will be saved.
timeout:
Timeout in seconds after which download is interrupted.
Raises:
ArtifactNotExist:
If the run has no report artifact or the report has not yet been
uploaded.
Examples:
>>> # schedule run
>>> scheduled_run_id = client.schedule_compute_worker_run(...)
>>>
>>> # wait until run completed
>>> for run_info in client.compute_worker_run_info_generator(scheduled_run_id=scheduled_run_id):
>>> pass
>>>
>>> # download checkpoint
>>> run = client.get_compute_worker_run_from_scheduled_run(scheduled_run_id=scheduled_run_id)
>>> client.download_compute_worker_run_report_v2_json(run=run, output_path="report_v2.json")
"""
self._download_compute_worker_run_artifact_by_type(
run=run,
artifact_type=DockerRunArtifactType.REPORT_V2_JSON,
output_path=output_path,
timeout=timeout,
)

def download_compute_worker_run_log(
self,
run: DockerRunData,
Expand Down

0 comments on commit 4fbb18e

Please sign in to comment.