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

Warn on unused arguments #238

Merged
merged 26 commits into from
May 15, 2023
Merged

Warn on unused arguments #238

merged 26 commits into from
May 15, 2023

Conversation

gtfierro
Copy link
Collaborator

@gtfierro gtfierro commented May 8, 2023

Fixes #203 and #237

Cleans up template evaluation with some more utility functions (all tested), and some additional comments. Also adds a few tests to cover untested edge cases in template evaluation. Fixes behavior around inlining dependencies with optional arguments (#237)

Adds a new flag, warn_unused, to Template.evaluate; defaults to True.
This raises a warning if not all of the mandatory parameters are
provided to the Template when it is evaluated. Will raise warning
if optional arguments are required (when using the corresponding flag on
Template.evaluate)
@gtfierro gtfierro marked this pull request as draft May 8, 2023 06:00
@gtfierro gtfierro marked this pull request as ready for review May 8, 2023 14:41
@gtfierro
Copy link
Collaborator Author

gtfierro commented May 8, 2023

There's a subtle logic bug in here that is causing the tests to fail; I'm anticipating a relatively minor change to the code, but feel free to hold off on review for a day

Copy link
Member

@TShapinsky TShapinsky left a comment

Choose a reason for hiding this comment

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

I don't have any issues with this PR. Do we think the tests will be fixed by the other PR being merged?

buildingmotif/dataclasses/template.py Show resolved Hide resolved
@gtfierro
Copy link
Collaborator Author

gtfierro commented May 9, 2023

I don't have any issues with this PR. Do we think the tests will be fixed by the other PR being merged?

They won't be, I don't think. There's a subtle issue with dependencies more than 1 'hop' away that I'm still trying to fix

gtfierro added 5 commits May 9, 2023 08:30
Due to how we have the dependencies structured, the mapsTo relationship
needs to refer to a connection point that lies in a dependency's
dependency. This makes that relationship explicit
New problem is when we are testing the libraries for validity,
sometimes we want to give an explicit argument to the 'mapsto'
optional arg w/n a dependency. However, we currently can't give
a binding to a nested dependency. The result is that we end up with
multiple mapsto (because the 'optional' mapsto argument gets a newly
minted URI from template.fill()), which fails validation.

This commit splits template dependency management into 2 phases: an
initial phase which adds the dependency links and args to the DB; a
second phase which checks that the args/params between the template and
its dependencies are all valid and work as expected.
@gtfierro gtfierro requested a review from TShapinsky May 10, 2023 20:43
@gtfierro
Copy link
Collaborator Author

Logic bug is fixed as discussed on the call today -- this is ready for review!

Copy link
Member

@MatthewSteen MatthewSteen left a comment

Choose a reason for hiding this comment

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

Just some questions about untested methods and suggestions for grammar and punctuation.

buildingmotif/database/table_connection.py Show resolved Hide resolved
buildingmotif/database/table_connection.py Outdated Show resolved Hide resolved
buildingmotif/database/table_connection.py Outdated Show resolved Hide resolved
buildingmotif/database/table_connection.py Outdated Show resolved Hide resolved
buildingmotif/database/table_connection.py Outdated Show resolved Hide resolved
buildingmotif/utils.py Outdated Show resolved Hide resolved
buildingmotif/database/table_connection.py Outdated Show resolved Hide resolved
buildingmotif/database/table_connection.py Outdated Show resolved Hide resolved
buildingmotif/utils.py Outdated Show resolved Hide resolved
buildingmotif/utils.py Outdated Show resolved Hide resolved
@gtfierro gtfierro merged commit 1448e60 into develop May 15, 2023
@gtfierro gtfierro deleted the gtf-warn-unused-issue-203 branch May 15, 2023 19:57
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
3 participants