Problem
In linker.py, line 59, the experiments directory is hard-coded and is joined with the proposal path as follows:
path_expr = path_proposal / "experiments"
This approach is error-prone, especially if users provide the experiments directory as "/experiments", "/", or with extra slashes. As a result, the path can become malformed or absolute when it should remain relative, leading to bugs or user confusion.
Proposal
- Replace the hard-coded string and manual string manipulation with normalized
pathlib.Path logic.
- Ensure that if a user provides values like
"/experiments", "experiments", or "/", the resulting path is always a relative segment joined to path_proposal (not absolute).
- Optionally, provide a helper function using
Path.parts to strip leading slashes or anchors and clarify the intent in code comments.
Example Fix
def make_relative_path(value):
path = Path(value)
return Path(*path.parts[1:]) if path.is_absolute() else path
experiments_dir = make_relative_path(doc.get("experiments_directory", "experiments"))
path_expr = path_proposal / experiments_dir
Similar normalization should be applied to the experiment_alias_directory or any other user path input being joined.
Benefits
- More robust path handling
- Avoids accidental absolute/incorrect paths
- Future-proofs for directory configuration changes
Reference
Related to linker.py line 59 and user report.
Problem
In
linker.py, line 59, theexperimentsdirectory is hard-coded and is joined with the proposal path as follows:This approach is error-prone, especially if users provide the experiments directory as "/experiments", "/", or with extra slashes. As a result, the path can become malformed or absolute when it should remain relative, leading to bugs or user confusion.
Proposal
pathlib.Pathlogic."/experiments","experiments", or"/", the resulting path is always a relative segment joined topath_proposal(not absolute).Path.partsto strip leading slashes or anchors and clarify the intent in code comments.Example Fix
Similar normalization should be applied to the
experiment_alias_directoryor any other user path input being joined.Benefits
Reference
Related to linker.py line 59 and user report.