-
Notifications
You must be signed in to change notification settings - Fork 11
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 yaml format check in pre-commit #13
Conversation
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 @unkcpz !
I'm a little bit torn here, since I see it as an advantage if people can add yaml files without having to install pre-commit etc. (this means, e.g. it can be done directly via the github web interface).
At the same time I definitely see the benefit of uniformity... i.e. if the linter has clear instructions on how to fix the formatting, let's go ahead.
Please document in the README or wiki how to properly set up the pre-commit hooks.
computers/daint-mc/daint-mc.yml
Outdated
work_dir: /scratch/snx3000/{username}/aiida_run/ | ||
shebang: '#!/bin/bash' | ||
mpirun_command: srun -n {tot_num_mpiprocs} | ||
mpiprocs_per_machine: '36' |
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.
I guess these quotation marks are introduced because we had quotation marks before, and it wants to keep the information that this should be treated as a string.
However, it would be perfectly fine to treat it as a number as well, i.e. these quotation marks (and those of all other numbers) can be removed.
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.
I guess these quotation marks are introduced because we had quotation marks before
That true. But we can not depend on pre-commit to fix or check this, or we need to customize this rule ourselves (include other customize format errors such as checking invalid input keys).
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.
Ah, don't worry about this for new additions - I just wanted to make sure the examples we have in the repository are as clear as possible (i.e. just change it for the existing ones).
If people go by those examples, it will continue to be like this.
I was wondering, are there some approaches to automatically fix trivial or non-critical format issues (warnings in |
0353ab0
to
6ab6469
Compare
There are - it could create a new PR with the changes; and we've tried that on aiida-core but it does not work for pull requests from forks, which are the ones where it would matter here. However, if the output from the linter is good, one can have github actions create a commit comment with the things to change; I think this is the best approach currently. |
Ha! that's what I am looking for, thanks for the links, I'll have a try. |
### code prepend_text start ### | ||
module load CP2K | ||
### code prepend_text end ### | ||
append_text: ' ' |
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.
I believe this can be an empty string. No need to keep a space here, right? Same for all the cases below.
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.
I think so, don't know why use space here originally. I will change this to empty string.
EDIT: or just remove this parameter in the config file.
That's not true, if for example the append_text
is not set here or it is set to empty string ''
(without space) . when user call code setup up with verdi, it will prompt and wait user to input. While using ' '
(with space in middle) will fill the parameter. Therefore, it is necessary to leave a space here.
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.
Yes, this is something that will need to be fixed in AiiDA at some point. It is necessary at the moment.
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.
wow, didn't know that. Thanks!
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.
Yes, this is something that will need to be fixed in AiiDA at some point. It is necessary at the moment.
Is there an issue for that?
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.
I checked and didn't find one for this issue specifically. You're welcome to create it
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.
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.
I think the issue has been resolved in the latest release of AiiDA.
3a92c0e
to
6ab6469
Compare
@unkcpz let us know if you need any help to finalize the PR. |
Thanks @yakutovicha. it's been a bit long time, I will take some time to finish this. I'll let you know if there is any progress. thanks. |
@unkcpz - this is not urgent, but would be nice to get this PR merged at some point. probably easiest to just take the pre-commit and yamllint configs and rerun them on the registry (to avoid merge conflicts) |
Oh, damn. I totally forget about this. Will finish this before next week. |
be6a025
to
abb6417
Compare
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 @unkcpz , looks good to me!
one small question
The yamllint configuration is set in the file .yamllint. In pre-commit, the strict mode is open to list all the warnings. Therefore all the start yaml document warnings are catched and fixed with adding `---` in front of yaml files.
abb6417
to
55a41a7
Compare
Guys, why did you mess up the repository structure? :( |
@yakutovicha Sorry about that, I didn't notice that. I maybe wrongly rebase the commit. Tell me how to remedy for this, do we need rollback? Or you will make new commits? |
I just made the PR, please have a look #43. |
Sorry about this - I should have paid closer attention. I just checked the "Files changed" tab again and it does not show any renamed files, so I would have needed to notice that some files were already named differently than in the repo. There used to be an option "Require branches to be up to date" in the branch protection rules which I think might have helped here. But I no longer see it https://github.com/aiidateam/aiida-code-registry/settings/branch_protection_rules/22415444 If someone knows where it went or how we could make sure that it would have shown the renamed files here, just let me know. |
P.S. I now see - there are a couple of new files in the "Files changed"; this I should have noticed. |
pre-commit check of all yaml files in the repository, with yamlfmt
format yaml file automatically and with yamllint check the final format.