Skip to content
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

Closed
wants to merge 2 commits into from

Conversation

Polber
Copy link
Contributor

@Polber Polber commented Aug 2, 2023

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 a schema 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:

  • Mention the appropriate issue in your description (for example: 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, comment fixes #<ISSUE NUMBER> instead.
  • Update CHANGES.md with noteworthy changes.
  • If this contribution is large, please file an Apache Individual Contributor License Agreement.

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)

Build python source distribution and wheels
Python tests
Java tests
Go tests

See CI.md for more information about GitHub Actions CI or the workflows README to see a list of phrases to trigger workflows.

@github-actions github-actions bot added the python label Aug 2, 2023
@Polber Polber force-pushed the jkinard/add-yaml-provider-tests branch from 6f5ba45 to 988146c Compare August 2, 2023 17:15
@codecov
Copy link

codecov bot commented Aug 2, 2023

Codecov Report

Attention: 6 lines in your changes are missing coverage. Please review.

Comparison is base (1032533) 72.31% compared to head (6eea11a) 72.34%.
Report is 1245 commits behind head on master.

Files Patch % Lines
sdks/python/apache_beam/yaml/yaml_provider.py 72.72% 6 Missing ⚠️
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              
Flag Coverage Δ
python 82.88% <72.72%> (+0.06%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@github-actions
Copy link
Contributor

github-actions bot commented Aug 2, 2023

Checks are failing. Will not request review until checks are succeeding. If you'd like to override that behavior, comment assign set of reviewers

@Polber Polber force-pushed the jkinard/add-yaml-provider-tests branch from 988146c to 5070208 Compare September 12, 2023 23:51
Comment on lines +444 to +463
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']))
Copy link
Contributor Author

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?

Copy link
Contributor

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.

@Polber Polber requested a review from robertwb September 12, 2023 23:54
@github-actions
Copy link
Contributor

Assigning reviewers. If you would like to opt out of this review, comment assign to next reviewer:

R: @liferoad for label python.

Available commands:

  • stop reviewer notifications - opt out of the automated review tooling
  • remind me after tests pass - tag the comment author after tests pass
  • waiting on author - shift the attention set back to the author (any comment or push by the author will return the attention set to the reviewers)

The PR bot will only process comments in the main thread (not review comments).

@Polber Polber force-pushed the jkinard/add-yaml-provider-tests branch from 5070208 to 4477171 Compare September 13, 2023 18:15
Signed-off-by: Jeffrey Kinard <[email protected]>
@Polber Polber force-pushed the jkinard/add-yaml-provider-tests branch from 4477171 to 6eea11a Compare September 13, 2023 18:32
try:
return self._transform_factories[type](**args)
except KeyError:
raise KeyError(f'Invalid transform specified: "{type}".')
Copy link
Contributor

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:
Copy link
Contributor

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:
Copy link
Contributor

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.*")
Copy link
Contributor

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.
Copy link
Contributor

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.*")
Copy link
Contributor

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'
Copy link
Contributor

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.

@github-actions
Copy link
Contributor

Reminder, please take a look at this pr: @liferoad

@github-actions
Copy link
Contributor

Assigning new set of reviewers because Pr has gone too long without review. If you would like to opt out of this review, comment assign to next reviewer:

R: @AnandInguva for label python.

Available commands:

  • stop reviewer notifications - opt out of the automated review tooling
  • remind me after tests pass - tag the comment author after tests pass
  • waiting on author - shift the attention set back to the author (any comment or push by the author will return the attention set to the reviewers)

@github-actions
Copy link
Contributor

github-actions bot commented Oct 7, 2023

Reminder, please take a look at this pr: @AnandInguva

Copy link
Contributor

github-actions bot commented Dec 6, 2023

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.

@github-actions github-actions bot added the stale label Dec 6, 2023
@AnandInguva
Copy link
Contributor

@Polber is this PR still relevant?

@github-actions github-actions bot removed the stale label Dec 7, 2023
Copy link
Contributor

github-actions bot commented Feb 6, 2024

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.

@github-actions github-actions bot added the stale label Feb 6, 2024
@github-actions github-actions bot removed the stale label Feb 7, 2024
@Polber Polber marked this pull request as draft February 13, 2024 16:22
Copy link
Contributor

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.

@github-actions github-actions bot added the stale label Apr 14, 2024
@codecov-commenter
Copy link

codecov-commenter commented Apr 14, 2024

Codecov Report

Attention: Patch coverage is 72.72727% with 6 lines in your changes missing coverage. Please review.

Project coverage is 72.34%. Comparing base (1032533) to head (6eea11a).
Report is 3489 commits behind head on master.

Files with missing lines Patch % Lines
sdks/python/apache_beam/yaml/yaml_provider.py 72.72% 6 Missing ⚠️
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              
Flag Coverage Δ
python 82.88% <72.72%> (+0.06%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@github-actions github-actions bot removed the stale label Apr 15, 2024
Copy link
Contributor

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.

@github-actions github-actions bot added stale and removed stale labels Jun 14, 2024
Copy link
Contributor

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.

@github-actions github-actions bot added stale and removed stale labels Aug 14, 2024
Copy link
Contributor

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.

@github-actions github-actions bot added stale and removed stale labels Oct 14, 2024
Copy link
Contributor

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.

@github-actions github-actions bot added the stale label Dec 15, 2024
Copy link
Contributor

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.

@github-actions github-actions bot closed this Dec 23, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants