Skip to content

Commit 14072d6

Browse files
authored
Issue #565 passing "env" to docker as extra-docker-config (#567)
* Update lean_runner.py * Update lean_runner.py * Extra env vars are added to existing ones. * Support for multiple input option
1 parent 80e83c8 commit 14072d6

File tree

1 file changed

+17
-0
lines changed

1 file changed

+17
-0
lines changed

lean/components/docker/lean_runner.py

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -935,6 +935,23 @@ def parse_extra_docker_config(run_options: Dict[str, Any], extra_docker_config:
935935
# Add known additional run options from the extra docker config.
936936
# For now, only device_requests is supported
937937
if extra_docker_config is not None:
938+
939+
if "name" in extra_docker_config:
940+
run_options["name"] = extra_docker_config["name"]
941+
942+
if "environment" in extra_docker_config:
943+
target = run_options.get("environment")
944+
if not target:
945+
target = run_options["environment"] = {}
946+
if isinstance(extra_docker_config["environment"], list):
947+
target.update({item[0]: item[1] for item in [
948+
item if not isinstance(item, str) else (item.split("=")[0], item.split("=")[1]) for item in extra_docker_config["environment"]
949+
]})
950+
elif isinstance(extra_docker_config["environment"], dict):
951+
target.update(extra_docker_config["environment"])
952+
else:
953+
raise ValueError("Additional environment variables can be passed to the container in a dictionary, list of '{key}={value}' strings, or list of '(key, value)' tuples.")
954+
938955
if "device_requests" in extra_docker_config:
939956
from docker.types import DeviceRequest
940957
run_options["device_requests"] = [DeviceRequest(**device_request)

0 commit comments

Comments
 (0)