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

Check manifest fields for type errors. #485

Closed
wants to merge 3 commits into from

Conversation

dblock
Copy link
Member

@dblock dblock commented Sep 15, 2021

Signed-off-by: dblock dblock@dblock.org

Description

Issues Resolved

Closes #470.

Check List

  • Commits are signed per the DCO using --signoff

By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.
For more information on following Developer Certificate of Origin and signing off your commits, please check here.

@@ -0,0 +1,111 @@
# SPDX-License-Identifier: Apache-2.0
Copy link
Member

Choose a reason for hiding this comment

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

Nit: Not sure but can we have the name of the file as typechecker as typechecked is an internal keyword?

Copy link
Member Author

Choose a reason for hiding this comment

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

Renamed to match the class name, dataclass_typechecked.

ref: 1.1
checks:
- gradle:publish
- gradle:properties:version
Copy link
Member

Choose a reason for hiding this comment

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

New line here

Copy link
Member Author

Choose a reason for hiding this comment

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

Added.

owaiskazi19
owaiskazi19 previously approved these changes Sep 15, 2021
Copy link
Member

@owaiskazi19 owaiskazi19 left a comment

Choose a reason for hiding this comment

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

Few should have's

Copy link
Member

@peternied peternied left a comment

Choose a reason for hiding this comment

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

This seems like a large/complex amount of work when all the types in the build manifest are strings. Is there a usecase where we need to support numeric values?

Could we do something simpler where we automatically convert all values to strings?

@dblock
Copy link
Member Author

dblock commented Sep 16, 2021

This seems like a large/complex amount of work when all the types in the build manifest are strings. Is there a usecase where we need to support numeric values?

Could we do something simpler where we automatically convert all values to strings?

I see the following options.

  1. This change.
  2. We could not merge this and str() the ref on a git repo (or str all the non-dict fields). This would be a hack to work around the fact that 1.1 is of type float and not a string, and there's no guarantee that a branch name such as 1.01 doesn't suddenly convert to a string 1.099999 or something like that in the future, which will be hard to debug.
  3. We could check explicitly that this one field is an str instead of adding a typechecker. Feels not very future-proof. Plus the check as is also catches issues such as not specifying a dictionary where it should be one - it's an actual validator for manifest schema.

More importantly, agronholm/typeguard#161 is opened to add the dataclass type checking code to the typeguard library, so the complex code will be then removed from here. There's really not much going on other than that :)

@dblock
Copy link
Member Author

dblock commented Sep 16, 2021

@peternied LMK what you think - this does fix a bug and prevents future bugs.

Signed-off-by: dblock <dblock@dblock.org>
@codecov-commenter
Copy link

codecov-commenter commented Sep 16, 2021

Codecov Report

Merging #485 (0972e82) into main (3a6dbae) will increase coverage by 1.93%.
The diff coverage is 87.73%.

Impacted file tree graph

@@            Coverage Diff             @@
##             main     #485      +/-   ##
==========================================
+ Coverage   69.31%   71.25%   +1.93%     
==========================================
  Files          58       59       +1     
  Lines        1509     1607      +98     
==========================================
+ Hits         1046     1145      +99     
+ Misses        463      462       -1     
Impacted Files Coverage Δ
...ow/src/ci_workflow/ci_check_gradle_dependencies.py 100.00% <ø> (ø)
...src/manifests_workflow/component_opensearch_min.py 100.00% <ø> (ø)
...le-workflow/src/manifests/dataclass_typechecked.py 79.03% <79.03%> (ø)
bundle-workflow/src/manifests/build_manifest.py 100.00% <100.00%> (ø)
bundle-workflow/src/manifests/bundle_manifest.py 100.00% <100.00%> (ø)
bundle-workflow/src/manifests/input_manifest.py 100.00% <100.00%> (ø)
bundle-workflow/src/manifests/manifest.py 96.66% <100.00%> (+0.11%) ⬆️
bundle-workflow/src/manifests/test_manifest.py 100.00% <100.00%> (+100.00%) ⬆️
...workflow/src/manifests_workflow/input_manifests.py 95.65% <100.00%> (ø)
bundle-workflow/src/system/properties_file.py 97.36% <100.00%> (ø)
... and 2 more

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update c678193...0972e82. Read the comment docs.

@peternied
Copy link
Member

What about defining a schema document and validating? Implemented something close on my fork Schematize and validate bundle manitests

Copy link
Member

@peternied peternied left a comment

Choose a reason for hiding this comment

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

Since python doesn't enforce typing I guess I am hesitant to rely on the current effort because while it works right now, a new untyped field could be added and it might be missed.

@dblock
Copy link
Member Author

dblock commented Sep 16, 2021

I like the schema idea better. Do you want to finish that or do you want me to take it?

@peternied
Copy link
Member

@dblock Could you pick it up the schema change and make a new PR?

@dblock dblock mentioned this pull request Sep 16, 2021
1 task
@dblock
Copy link
Member Author

dblock commented Sep 16, 2021

Closing in favor of #509.

@dblock dblock closed this Sep 16, 2021
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.

Test that manifests don't contain float refs
4 participants