@@ -167,8 +167,6 @@ class DBGymWorkspace:
167
167
num_times_created_this_run : int = 0
168
168
169
169
def __init__ (self , dbgym_workspace_path : Path ):
170
- assert is_fully_resolved (dbgym_workspace_path )
171
-
172
170
# The logic around dbgym_tmp_path assumes that DBGymWorkspace is only constructed once.
173
171
DBGymWorkspace .num_times_created_this_run += 1
174
172
assert (
@@ -181,6 +179,10 @@ def __init__(self, dbgym_workspace_path: Path):
181
179
# Set and create paths.
182
180
self .dbgym_workspace_path = dbgym_workspace_path
183
181
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
+
184
186
self .dbgym_runs_path = get_runs_path_from_workspace_path (
185
187
self .dbgym_workspace_path
186
188
)
@@ -281,7 +283,8 @@ def get_workspace_path_from_config(dbgym_config_path: Path) -> Path:
281
283
Returns the workspace path (as a fully resolved path) from the config file.
282
284
"""
283
285
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 ()
285
288
286
289
287
290
def make_standard_dbgym_workspace () -> DBGymWorkspace :
@@ -355,6 +358,9 @@ def is_fully_resolved(path: Path) -> bool:
355
358
"""
356
359
Checks if a path is fully resolved (exists, is absolute, and contains no symlinks in its entire ancestry).
357
360
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
+
358
364
Even if a path exists, is absolute, and is not itself a symlink, it could still contain
359
365
symlinks in its parent directories. For example:
360
366
/home/user/ # Real directory
@@ -597,7 +603,6 @@ def link_result(
597
603
assert is_fully_resolved (
598
604
result_fordpath
599
605
), f"result_fordpath ({ result_fordpath } ) should be a fully resolved path"
600
- result_fordpath = fully_resolve_path (result_fordpath )
601
606
assert is_child_path (result_fordpath , dbgym_workspace .dbgym_this_run_path )
602
607
assert not os .path .islink (result_fordpath )
603
608
0 commit comments