-
Notifications
You must be signed in to change notification settings - Fork 1.2k
fix: tag permission issue - remove describe before create #3662
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
Changes from all commits
e7ed90d
c98b231
607f85a
3d00085
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -15,6 +15,8 @@ | |
|
||
import time | ||
|
||
from botocore.exceptions import ClientError | ||
|
||
from sagemaker.apiutils import _base_types | ||
from sagemaker.experiments.trial import _Trial | ||
from sagemaker.experiments.trial_component import _TrialComponent | ||
|
@@ -154,17 +156,21 @@ def _load_or_create( | |
Returns: | ||
experiments.experiment._Experiment: A SageMaker `_Experiment` object | ||
""" | ||
sagemaker_client = sagemaker_session.sagemaker_client | ||
try: | ||
experiment = _Experiment.load(experiment_name, sagemaker_session) | ||
except sagemaker_client.exceptions.ResourceNotFound: | ||
experiment = _Experiment.create( | ||
experiment_name=experiment_name, | ||
display_name=display_name, | ||
description=description, | ||
tags=tags, | ||
sagemaker_session=sagemaker_session, | ||
) | ||
except ClientError as ce: | ||
error_code = ce.response["Error"]["Code"] | ||
error_message = ce.response["Error"]["Message"] | ||
if not (error_code == "ValidationException" and "already exists" in error_message): | ||
raise ce | ||
Comment on lines
+168
to
+171
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. Nit: these lines of code keeps repeating. May be good to extract them to a helper function 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. ack, a definite improvement 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. +1 to that. Also I don't like the idea of logic depending on the parsed error message. As error messages are prone to change and will break the logic |
||
# already exists | ||
experiment = _Experiment.load(experiment_name, sagemaker_session) | ||
return experiment | ||
|
||
def list_trials(self, created_before=None, created_after=None, sort_by=None, sort_order=None): | ||
|
Uh oh!
There was an error while loading. Please reload this page.