-
Notifications
You must be signed in to change notification settings - Fork 44
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 snakefmt
to pre-commit
#352
base: main
Are you sure you want to change the base?
Conversation
for more information, see https://pre-commit.ci
This looks great too! Can you fix the conflicts and try to see what the pre-commit failure is being caused by? Here is the error log:
Seems to be a syntax error somewhere, but it's not very clear :D |
This syntax error happens on master as well. It's due to
This is at the limits of my snakemake knowledge as I didn't even know you could have rules within if statements. Any idea? |
Nevermind I fixed it. Snakefiles are a little too expressive for my taste; it was some issue where it couldn't tell where a block ended and the next one began, so I put a |
@@ -18,44 +22,39 @@ workdir: paths.user().repo.as_posix() | |||
# What kind of run is this? (clean, build, etc.) | |||
run_type = get_run_type() | |||
|
|||
if not (paths.user().temp / "config.json").exists() and run_type != "clean": | |||
raise exceptions.MissingConfigFile() |
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 just made a second if statement instead of an else. But I'm not sure if onsuccess
refers to the original if statement or not?
Also - with this exception raised at the top, does the rest even need to be embedded in an if statement?
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 added some tiny inline comments, but this otherwise looks great!
# Remove old flags | ||
for file in paths.user().flags.glob("*"): | ||
file.unlink() | ||
|
||
|
||
# Set up custom logging for Snakemake | ||
# Set up custom logging for Snakemake |
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 formatting is wrong. Are there settings that we can change in snakefmt?
|
||
if run_type != "clean": | ||
raise exceptions.MissingConfigFile() | ||
pass |
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.
After adding the new conditional at the top, this isn't still needed anymore, is 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.
I think you are correct.
Actually, could the entire if statement be removed now, since the check is at the top?
It looks like this might be a bug in snakefmt: snakemake/snakefmt#190 and snakemake/snakefmt#186 We could wait to merge this until those bugs are fixed, lest it produces a bug on our side due to incorrect formatting. Wdyt? |
Sounds like a plan to me! |
Seems like a good addition given the number of snakemake files and the fact that
black
is already used for Python: