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

Small fixes for testing client and test result #438

Merged
merged 3 commits into from
Jun 18, 2024
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
1 change: 1 addition & 0 deletions geti_sdk/data_models/test_result.py
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,7 @@ class ModelInfo:
)
version: int
precision: Optional[List[str]] = None # Added in Geti v1.9
task_id: Optional[str] = None # Added in Geti v2.0


@attr.define()
Expand Down
21 changes: 19 additions & 2 deletions geti_sdk/rest_clients/testing_client.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
from geti_sdk.data_models import Dataset, Job, Model, Project, TestResult
from geti_sdk.http_session import GetiSession
from geti_sdk.rest_converters import TestResultRESTConverter
from geti_sdk.utils.job_helpers import get_job_with_timeout, monitor_jobs
from geti_sdk.utils.job_helpers import get_job_with_timeout, monitor_job, monitor_jobs

SUPPORTED_METRICS = ["global", "local"]

Expand Down Expand Up @@ -73,7 +73,7 @@ def test_model(
url=self.base_url, method="POST", data=test_data
)
job = get_job_with_timeout(
job_id=response["job_ids"][0],
job_id=response["job_id"],
session=self.session,
workspace_id=self.workspace_id,
job_type="testing",
Expand Down Expand Up @@ -122,3 +122,20 @@ def monitor_jobs(
return monitor_jobs(
session=self.session, jobs=jobs, timeout=timeout, interval=interval
)

def monitor_job(self, job: Job, timeout: int = 10000, interval: int = 15) -> Job:
"""
Monitor and print the progress of the `job`. Execution is
halted until the job has either finished, failed or was cancelled.

Progress will be reported in 15s intervals

:param job: Job to monitor
:param timeout: Timeout (in seconds) after which to stop the monitoring
:param interval: Time interval (in seconds) at which the TrainingClient polls
the server to update the status of the jobs. Defaults to 15 seconds
:return: Job with its status updated
"""
return monitor_job(
session=self.session, job=job, timeout=timeout, interval=interval
)
Loading