From 30814c63b456169497d57d682fbb26cf425b61e4 Mon Sep 17 00:00:00 2001 From: Rupert Swarbrick Date: Thu, 2 Apr 2026 16:37:26 +0100 Subject: [PATCH] refactor: Explicitly add proj_root to FlowCfg This gets loaded up from the hjson file (and nothing will work if it's missing). This commit tweaks things so that we check the field has been loaded. This will always have type str (because it gets loaded directly from an hjson file). Add an explicit cast to Path when calling the WorkspaceConfig constructor. Signed-off-by: Rupert Swarbrick --- src/dvsim/flow/base.py | 5 +++++ src/dvsim/job/deploy.py | 2 +- 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/src/dvsim/flow/base.py b/src/dvsim/flow/base.py index e90c17d1..e37570d1 100644 --- a/src/dvsim/flow/base.py +++ b/src/dvsim/flow/base.py @@ -78,6 +78,7 @@ def __init__(self, flow_cfg_file, hjson_data, args, mk_config) -> None: self.project = "" self.scratch_path = "" self.scratch_base_path = "" + self.proj_root = "" # Add exports using 'exports' keyword - these are exported to the child # process' environment. @@ -154,6 +155,10 @@ def __init__(self, flow_cfg_file, hjson_data, args, mk_config) -> None: # _expand and add the code at the start. self._expand() + # Check that proj_root has indeed been defined in the hjson config file + if not self.proj_root: + raise RuntimeError("Config file did not define proj_root.") + # After initialisation & expansion, save some useful revision metadata proj_root = Path(self.proj_root) self.commit = git_commit_hash(path=proj_root, short=False) diff --git a/src/dvsim/job/deploy.py b/src/dvsim/job/deploy.py index b31f534a..0678a65f 100644 --- a/src/dvsim/job/deploy.py +++ b/src/dvsim/job/deploy.py @@ -138,7 +138,7 @@ def get_job_spec(self) -> "JobSpec": ), workspace_cfg=WorkspaceConfig( timestamp=self.sim_cfg.args.timestamp, - project_root=self.sim_cfg.proj_root, + project_root=Path(self.sim_cfg.proj_root), scratch_root=Path(self.sim_cfg.scratch_root), scratch_path=Path(self.sim_cfg.scratch_path), ),