Check for empty user-defined subsampling scheme #1082
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Description of proposed changes
Adds a check for an empty user-defined subsampling scheme and provides a helpful error message when this happens to replace the unhelpful
AttributeError
message users would get before when the workflow tried to access a nonexistent method of aNoneType
.This error can happen when a user defines a custom subsampling scheme where the contents are not properly indented below the
subsampling
key. The resulting config is still a valid YAML file, so the emptiness of the subsampling scheme needs to be checked specifically. We could probably handle this better and more generically with a more stringent YAML schema.Along the lines of that last point, I tried adding the following lines to the config schema to prevent an empty subsampling scheme:
This change did not catch the issue with the user-defined configuration, however, because we call the validation function after we load the default config file and it is during this step that Snakemake throws an error (presumably when deep-merging the user-provided and default config files).
Next, I tried validating both before and after the
configfile
declaration in the Snakefile. This change catches the incorrect config file and prints the following error for the user:I like that this error gets generated from the schema without additional code added to the workflow itself. I wish the error from this validation step provided more details to the user about what specifically went wrong. The error I provide in the commit of this PR seems more helpful to the user, even though it requires a modification to the workflow
Testing