Skip to content

Commit eb82263

Browse files
manventolaurenyu
authored andcommitted
Fix "ValueError: too many values to unpack (expected 2)" is occurred in windows local mode (#1125)
Windows paths start with unit letter and colon. Moreover when composing docker image path it's better to not use os.path.join, because docker image is a unix OS, but os path use separator.
1 parent 0838bf0 commit eb82263

File tree

1 file changed

+6
-5
lines changed

1 file changed

+6
-5
lines changed

src/sagemaker/local/image.py

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,6 @@
4343
DOCKER_COMPOSE_HTTP_TIMEOUT_ENV = "COMPOSE_HTTP_TIMEOUT"
4444
DOCKER_COMPOSE_HTTP_TIMEOUT = "120"
4545

46-
4746
# Environment variables to be set during training
4847
REGION_ENV_NAME = "AWS_REGION"
4948
TRAINING_JOB_NAME_ENV_NAME = "TRAINING_JOB_NAME"
@@ -256,7 +255,11 @@ def retrieve_artifacts(self, compose_data, output_data_config, job_name):
256255
for host in self.hosts:
257256
volumes = compose_data["services"][str(host)]["volumes"]
258257
for volume in volumes:
259-
host_dir, container_dir = volume.split(":")
258+
if re.search(r"^[A-Za-z]:", volume):
259+
unit, host_dir, container_dir = volume.split(":")
260+
host_dir = unit + ":" + host_dir
261+
else:
262+
host_dir, container_dir = volume.split(":")
260263
if container_dir == "/opt/ml/model":
261264
sagemaker.local.utils.recursive_copy(host_dir, model_artifacts)
262265
elif container_dir == "/opt/ml/output":
@@ -639,9 +642,7 @@ def __init__(self, host_dir, container_dir=None, channel=None):
639642
if container_dir and channel:
640643
raise ValueError("container_dir and channel cannot be declared together.")
641644

642-
self.container_dir = (
643-
container_dir if container_dir else os.path.join("/opt/ml/input/data", channel)
644-
)
645+
self.container_dir = container_dir if container_dir else "/opt/ml/input/data/" + channel
645646
self.host_dir = host_dir
646647
if platform.system() == "Darwin" and host_dir.startswith("/var"):
647648
self.host_dir = os.path.join("/private", host_dir)

0 commit comments

Comments
 (0)