Skip to content

Replaced generic ValueError with custom subclass when reporting unexpected resource status#855

Closed
arodiss wants to merge 3 commits into
aws:masterfrom
arodiss:master
Closed

Replaced generic ValueError with custom subclass when reporting unexpected resource status#855
arodiss wants to merge 3 commits into
aws:masterfrom
arodiss:master

Conversation

@arodiss
Copy link
Copy Markdown
Contributor

@arodiss arodiss commented Jun 14, 2019

Issue #, if available:
None

Description of changes:
Replaced generic ValueError with custom subclass when reporting unexpected resource status

Merge Checklist

Put an x in the boxes that apply. You can also fill these out after creating the PR. If you're unsure about any of them, don't hesitate to ask. We're here to help! This is simply a reminder of what we are going to look for before merging your pull request.

  • I have read the CONTRIBUTING doc
  • I used the commit message format described in CONTRIBUTING
  • I have added tests that prove my fix is effective or that my feature works (if appropriate)
  • I have updated any necessary documentation (if appropriate)

By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.

@jesterhazy
Copy link
Copy Markdown
Contributor

AWS CodeBuild CI Report

  • Result: FAILED
  • Build Logs (available for 30 days)

Powered by github-codebuild-logs, available on the AWS Serverless Application Repository

@jesterhazy
Copy link
Copy Markdown
Contributor

AWS CodeBuild CI Report

  • Result: FAILED
  • Build Logs (available for 30 days)

Powered by github-codebuild-logs, available on the AWS Serverless Application Repository

@mvsusp
Copy link
Copy Markdown
Contributor

mvsusp commented Jun 14, 2019

Hello @arodiss, thanks for the contribution. Any special reasoning behinds creating a new special exception? I would tend to just use ValueError here otherwise.

@mvsusp mvsusp self-requested a review June 14, 2019 18:36
Copy link
Copy Markdown
Contributor

@mvsusp mvsusp left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hello @arodiss, thanks for the contribution. Any special reasoning behinds creating a new special exception? I would tend to just use ValueError here otherwise.

@arodiss
Copy link
Copy Markdown
Contributor Author

arodiss commented Jun 17, 2019

@mvsusp
I want to catch this specific situation in my client script, and to distinguish between "batch transformation status is failed because some records are malformed" and "ValueError was raised by one of the 10000 possible sources" I have to parse error message, which is meh.
Generally, I think that specific exception classes are strictly preferable over built-ins - they allow something for a client but do not demand anything from him.
Here my custom exception is inherited from the ValueError, so if somebody is not interested in specific handling - his code will work just as it did before

@mvsusp
Copy link
Copy Markdown
Contributor

mvsusp commented Jun 17, 2019

Agreed that is helpful in your use case. Thanks for your contribution!

@@ -0,0 +1,9 @@
from __future__ import absolute_import
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please add copyright.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

added

Comment thread src/sagemaker/session.py Outdated
)
return desc

def create_endpoint_config(self, name, model_name, initial_instance_count, instance_type,
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please include unit tests, example

def test_create_endpoint_config(sagemaker_session):

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

included

Comment thread src/sagemaker/session.py
message='Error for {} {}: {} Reason: {}'.format(job_type, job, status, reason),
allowed_statuses=['Completed', 'Stopped'],
actual_status=status
)
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We need unit tests here as well.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done

Comment thread src/sagemaker/session.py
allowed_statuses=['InService'],
actual_status=status
)
return desc
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please include unit tests.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done

Comment thread src/sagemaker/session.py Outdated
from sagemaker import vpc_utils
from sagemaker.user_agent import prepend_user_agent
from sagemaker.utils import name_from_image, secondary_training_status_changed, secondary_training_status_message
from sagemaker.exceptions import UnexpectedStatusException
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Let's try to follow Google Python Style guide, http://google.github.io/styleguide/pyguide.html#224-decision

from sagemaker import exceptions

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

updated.
I have to mention that other imports in the same file are quite far from the guide

@jesterhazy
Copy link
Copy Markdown
Contributor

AWS CodeBuild CI Report

  • Result: FAILED
  • Build Logs (available for 30 days)

Powered by github-codebuild-logs, available on the AWS Serverless Application Repository

@jesterhazy
Copy link
Copy Markdown
Contributor

AWS CodeBuild CI Report

  • Result: FAILED
  • Build Logs (available for 30 days)

Powered by github-codebuild-logs, available on the AWS Serverless Application Repository

@jesterhazy
Copy link
Copy Markdown
Contributor

AWS CodeBuild CI Report

  • Result: FAILED
  • Build Logs (available for 30 days)

Powered by github-codebuild-logs, available on the AWS Serverless Application Repository

@arodiss
Copy link
Copy Markdown
Contributor Author

arodiss commented Jun 19, 2019

@mvsusp
All done.
Test failures are same as on the master

@jesterhazy
Copy link
Copy Markdown
Contributor

AWS CodeBuild CI Report

  • Result: FAILED
  • Build Logs (available for 30 days)

Powered by github-codebuild-logs, available on the AWS Serverless Application Repository

@jesterhazy
Copy link
Copy Markdown
Contributor

AWS CodeBuild CI Report

  • Result: FAILED
  • Build Logs (available for 30 days)

Powered by github-codebuild-logs, available on the AWS Serverless Application Repository

@jesterhazy
Copy link
Copy Markdown
Contributor

AWS CodeBuild CI Report

  • Result: FAILED
  • Build Logs (available for 30 days)

Powered by github-codebuild-logs, available on the AWS Serverless Application Repository

@jesterhazy
Copy link
Copy Markdown
Contributor

AWS CodeBuild CI Report

  • Result: FAILED
  • Build Logs (available for 30 days)

Powered by github-codebuild-logs, available on the AWS Serverless Application Repository

@jesterhazy
Copy link
Copy Markdown
Contributor

AWS CodeBuild CI Report

  • Result: FAILED
  • Build Logs (available for 30 days)

Powered by github-codebuild-logs, available on the AWS Serverless Application Repository

@jesterhazy
Copy link
Copy Markdown
Contributor

AWS CodeBuild CI Report

  • Result: FAILED
  • Build Logs (available for 30 days)

Powered by github-codebuild-logs, available on the AWS Serverless Application Repository

@jesterhazy
Copy link
Copy Markdown
Contributor

AWS CodeBuild CI Report

  • Result: FAILED
  • Build Logs (available for 30 days)

Powered by github-codebuild-logs, available on the AWS Serverless Application Repository

@jesterhazy
Copy link
Copy Markdown
Contributor

AWS CodeBuild CI Report

  • Result: FAILED
  • Build Logs (available for 30 days)

Powered by github-codebuild-logs, available on the AWS Serverless Application Repository

@arodiss
Copy link
Copy Markdown
Contributor Author

arodiss commented Jul 10, 2019

Moved to #919

@arodiss arodiss closed this Jul 10, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants