-
Notifications
You must be signed in to change notification settings - Fork 4.3k
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
[yaml] Add yaml_provider.py Unit Tests #27804
Conversation
6f5ba45
to
988146c
Compare
Codecov ReportAttention:
Additional details and impacted files@@ Coverage Diff @@
## master #27804 +/- ##
==========================================
+ Coverage 72.31% 72.34% +0.03%
==========================================
Files 683 683
Lines 100633 100640 +7
==========================================
+ Hits 72768 72813 +45
+ Misses 26289 26251 -38
Partials 1576 1576
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Sentry. |
Checks are failing. Will not request review until checks are succeeding. If you'd like to override that behavior, comment |
988146c
to
5070208
Compare
if 'schema' not in args.keys(): | ||
raise ValueError("WithSchema transform missing required 'schema' tag.") | ||
named_tuple = schemas.named_tuple_from_schema(parse_schema(args['schema'])) |
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.
@robertwb Should I remove this now that we have the config
tag?
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.
The schema needs to be in the config now.
Assigning reviewers. If you would like to opt out of this review, comment R: @liferoad for label python. Available commands:
The PR bot will only process comments in the main thread (not review comments). |
Signed-off-by: Jeffrey Kinard <[email protected]>
5070208
to
4477171
Compare
Signed-off-by: Jeffrey Kinard <[email protected]>
4477171
to
6eea11a
Compare
try: | ||
return self._transform_factories[type](**args) | ||
except KeyError: | ||
raise KeyError(f'Invalid transform specified: "{type}".') |
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.
There may be other key errors that we catch here. Also, this should never be called unless type is already in self._transform_factories. If we want to raise this error here, do an explicit check for the key in the dictionary, rather than catch all key errors that may occur in the call.
return self._transform_factories[type](**args) | ||
except KeyError: | ||
raise KeyError(f'Invalid transform specified: "{type}".') | ||
except TypeError: |
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.
We already attempt a better error message at a higher level. But this will catch all type errors, not just invalid transform arguments.
@@ -372,7 +377,14 @@ def provided_transforms(self): | |||
return self._transform_factories.keys() | |||
|
|||
def create_transform(self, type, args, yaml_create_transform): | |||
return self._transform_factories[type](**args) | |||
try: |
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 we should revert catching these here (see below).
with self.assertRaises(ValueError) as e: | ||
ExternalProvider.provider_from_spec(spec) | ||
self.assertEqual(beam_version, spec['version']) | ||
self.assertRegex(str(e.exception), ".*Unexpected parameters in provider.*") |
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.
Use assertRaisesRegex
?
self.assertEqual(beam_version, spec['version']) | ||
self.assertRegex(str(e.exception), ".*Unexpected parameters in provider.*") | ||
|
||
# TODO - this test will need to be updated when docker support is added. |
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'd just remove this test.
} | ||
with self.assertRaises(ValueError) as e: | ||
ExternalProvider.provider_from_spec(spec) | ||
self.assertRegex(str(e.exception), ".*Missing type in provider.*") |
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.
assertRaisesRegex
def __init__(self, method_name="runExternalPythonProviderTest"): | ||
super().__init__(method_name) | ||
|
||
self._type = 'pythonPackage' |
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.
You could have _type as a class-level attribute and not bother overriding init.
Reminder, please take a look at this pr: @liferoad |
Assigning new set of reviewers because Pr has gone too long without review. If you would like to opt out of this review, comment R: @AnandInguva for label python. Available commands:
|
Reminder, please take a look at this pr: @AnandInguva |
This pull request has been marked as stale due to 60 days of inactivity. It will be closed in 1 week if no further activity occurs. If you think that’s incorrect or this pull request requires a review, please simply write any comment. If closed, you can revive the PR at any time and @mention a reviewer or discuss it on the [email protected] list. Thank you for your contributions. |
@Polber is this PR still relevant? |
This pull request has been marked as stale due to 60 days of inactivity. It will be closed in 1 week if no further activity occurs. If you think that’s incorrect or this pull request requires a review, please simply write any comment. If closed, you can revive the PR at any time and @mention a reviewer or discuss it on the [email protected] list. Thank you for your contributions. |
This pull request has been marked as stale due to 60 days of inactivity. It will be closed in 1 week if no further activity occurs. If you think that’s incorrect or this pull request requires a review, please simply write any comment. If closed, you can revive the PR at any time and @mention a reviewer or discuss it on the [email protected] list. Thank you for your contributions. |
Codecov ReportAttention: Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## master #27804 +/- ##
==========================================
+ Coverage 72.31% 72.34% +0.03%
==========================================
Files 683 683
Lines 100633 100640 +7
==========================================
+ Hits 72768 72813 +45
+ Misses 26289 26251 -38
Partials 1576 1576
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Sentry. |
This pull request has been marked as stale due to 60 days of inactivity. It will be closed in 1 week if no further activity occurs. If you think that’s incorrect or this pull request requires a review, please simply write any comment. If closed, you can revive the PR at any time and @mention a reviewer or discuss it on the [email protected] list. Thank you for your contributions. |
This pull request has been marked as stale due to 60 days of inactivity. It will be closed in 1 week if no further activity occurs. If you think that’s incorrect or this pull request requires a review, please simply write any comment. If closed, you can revive the PR at any time and @mention a reviewer or discuss it on the [email protected] list. Thank you for your contributions. |
This pull request has been marked as stale due to 60 days of inactivity. It will be closed in 1 week if no further activity occurs. If you think that’s incorrect or this pull request requires a review, please simply write any comment. If closed, you can revive the PR at any time and @mention a reviewer or discuss it on the [email protected] list. Thank you for your contributions. |
This pull request has been marked as stale due to 60 days of inactivity. It will be closed in 1 week if no further activity occurs. If you think that’s incorrect or this pull request requires a review, please simply write any comment. If closed, you can revive the PR at any time and @mention a reviewer or discuss it on the [email protected] list. Thank you for your contributions. |
This pull request has been closed due to lack of activity. If you think that is incorrect, or the pull request requires review, you can revive the PR at any time. |
Add unit tests for yaml_provider.py.
This PR also introduces non-breaking name changes to functions and variables to suppress IDE warnings.
There is also a change to the
WithSchema
built-in transform - it now requires aschema
tag so that the schema field names do not collide with the top-level transform tags (e.g "name").Thank you for your contribution! Follow this checklist to help us incorporate your contribution quickly and easily:
addresses #123
), if applicable. This will automatically add a link to the pull request in the issue. If you would like the issue to automatically close on merging the pull request, commentfixes #<ISSUE NUMBER>
instead.CHANGES.md
with noteworthy changes.See the Contributor Guide for more tips on how to make review process smoother.
To check the build health, please visit https://github.com/apache/beam/blob/master/.test-infra/BUILD_STATUS.md
GitHub Actions Tests Status (on master branch)
See CI.md for more information about GitHub Actions CI or the workflows README to see a list of phrases to trigger workflows.