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

Fix URLConfig.evaluate_dry #1219

Merged
merged 1 commit into from Jul 18, 2023
Merged

Fix URLConfig.evaluate_dry #1219

merged 1 commit into from Jul 18, 2023

Conversation

jmosbacher
Copy link
Member

@jmosbacher jmosbacher commented Jul 18, 2023

URLConfig.evaluate_dry was using the url_to_ast method which returns a nested abstract syntax tree so only the top level kwargs were replaced. This causes errors when trying to replace kwargs used by nested protocols.
The PR uses the URLConfig.format_url_kwargs which replaces kwargs globally in the URL.

Minimal example:

URL = "list-to-array://xedocs://pmt_area_to_pes?as_list=True&sort=pmt&detector=tpc&run_id=plugin.run_id&version=v9&attr=value"
straxen.URLConfig.evaluate_dry(URL, run_id='047600')

@jmosbacher jmosbacher requested a review from dachengx July 18, 2023 11:51
@@ -536,8 +535,8 @@ def evaluate_dry(cls, url: str, **kwargs):
f"Try passing {k} as a keyword argument."
f"e.g.: `URLConfig.evaluate_dry({url}, {k}=SOME_VALUE)`"
)

return cls.eval(protocol, url_arg, combined_kwargs)

Choose a reason for hiding this comment

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

[pep8] reported by reviewdog 🐶
W293 blank line contains whitespace

@coveralls
Copy link

Coverage Status

coverage: 93.567% (+0.03%) from 93.534% when pulling 18242f5 on fix_urlconfig_bug into 03ab8b8 on master.

Copy link
Collaborator

@dachengx dachengx left a comment

Choose a reason for hiding this comment

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

Thanks @jmosbacher ! Looks good to me.

@dachengx dachengx merged commit b3e776f into master Jul 18, 2023
8 checks passed
@dachengx dachengx deleted the fix_urlconfig_bug branch July 18, 2023 14:03
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.

None yet

3 participants