Skip to content

Commit

Permalink
HARMONY-1898: Add label function
Browse files Browse the repository at this point in the history
  • Loading branch information
vinnyinverso committed Jan 22, 2025
1 parent 08d2287 commit 19d7cc7
Showing 1 changed file with 22 additions and 0 deletions.
22 changes: 22 additions & 0 deletions harmony/harmony.py
Original file line number Diff line number Diff line change
Expand Up @@ -677,6 +677,9 @@ def _resume_url(self, job_id: str, link_type: LinkType = LinkType.https) -> str:

def _cloud_access_url(self) -> str:
return f'{self.config.root_url}/cloud-access'

def _labels_url(self) -> str:
return f'{self.config.root_url}/labels'

def _params(self, request: BaseRequest) -> dict:
"""Creates a dictionary of request query parameters from the given request."""
Expand Down Expand Up @@ -1100,6 +1103,25 @@ def progress(self, job_id: str) -> Tuple[int, str, str]:
else:
self._handle_error_response(response)

def label(self, job_ids: List[str], labels: List[str]) -> dict:
"""Add one or more labels to one or more of your jobs.
Args:
job_ids: IDs of the jobsto label.
labels: Labels to add to the jobs.
Returns:
Raises:
"""
session = self._session()
response = session.put(self._labels_url, data={ 'jobId': job_ids, 'label' : labels })
if response.ok:
return 'The labels were added successfully.'
else:
self._handle_error_response(response)

def wait_for_processing(self, job_id: str, show_progress: bool = False) -> None:
"""Retrieve a submitted job's completion status in percent.
Expand Down

0 comments on commit 19d7cc7

Please sign in to comment.