-
Notifications
You must be signed in to change notification settings - Fork 80
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 pre-commit hooks to this repo #4
Conversation
Let's change the contributors guidelines in this PR. @TuanaCelik we never run a formatter on the notebooks, I think this is a good opportunity to do it. The only problem I see, it's already hard to port changes from the haystack repo now, if we re-format the files it'll be impossible. So I would re-format all the things only if we're close enough to remove the files from the haystack repo. WDYT? |
@masci - regarding formatting, sounds good to me. Let me make sure I've got it right:
Correct? |
|
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.
Thanks for the PR! Can we also invoke python /scripts/generate_markdowns.py
in the pre-commit hook? The generation is pretty fast, we can afford to run it at every commit I think.
I agree. |
Taking inspiration from deepset-ai/haystack#2979, I refactored generate_markdowns.py: It is still possible to run the script on all the notebooks, using the argument I tested it on Ubuntu 22.04. |
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.
Hook doesn't work on mac, otherwise looks good
|
||
for filename in filenames: | ||
filepath = Path(filename) | ||
if filepath.parent == notebook_tutorials_dir and filepath.suffix == ".ipynb": |
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.
This doesn't seem to work on macOS, filepath
is relative to the root of the repo while notebook_tutorials_dir
is absolute.
I had the same problem in Haystack, I think we can hardcode paths here and use relatives everywhere.
This PR is for adding pre-commit hooks to the tutorials repository.
.pre-commit-config.yaml
from the haystack repo, then I removed all the hooks not related to Jupyter notebooks(I understood that pure python tutorials won't be supported)
Some notes/questions:
pre-commit run --all-files
, it seems that black-jupyter (22.6.0) wants to reformat all the notebooks. It can be an issue of my environment.)