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

CI: configure pre-commit with ruff and other simple checks, run pre-commit in CI #159

Draft
wants to merge 3 commits into
base: main
Choose a base branch
from

Conversation

eguiraud
Copy link
Contributor

Trying this out as @alexander-held mentioned it might be useful.

The only issue is that jupytext processes a lot of notebooks or python scripts that it has no business processing. I did not find an obvious way to restrict jupytext to only run on certain files. We could run it "manually" on the notebooks we care about but I guess it would be more elegant to do it via the pre-commit hook.

Suggestions are welcome :D

@alexander-held alexander-held requested a review from ekauffma June 13, 2023 09:39
Comment on lines +7 to +8
- id: check-yaml
- id: check-added-large-files
Copy link
Member

Choose a reason for hiding this comment

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

Let's also add these two here for things that we have not been super consistent on in the past: trailing-whitespace, end-of-file-fixer.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I actually had them in originally, I removed them because of the huge amount of changes all over the place that they would require. should I commit those changes as part of this PR as well?

Copy link
Member

Choose a reason for hiding this comment

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

I see, does this affect the workshops/ folder again or also analyses/? The former acts as more of a long term storage for material shown previously and we don't necessarily want to change it a lot, but for the latter I'd be happy to just apply all the changes.

Copy link
Member

Choose a reason for hiding this comment

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

Given that this might cause a lot of conflicts though it might be best to wait with that, it might make rebasing #158 a lot more difficult.

@ekauffma
Copy link
Collaborator

After some digging, I think you can specify which files to apply the hook to, like:

  • id: jupytext
    name: jupytext
    files: ^notebooks/ # Only apply this under notebooks/

(from reading https://www.edwinwenink.xyz/posts/70-version_control_on_notebooks_with_precommit_and_jupytext/)

@eguiraud
Copy link
Contributor Author

Thank you @ekauffma , I'll take a look.

Which directories should be considered? e.g. these are the notebooks under analyses/:

atlas-open-data-hzz/HZZ_analysis_pipeline.ipynb
atlas-open-data-hzz/alternative_implementations/CabinetryHZZAnalysis.ipynb
atlas-open-data-hzz/alternative_implementations/CoffeaHZZAnalysis.ipynb
atlas-open-data-hzz/alternative_implementations/infofile.ipynb
atlas-open-data-hzz/utils/__init__.ipynb
atlas-open-data-hzz/utils/infofile.ipynb
cms-open-data-ttbar/GetIOBranches.ipynb
cms-open-data-ttbar/coffea.ipynb
cms-open-data-ttbar/make_corrections_json.ipynb
cms-open-data-ttbar/ttbar_analysis_pipeline.ipynb
cms-open-data-ttbar/utils/__init__.ipynb
cms-open-data-ttbar/validate_histograms.ipynb

@ekauffma
Copy link
Collaborator

Hm I'd imagine we would only want cms-open-data-ttbar/ttbar_analysis_pipeline.ipynb, atlas-open-data-hzz/HZZ_analysis_pipeline.ipynb, and perhaps atlas-open-data-hzz/alternative_implementations/CabinetryHZZAnalysis.ipynb and
atlas-open-data-hzz/alternative_implementations/CoffeaHZZAnalysis.ipynb. I am not sure if it is possible to select specific files instead of directories, but we could try..

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.

3 participants