Skip to content

Commit 3add664

Browse files
committed
get_workspace_path_from_config no longer calls fully_resolve_path
1 parent ab73156 commit 3add664

File tree

1 file changed

+9
-4
lines changed

1 file changed

+9
-4
lines changed

util/workspace.py

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -167,8 +167,6 @@ class DBGymWorkspace:
167167
num_times_created_this_run: int = 0
168168

169169
def __init__(self, dbgym_workspace_path: Path):
170-
assert is_fully_resolved(dbgym_workspace_path)
171-
172170
# The logic around dbgym_tmp_path assumes that DBGymWorkspace is only constructed once.
173171
DBGymWorkspace.num_times_created_this_run += 1
174172
assert (
@@ -181,6 +179,10 @@ def __init__(self, dbgym_workspace_path: Path):
181179
# Set and create paths.
182180
self.dbgym_workspace_path = dbgym_workspace_path
183181
self.dbgym_workspace_path.mkdir(parents=True, exist_ok=True)
182+
183+
# Now that the workspace is guaranteed to be created, we can check if it's fully resolved.
184+
assert is_fully_resolved(self.dbgym_workspace_path)
185+
184186
self.dbgym_runs_path = get_runs_path_from_workspace_path(
185187
self.dbgym_workspace_path
186188
)
@@ -281,7 +283,8 @@ def get_workspace_path_from_config(dbgym_config_path: Path) -> Path:
281283
Returns the workspace path (as a fully resolved path) from the config file.
282284
"""
283285
with open(dbgym_config_path) as f:
284-
return fully_resolve_path(Path(yaml.safe_load(f)["dbgym_workspace_path"]))
286+
# We do *not* call fully_resolve_path() here because the workspace may not exist yet.
287+
return Path(yaml.safe_load(f)["dbgym_workspace_path"]).resolve().absolute()
285288

286289

287290
def make_standard_dbgym_workspace() -> DBGymWorkspace:
@@ -355,6 +358,9 @@ def is_fully_resolved(path: Path) -> bool:
355358
"""
356359
Checks if a path is fully resolved (exists, is absolute, and contains no symlinks in its entire ancestry).
357360
361+
The reason we check for existence is because that's the only way we know that there are no symlinks in its entire ancestry.
362+
If we didn't check for existence, we could later create a new symlink in the path's ancestry.
363+
358364
Even if a path exists, is absolute, and is not itself a symlink, it could still contain
359365
symlinks in its parent directories. For example:
360366
/home/user/ # Real directory
@@ -597,7 +603,6 @@ def link_result(
597603
assert is_fully_resolved(
598604
result_fordpath
599605
), f"result_fordpath ({result_fordpath}) should be a fully resolved path"
600-
result_fordpath = fully_resolve_path(result_fordpath)
601606
assert is_child_path(result_fordpath, dbgym_workspace.dbgym_this_run_path)
602607
assert not os.path.islink(result_fordpath)
603608

0 commit comments

Comments
 (0)