Skip to content

feat(emcee): implement get_expected_outputs (closes #804)#1073

Open
christianescamilla15-cell wants to merge 1 commit intobilby-dev:mainfrom
christianescamilla15-cell:fix/emcee-expected-outputs
Open

feat(emcee): implement get_expected_outputs (closes #804)#1073
christianescamilla15-cell wants to merge 1 commit intobilby-dev:mainfrom
christianescamilla15-cell:fix/emcee-expected-outputs

Conversation

@christianescamilla15-cell
Copy link
Copy Markdown

Summary

Implements a concrete `get_expected_outputs` override for the `Emcee` sampler so that `bilby_pipe` knows about the `chain.dat` and `sampler.pickle` files it writes when using HTCondor file transfer.

Closes #804.

Background

From the issue:

`get_expected_outputs` for `emcee` was implemented based on the existing code in `bilby_pipe` but it should be updated to include `chains.dat` and `sampler.pickle`.

Looking at `bilby/core/sampler/emcee.py` the checkpoint logic is very explicit about what files get written:

```python
chain_file = os.path.join(out_dir, "chain.dat")
sampler_file = os.path.join(out_dir, "sampler.pickle")
```

But `get_expected_outputs` was not overridden on `Emcee`, so it was falling back to the generic `Sampler.get_expected_outputs` which returns only a directory with no files. This means `bilby_pipe` was not listing these files as expected outputs for HTCondor transfer.

Changes

`bilby/core/sampler/emcee.py`

Added a classmethod `get_expected_outputs` that returns:

  • Files: `{outdir}/emcee_{label}/chain.dat` and `{outdir}/emcee_{label}/sampler.pickle`
  • Directories: `{outdir}/emcee_{label}/`

The implementation follows the same pattern used by the existing `ptemcee`, `dynesty`, and `nessai` overrides.

`test/core/sampler/emcee_test.py`

Added `test_get_expected_outputs` following the pattern of the corresponding tests in `dynesty_test.py` and `nessai_test.py`. It verifies:

  • Exactly 2 files are reported
  • Exactly 1 directory is reported
  • The directory path is `{outdir}/emcee_{label}`
  • Both expected files (`chain.dat`, `sampler.pickle`) are in the list

Test plan

  • `py_compile` passes for modified files
  • New unit test added
  • Full test suite should pass in CI (reviewer to confirm)

References

Issue reported by @michael-williams (GitLab migration) — original comment at `bilby/core/sampler/emcee.py#L258`.

The Emcee sampler was inheriting the default get_expected_outputs from
the base Sampler class, which returns only a single directory. However,
emcee actually writes two concrete files during checkpointing via its
checkpoint_info property (bilby/core/sampler/emcee.py:256-257):

- chain.dat      (tab-separated chain history)
- sampler.pickle (dill-pickled EnsembleSampler for resume)

These were not being reported to bilby_pipe, which uses this method to
know which files to transfer via HTCondor. This PR adds an explicit
override for Emcee that reports both files plus the run directory.

Also adds a unit test in test/core/sampler/emcee_test.py following the
same pattern as the existing tests for Dynesty, Nessai, and Bilby_MCMC.
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

Successfully merging this pull request may close these issues.

Update get_expected_outputs for emcee

1 participant