-
-
Notifications
You must be signed in to change notification settings - Fork 86
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
feat: better reload options #362
Conversation
* Includes reload path option and filter options
…to reload-options
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Left some comments; vast majority of them are nits.
Thank you very much for your review :) I'll have to make another manual testing round later on, haven't spent a lot of time on that after the last two commits. @gi0baro, should we speak about unit tests for some functionalities? I could cover reload options in an early iteration. |
Gonna make another code review ASAP.
If you figure out a smart way to unit-test reload options, then yes please, go ahead. In general it's hard to unit-test Granian for everything which regards actual HTTP requests/application interaction (given also how the codebase is structured right now), maybe with some huge refactoring we can change this, but at the moment it feels too costly to be worth (especially considering there are 0 contributors on the Rust side at the moment except for myself). But again, given the context, I think it is a good candidate for unit.
Yep, I see it. I just need to find some time to proper reply :) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Left some suggestions/comments.
Also, probably changes to README.md
need an update too.
I'm sorry for the delay on this PR @gi0baro! Meanwhile, I was thinking a bit about tests.
E.g. 2. could be an assert for the response body not to be the later modified one. I think we could pull that off with minimal changes to WDYT? |
np at all, there's no need to rush here :)
This sounds more like testing
I'm definitely more up to a separate PR for tests, planning to review and merge this one in the near future. |
), | ||
multiple=True, | ||
) | ||
@option( | ||
'--reload-ignore-patterns', | ||
help=( | ||
'Entity patterns (regex) to ignore changes for. ' | ||
'Extends the default list of patterns to ignore in watchfiles.filters.DefaultFilter.' | ||
'Path patterns (regex) to ignore changes for. ' |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Quick note because I stumbled over this while testing the feature.
I had also assumed that this will regex match on the full path of something that triggered the reload. However, this only matches the last part of the path, meaning the exact file/dir that triggered the reload, not the entire path.
https://watchfiles.helpmanual.io/api/filters/#watchfiles.DefaultFilter.ignore_entity_patterns
"Entity" isn't a much better description 😛 but "Path" might be suggesting a different behaviour altogether. WDYT?
I want to avoid issues where users report this to be broken.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Oh, I missed that. Would Relative path patterns make sense to you?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sorry for the late answer.
I think being fully explicit could help.
'Path patterns (regex) to ignore changes for. ' | |
'File/directory name patterns (regex) to ignore changes for. ' |
WDYT?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks perfect. Can you open a PR for this? otherwise I'll do it by myself later
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No worries, will do!
Hey all,
I based this PR off of @Andrew-Chen-Wang's work and included his original commit from #225.
Additionally to the rebase, I made a few changes to the descriptions (as required in the previous PR) and added the capability to pass a
reload_filter
from the Python API.The
reload_filter
should be an obj based on watchfiles'BaseClass
.Closes #353 and #225.