Skip to content

Commit

Permalink
Override cleanup distributed fixture, and reconfigure dask-jobqueue w…
Browse files Browse the repository at this point in the history
…hen called
  • Loading branch information
guillaumeeb committed Jul 28, 2022
1 parent fa27942 commit d50cc2d
Show file tree
Hide file tree
Showing 5 changed files with 19 additions and 6 deletions.
10 changes: 9 additions & 1 deletion conftest.py
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
# content of conftest.py

# Make loop fixture available in all tests
from distributed.utils_test import loop, cleanup # noqa: F401
from distributed.utils_test import loop # noqa: F401

import pytest

import dask_jobqueue.config
import dask_jobqueue.lsf
import dask

Expand Down Expand Up @@ -88,6 +89,13 @@ def mock_lsf_version(monkeypatch, request):
"htcondor": HTCondorCluster,
}

# We override cleanup method from distributed that has been added to the loop
# fixture, because it just wipe the Main Loop in our tests.
@pytest.fixture
def cleanup():
dask_jobqueue.config.reconfigure()
yield


@pytest.fixture(
params=[pytest.param(v, marks=[pytest.mark.env(k)]) for (k, v) in all_envs.items()]
Expand Down
Empty file added dask-worker-space/global.lock
Empty file.
Empty file added dask-worker-space/purge.lock
Empty file.
Empty file.
15 changes: 10 additions & 5 deletions dask_jobqueue/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,15 @@
import dask
import yaml

fn = os.path.join(os.path.dirname(__file__), "jobqueue.yaml")
dask.config.ensure_file(source=fn)

with open(fn) as f:
defaults = yaml.safe_load(f)
def reconfigure():
fn = os.path.join(os.path.dirname(__file__), "jobqueue.yaml")
dask.config.ensure_file(source=fn)

dask.config.update(dask.config.config, defaults, priority="old")
with open(fn) as f:
defaults = yaml.safe_load(f)

dask.config.update_defaults(defaults)


reconfigure()

0 comments on commit d50cc2d

Please sign in to comment.