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

campaigns: yaml read-in can cause unexpected behavior from accidental duplicate keys #114

Closed
jessmuir opened this issue Jan 26, 2024 · 1 comment

Comments

@jessmuir
Copy link

(Accidentally initially submitted this as a standard library issue, copying it here where it is more relevant!)

When setting up a new run in a campaign yaml file, I accidentally created a run entry that had the params settings split in two places, like this:

  - name: testlike
    parent: baseline
    params:
    - sampler = test
    - pipeline.fast_slow = F
    env:
      DATA_VECTOR : sim_alt_w.fits
    params:
    - DEFAULT.2PT_FILE = data_vectors/${DATA_VECTOR}
    values:
    - cosmological_parameters--w = -0.90

Here, the parent run was set up to use the polychord sampler, but I wanted to do a quick test run to make sure the likelihood matched a the simulated datavector I'd just made (sim_alt_w.fits). When I ran this using cosmosis-campaign, it started the the polychord sampler, which suggests that perhaps the second block of params: read-in may have overwritten the first one, or caused the first one where I set sampler = test to be ignored.

While this mistake in my yaml file was pretty obvious (causing me to launch polychord instead of a test sampler), I could imagine scenarios where this could cause problems if not caught!

I think this is just the default behavior of how yaml.safe_load() handles duplicate keys. I'm not sure what the best fix is, but if possible it'd be good to either have the yaml parser throw an error if you have a duplicate list name or adjust the read-in so it can handle cases where the params (or env or values or pipeline) lists are split into two parts.

@joezuntz
Copy link
Owner

Addressed in issue #117

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants