ert icon indicating copy to clipboard operation
ert copied to clipboard

Use `watchdog` to keep Storage with `mode="r"` up-to-date

Open pinkwah opened this issue 1 year ago • 3 comments

The Python package watchdog https://pypi.org/project/watchdog/ lets us watch a directory for changes, particularly when files are created and when files are deleted.

Definition of done is when the following test sketch passes:

def test_watchdog(tmp_path):
    with open_storage(tmp_path, mode="r", watch=True) as reader:
        assert _cases(reader) == []

        with open_storage(tmp_path, mode="w") as writer:
            writer.create_experiment().create_ensemble(name="foobar")

        assert _cases(reader) == ["foobar"]

pinkwah avatar Feb 09 '24 08:02 pinkwah

Might want to evaluate whether to use watchfiles instead of watchdog. https://pypi.org/project/watchfiles/

berland avatar Feb 09 '24 09:02 berland

This looks nice. Do I understand correctly that this would allow me to keep a read-only storage open in a Jupyter notebook while ert is running, and will stay up-to-date as new results are written to storage?

dafeda avatar Feb 12 '24 05:02 dafeda

This looks nice. Do I understand correctly that this would allow me to keep a read-only storage open in a Jupyter notebook while ert is running, and will stay up-to-date as new results are written to storage?

Yep.

pinkwah avatar Mar 08 '24 09:03 pinkwah