Skip to content

Commit

Permalink
Delay lookup of allowed failures. (dask#2761)
Browse files Browse the repository at this point in the history
This allows for setting the config after importing distributed

xref dask/dask-examples#75 (comment)
  • Loading branch information
TomAugspurger authored and mrocklin committed Jun 8, 2019
1 parent 309e435 commit d378b41
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 3 deletions.
6 changes: 3 additions & 3 deletions distributed/scheduler.py
Original file line number Diff line number Diff line change
Expand Up @@ -73,8 +73,6 @@
logger = logging.getLogger(__name__)


ALLOWED_FAILURES = dask.config.get("distributed.scheduler.allowed-failures")

LOG_PDB = dask.config.get("distributed.admin.pdb-on-err")
DEFAULT_DATA_SIZE = dask.config.get("distributed.scheduler.default-data-size")

Expand Down Expand Up @@ -829,7 +827,7 @@ def __init__(
synchronize_worker_interval="60s",
services=None,
service_kwargs=None,
allowed_failures=ALLOWED_FAILURES,
allowed_failures=None,
extensions=None,
validate=False,
scheduler_file=None,
Expand All @@ -846,6 +844,8 @@ def __init__(
self._setup_logging(logger)

# Attributes
if allowed_failures is None:
allowed_failures = dask.config.get("distributed.scheduler.allowed-failures")
self.allowed_failures = allowed_failures
self.validate = validate
self.status = None
Expand Down
14 changes: 14 additions & 0 deletions distributed/tests/test_scheduler.py
Original file line number Diff line number Diff line change
Expand Up @@ -1607,3 +1607,17 @@ async def test_async_context_manager():
assert w.status == "running"
assert s.workers
assert not s.workers


@pytest.mark.asyncio
async def test_allowed_failures_config():
async with Scheduler(port=0, allowed_failures=10) as s:
assert s.allowed_failures == 10

with dask.config.set({"distributed.scheduler.allowed_failures": 100}):
async with Scheduler(port=0) as s:
assert s.allowed_failures == 100

with dask.config.set({"distributed.scheduler.allowed_failures": 0}):
async with Scheduler(port=0) as s:
assert s.allowed_failures == 0

0 comments on commit d378b41

Please sign in to comment.