Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Implement setting config variables that contain the dot in name #10992

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
8 changes: 6 additions & 2 deletions dask/config.py
Expand Up @@ -272,7 +272,7 @@ def collect_env(env: Mapping[str, str] | None = None) -> dict:

for name, value in env.items():
if name.startswith("DASK_"):
varname = name[5:].lower().replace("__", ".")
varname = name[5:].lower().replace("__", ".").replace("--", "__")
d[varname] = interpret_value(value)

result: dict = {}
Expand Down Expand Up @@ -429,7 +429,11 @@ def __init__(
if arg is not None:
for key, value in arg.items():
key = check_deprecations(key)
self._assign(key.split("."), value, config)
self._assign(
[s.replace("__", ".") for s in key.split(".")],
value,
config,
)
if kwargs:
for key, value in kwargs.items():
key = key.replace("__", ".")
Expand Down
6 changes: 4 additions & 2 deletions dask/tests/test_config.py
Expand Up @@ -227,6 +227,7 @@ def test_env():
"DASK_E__Y": "456",
"DASK_F": '[1, 2, "3"]',
"DASK_G": "/not/parsable/as/literal",
"DASK_G--A": "any",
"FOO": "not included",
}

Expand All @@ -237,6 +238,7 @@ def test_env():
"e": {"x": 123, "y": 456},
"f": [1, 2, "3"],
"g": "/not/parsable/as/literal",
"g.a": "any",
}

res = collect_env(env)
Expand Down Expand Up @@ -333,8 +335,8 @@ def test_set():
assert config["abc"] == 123
assert "abc" not in config

with dask.config.set({"abc.x": 1, "abc.y": 2, "abc.z.a": 3}):
assert config["abc"] == {"x": 1, "y": 2, "z": {"a": 3}}
with dask.config.set({"abc.x": 1, "abc.y": 2, "abc.z.a": 3, "abc.z.a__a": 4}):
assert config["abc"] == {"x": 1, "y": 2, "z": {"a": 3, "a.a": 4}}
assert "abc" not in config

d = {}
Expand Down