joezuntz / cosmosis

Other
22 stars 16 forks source link

cosmosis-campaign runs don't keep env options from parent runs #123

Closed jessmuir closed 3 months ago

jessmuir commented 3 months ago

Hi! I just ran into a slightly counterintuitive behavior with a campaign file, using the env elements between a pair of runs.

The first run, which functions as expected, applies a baseline pipeline to a different fits file. Since I have several different noise realizations I'm working with, I want the fits filename and output labels from cosmosis to contain a string labeling that realization using the env variable $NOISEREAL. The initial run looks like this:

  - name: noisydata1
    parent: baseline_run
    env:
      NOISEREAL : "01"
    params:
    - DEFAULT.2PT_FILE = data_vectors/noisy_datavector_r${NOISEREAL}.fits

Then, I want to run an importance sampler on the output of that, using the same pipeline but saving the model predictions for the data vector elements as extra output. My run setup initially looked like this:

name: savedv.noisydata1-IS
    parent: noisydata1
    components:
    - nocuts # this just removes scale cuts so I save all DV predictions
    params:
    - pipeline.extra_output = data_vector/2pt_theory#1000
    - pipeline.fast_slow=F
    - sampler = importance
    - importance.input = ${ORIG_CHAIN_DIR}/noisydata1.txt

This fails, complaining that there is no such file data_vectors/noisy_datavector_r${NOISEREAL}.fits. That is to say, the env variable from the parent run doesn't seem to be copied over and/or interpreted when parsing the child run. Things work again if I add

env:
      NOISEREAL : "01"

to the bottom of savedv.noisydata1-IS.

I assume that fixing this would require some adjustment to how or when env variables are parsed.

joezuntz commented 3 months ago

Hi @jessmuir

Both this issue and the other one you found (with components not being imported) are solved now in version 3.6, which is released on PyPI and is pushed to conda-forge so should be out soon.

Thanks for spotting! Joe