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

fix: handle config file extension/overwriting more explicitly #1251

Merged
merged 3 commits into from
Nov 17, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion snakemake/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -1239,7 +1239,9 @@ def get_argument_parser(profile=None):
"Specify or overwrite the config file of the workflow (see the docs). "
"Values specified in JSON or YAML format are available in the global config "
"dictionary inside the workflow. Multiple files overwrite each other in "
"the given order."
"the given order. Thereby missing keys in previous config files are extended by "
"following configfiles. Note that this order also includes a config file defined "
"in the workflow definition itself (which will come first)."
),
)
group_exec.add_argument(
Expand Down
21 changes: 17 additions & 4 deletions snakemake/workflow.py
Original file line number Diff line number Diff line change
Expand Up @@ -1238,10 +1238,23 @@ def configfile(self, fp):
"""Update the global config with data from the given file."""
global config
if not self.modifier.skip_configfile:
self.configfiles.append(fp)
c = snakemake.io.load_configfile(fp)
update_config(config, c)
update_config(config, self.overwrite_config)
if os.path.exists(fp):
self.configfiles.append(fp)
c = snakemake.io.load_configfile(fp)
update_config(config, c)
if self.overwrite_config:
logger.info(
"Config file {} is extended by additional config specified via the command line.".format(
fp
)
)
update_config(config, self.overwrite_config)
elif not self.overwrite_configfiles:
raise WorkflowError(
"Workflow defines configfile {} but it is not present or accessible.".format(
fp
)
)

def pepfile(self, path):
global pep
Expand Down