Skip to content
This repository was archived by the owner on Apr 14, 2026. It is now read-only.

Commit 2e94981

Browse files
committed
Ensure file mounts exist
1 parent 34e6180 commit 2e94981

1 file changed

Lines changed: 18 additions & 2 deletions

File tree

src/styxdocker/__init__.py

Lines changed: 18 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -91,12 +91,28 @@ def input_file(
9191
_host_file = pl.Path(host_file)
9292

9393
if resolve_parent:
94+
_host_file_parent = _host_file.parent
95+
if not _host_file_parent.is_dir():
96+
# If Docker gets passed a file to mount which does not exist it will
97+
# create a directory at this location.
98+
# This odd behaviour can lead to cryptic error messages downstream so we
99+
# make sure to catch this early.
100+
raise FileNotFoundError(
101+
f'Input folder not found: "{_host_file_parent}"'
102+
)
103+
94104
local_file = (
95-
f"/styx_input/{self.input_file_next_id}/{_host_file.parent.name}"
105+
f"/styx_input/{self.input_file_next_id}/{_host_file_parent.name}"
96106
)
97107
resolved_file = f"{local_file}/{_host_file.name}"
98-
self.input_mounts.append((_host_file.parent, local_file, mutable))
108+
self.input_mounts.append((_host_file_parent, local_file, mutable))
99109
else:
110+
if not _host_file.exists():
111+
# See note above.
112+
# We don't know if the 'file' here is a directory or file
113+
# so we can't additionally assert that it is.
114+
raise FileNotFoundError(f'Input file not found: "{_host_file}"')
115+
100116
resolved_file = local_file = (
101117
f"/styx_input/{self.input_file_next_id}/{_host_file.name}"
102118
)

0 commit comments

Comments
 (0)