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

add --field-prefix via click.option and update doc #124

Draft
wants to merge 8 commits into
base: master
Choose a base branch
from

Conversation

YeungOnion
Copy link

added option proposed in scikit-hep/histoprint #121


add --field-prefix via click.option
adding this option modifies kwargs which causes later errors
opting to delete this key, to fix root cause in later pr

implement behavior of --field-prefix option
uses click callback on the field option to handle this.

updated docs to include help text for --field-prefix option

remove type annotations
One of these type annotations was actually incorrect, but I noticed that they weren't used in this file. Opted to remove instead of fix

YeungOnion and others added 2 commits November 27, 2023 11:10
added option proposed in scikit-hep/histoprint scikit-hep#121

implement behavior of --field-prefix option

uses click callback on the field option to handle this.

updated docs to include help text for --field-prefix option

remove type annotations

One of these type annotations was actually incorrect, but I noticed
that they weren't used in this file. Opted to remove instead of fix
@ast0815
Copy link
Collaborator

ast0815 commented Nov 28, 2023

Hi! Thanks a lot for this PR. Could you add a test of this feature to .github/workflows/pythontests.yml? To make sure it keeps working in the future.

@YeungOnion
Copy link
Author

If github isn't notifying here, does that mean that all tests passed? If so, then I think I got it right.

@ast0815
Copy link
Collaborator

ast0815 commented Nov 28, 2023

If you look at the output of the tests (e.g. by clicking on the green checkmark next to the latest commit). you will see that it did not actually run your test defined in the tests.py file. That is because the test function names need to start with test_ in order to be discovered and run.

I would expect the test to fail, since you do ask for the field wo before setting the prefix t. The first field should be two, and that should check that the prefix does indeed only apply to fields after it.

You can also run pytest locally before pushing to test things.

@ast0815
Copy link
Collaborator

ast0815 commented Nov 28, 2023

Could you also remove the newlines from the option help text, so it behaves like the others, and also make the docstring of your test function follow the convention of the others?

@YeungOnion
Copy link
Author

I opted to ignore positional information, but didn't include that in the help doc, so I updated that along with the requests.

Comment on lines +90 to +91
help="String to prepend to all values indicated with --field option, "
"ignores position where this and --field options are specified.",
Copy link
Collaborator

Choose a reason for hiding this comment

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

Suggested change
help="String to prepend to all values indicated with --field option, "
"ignores position where this and --field options are specified.",
help="String to prepend to all '--field' values",

Command line options usually do not care about order so mentioning it seems more confusing than helping.

Also need to update the README. I usually just copy the output of histoprint -h directly into it, so it is exactly the same.

@ast0815
Copy link
Collaborator

ast0815 commented Nov 29, 2023

As you can see, the tests fail now: https://github.com/scikit-hep/histoprint/actions/runs/7023198492/job/19109160857?pr=124

Aside from fixing that, you also need to add the added option to the CHANGELOG.md. Just put it as a bullet point under

## [Unreleased]

### Added

migrate prefixing logic from callback into main
add test case and data
update changelog
@YeungOnion
Copy link
Author

Realized that click did not work the way I expected, but I think keeping it all in the decorators isn't worth the complexity. So it'll be implemented as a few lines in main - which may have always been the best bet. Now running pytest locally and all tests are passing.

@YeungOnion YeungOnion marked this pull request as draft December 7, 2023 07:02
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.

2 participants