-
Notifications
You must be signed in to change notification settings - Fork 50
[AQUA Telemetry] Update MD Tracking #1193
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
Merged
Merged
Changes from all commits
Commits
Show all changes
21 commits
Select commit
Hold shift + click to select a range
f6e3f00
initial commit WIP
agrimk 619a925
ODSC-70841 Improve Model Deployment Status Tracking
agrimk 2608622
Merge branch 'main' into ODSC-70841_update_md_tracking
mrDzurb 6917c98
PR review comments
agrimk 075d714
Merge branch 'ODSC-70841_update_md_tracking' of github.com:oracle/acc…
agrimk bc41862
Merge branch 'main' of github.com:oracle/accelerated-data-science int…
agrimk 5e84eaf
PR review comments
agrimk f3a9e9d
testing in INT
agrimk fc4c72a
testing in INT
agrimk fd09187
Merge branch 'main' into ODSC-70841_update_md_tracking
mrDzurb c0c072f
handling failure case and PR review comments
agrimk bf2953b
Merge branch 'ODSC-70841_update_md_tracking' of github.com:oracle/acc…
agrimk 8b143ff
adding env vars for tracking of SMC in telemetry
agrimk cabbfa4
merge conflicts resolved
agrimk c2b8d41
moved wait work request to background thread
agrimk a96bb82
Merge branch 'main' into ODSC-70841_update_md_tracking
mrDzurb a58ea43
corrected imports
agrimk 3938aac
pull from main branch
agrimk 8f2e0a0
Merge branch 'main' into ODSC-70841_update_md_tracking
VipulMascarenhas 4507162
fixed unit tests
agrimk 6eeb6cb
merge of master
agrimk File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,5 @@ | ||
#!/usr/bin/env python | ||
# -*- coding: utf-8; -*- | ||
|
||
# Copyright (c) 2024 Oracle and/or its affiliates. | ||
# Copyright (c) 2024, 2025 Oracle and/or its affiliates. | ||
# Licensed under the Universal Permissive License v 1.0 as shown at https://oss.oracle.com/licenses/upl/ | ||
|
||
import logging | ||
|
@@ -12,6 +10,7 @@ | |
import oci | ||
from oci import Signer | ||
from tqdm.auto import tqdm | ||
|
||
from ads.common.oci_datascience import OCIDataScienceMixin | ||
|
||
logger = logging.getLogger(__name__) | ||
|
@@ -20,10 +19,10 @@ | |
DEFAULT_WAIT_TIME = 1200 | ||
DEFAULT_POLL_INTERVAL = 10 | ||
WORK_REQUEST_PERCENTAGE = 100 | ||
# default tqdm progress bar format: | ||
# default tqdm progress bar format: | ||
# {l_bar}{bar}| {n_fmt}/{total_fmt} [{elapsed}<{remaining}, ' '{rate_fmt}{postfix}] | ||
# customize the bar format to remove the {n_fmt}/{total_fmt} from the right side | ||
DEFAULT_BAR_FORMAT = '{l_bar}{bar}| [{elapsed}<{remaining}, ' '{rate_fmt}{postfix}]' | ||
DEFAULT_BAR_FORMAT = "{l_bar}{bar}| [{elapsed}<{remaining}, " "{rate_fmt}{postfix}]" | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Can't it be just
? |
||
|
||
|
||
class DataScienceWorkRequest(OCIDataScienceMixin): | ||
|
@@ -32,13 +31,13 @@ class DataScienceWorkRequest(OCIDataScienceMixin): | |
""" | ||
|
||
def __init__( | ||
self, | ||
id: str, | ||
self, | ||
id: str, | ||
description: str = "Processing", | ||
config: dict = None, | ||
signer: Signer = None, | ||
client_kwargs: dict = None, | ||
**kwargs | ||
config: dict = None, | ||
signer: Signer = None, | ||
client_kwargs: dict = None, | ||
**kwargs, | ||
) -> None: | ||
"""Initializes ADSWorkRequest object. | ||
|
||
|
@@ -49,41 +48,43 @@ def __init__( | |
description: str | ||
Progress bar initial step description (Defaults to `Processing`). | ||
config : dict, optional | ||
OCI API key config dictionary to initialize | ||
OCI API key config dictionary to initialize | ||
oci.data_science.DataScienceClient (Defaults to None). | ||
signer : oci.signer.Signer, optional | ||
OCI authentication signer to initialize | ||
OCI authentication signer to initialize | ||
oci.data_science.DataScienceClient (Defaults to None). | ||
client_kwargs : dict, optional | ||
Additional client keyword arguments to initialize | ||
Additional client keyword arguments to initialize | ||
oci.data_science.DataScienceClient (Defaults to None). | ||
kwargs: | ||
Additional keyword arguments to initialize | ||
Additional keyword arguments to initialize | ||
oci.data_science.DataScienceClient. | ||
""" | ||
self.id = id | ||
self._description = description | ||
self._percentage = 0 | ||
self._status = None | ||
self._error_message = "" | ||
super().__init__(config, signer, client_kwargs, **kwargs) | ||
|
||
|
||
def _sync(self): | ||
"""Fetches the latest work request information to ADSWorkRequest object.""" | ||
work_request = self.client.get_work_request(self.id).data | ||
work_request_logs = self.client.list_work_request_logs( | ||
self.id | ||
).data | ||
work_request_logs = self.client.list_work_request_logs(self.id).data | ||
|
||
self._percentage= work_request.percent_complete | ||
self._percentage = work_request.percent_complete | ||
self._status = work_request.status | ||
self._description = work_request_logs[-1].message if work_request_logs else "Processing" | ||
self._description = ( | ||
work_request_logs[-1].message if work_request_logs else "Processing" | ||
) | ||
if work_request.status == "FAILED": | ||
self._error_message = self.client.list_work_request_errors(self.id).data | ||
|
||
def watch( | ||
self, | ||
self, | ||
progress_callback: Callable, | ||
max_wait_time: int=DEFAULT_WAIT_TIME, | ||
poll_interval: int=DEFAULT_POLL_INTERVAL, | ||
max_wait_time: int = DEFAULT_WAIT_TIME, | ||
poll_interval: int = DEFAULT_POLL_INTERVAL, | ||
): | ||
"""Updates the progress bar with realtime message and percentage until the process is completed. | ||
|
||
|
@@ -92,10 +93,10 @@ def watch( | |
progress_callback: Callable | ||
Progress bar callback function. | ||
It must accept `(percent_change, description)` where `percent_change` is the | ||
work request percent complete and `description` is the latest work request log message. | ||
work request percent complete and `description` is the latest work request log message. | ||
max_wait_time: int | ||
Maximum amount of time to wait in seconds (Defaults to 1200). | ||
Negative implies infinite wait time. | ||
Negative implies infinite wait time. | ||
poll_interval: int | ||
Poll interval in seconds (Defaults to 10). | ||
|
||
|
@@ -107,7 +108,6 @@ def watch( | |
|
||
start_time = time.time() | ||
while self._percentage < 100: | ||
|
||
seconds_since = time.time() - start_time | ||
if max_wait_time > 0 and seconds_since >= max_wait_time: | ||
logger.error(f"Exceeded max wait time of {max_wait_time} seconds.") | ||
|
@@ -124,12 +124,14 @@ def watch( | |
percent_change = self._percentage - previous_percent_complete | ||
previous_percent_complete = self._percentage | ||
progress_callback( | ||
percent_change=percent_change, | ||
description=self._description | ||
percent_change=percent_change, description=self._description | ||
) | ||
|
||
if self._status in WORK_REQUEST_STOP_STATE: | ||
if self._status != oci.work_requests.models.WorkRequest.STATUS_SUCCEEDED: | ||
if ( | ||
self._status | ||
!= oci.work_requests.models.WorkRequest.STATUS_SUCCEEDED | ||
): | ||
if self._description: | ||
raise Exception(self._description) | ||
else: | ||
|
@@ -145,12 +147,12 @@ def watch( | |
|
||
def wait_work_request( | ||
self, | ||
progress_bar_description: str="Processing", | ||
max_wait_time: int=DEFAULT_WAIT_TIME, | ||
poll_interval: int=DEFAULT_POLL_INTERVAL | ||
progress_bar_description: str = "Processing", | ||
max_wait_time: int = DEFAULT_WAIT_TIME, | ||
poll_interval: int = DEFAULT_POLL_INTERVAL, | ||
): | ||
"""Waits for the work request progress bar to be completed. | ||
|
||
Parameters | ||
---------- | ||
progress_bar_description: str | ||
|
@@ -160,7 +162,7 @@ def wait_work_request( | |
Negative implies infinite wait time. | ||
poll_interval: int | ||
Poll interval in seconds (Defaults to 10). | ||
|
||
Returns | ||
------- | ||
None | ||
|
@@ -172,7 +174,7 @@ def wait_work_request( | |
mininterval=0, | ||
file=sys.stdout, | ||
desc=progress_bar_description, | ||
bar_format=DEFAULT_BAR_FORMAT | ||
bar_format=DEFAULT_BAR_FORMAT, | ||
) as pbar: | ||
|
||
def progress_callback(percent_change, description): | ||
|
@@ -184,6 +186,5 @@ def progress_callback(percent_change, description): | |
self.watch( | ||
progress_callback=progress_callback, | ||
max_wait_time=max_wait_time, | ||
poll_interval=poll_interval | ||
poll_interval=poll_interval, | ||
) | ||
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is in SEC?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think there's an extra zero here, should have been 1200 :)