Skip to content

Commit

Permalink
Add detailed example to flepimop patch --help
Browse files Browse the repository at this point in the history
  • Loading branch information
TimothyWillard committed Dec 11, 2024
1 parent fe1dc2b commit d397eb1
Showing 1 changed file with 79 additions and 1 deletion.
80 changes: 79 additions & 1 deletion flepimop/gempyor_pkg/src/gempyor/cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,85 @@
)
@click.pass_context
def patch(ctx: click.Context = mock_context, **kwargs) -> None:
"""Merge configuration files"""
"""Merge configuration files
This command will merge multiple config files together by overriding the top level
keys in config files. The order of the config files is important, as the last file
has the highest priority and the first has the lowest.
A brief example:
\b
```bash
$ cd $(mktemp -d)
$ cat << EOF > config1.yml
compartments:
infection_stage: ['S', 'I', 'R']
seir:
parameters:
beta:
value: 1.2
EOF
$ cat << EOF > config2.yml
name: 'more parameters'
seir:
parameters:
beta:
value: 3.4
gamma:
value: 5.6
EOF
$ flepimop patch config1.yml config2.yml --indent 4
...: UserWarning: Configuration files contain overlapping keys: {'seir'}.
warnings.warn(f"Configuration files contain overlapping keys: {intersect}.")
compartments:
infection_stage:
- S
- I
- R
config_src:
- config1.yml
- config2.yml
first_sim_index: 1
jobs: 14
name: more parameters
outcome_modifiers_scenarios: []
seir:
parameters:
beta:
value: 3.4
gamma:
value: 5.6
seir_modifiers_scenarios: []
stoch_traj_flag: false
write_csv: false
write_parquet: true
$ flepimop patch config2.yml config1.yml --indent 4
...: UserWarning: Configuration files contain overlapping keys: {'seir'}.
warnings.warn(f"Configuration files contain overlapping keys: {intersect}.")
compartments:
infection_stage:
- S
- I
- R
config_src:
- config2.yml
- config1.yml
first_sim_index: 1
jobs: 14
name: more parameters
outcome_modifiers_scenarios: []
seir:
parameters:
beta:
value: 1.2
parameters: null
seir_modifiers_scenarios: []
stoch_traj_flag: false
write_csv: false
write_parquet: true
```
"""
parse_config_files(config, ctx, **kwargs)
print(yaml.dump(yaml.safe_load(config.dump()), indent=kwargs["indent"]))

Expand Down

0 comments on commit d397eb1

Please sign in to comment.