@@ -29,6 +29,21 @@ class FlowConfig(BaseModel):
2929
3030 model_config = ConfigDict (frozen = True , extra = "allow" )
3131
32+ flow : str
33+ name : str
34+
35+
36+ class TopFlowConfig (BaseModel ):
37+ """Flow configuration data."""
38+
39+ model_config = ConfigDict (frozen = True , extra = "allow" )
40+
41+ flow : str
42+ project : str
43+ revision : str
44+
45+ cfgs : Mapping [Path , FlowConfig ]
46+
3247
3348class Project (BaseModel ):
3449 """Project meta data."""
@@ -41,6 +56,7 @@ class Project(BaseModel):
4156 scratch_path : Path
4257 branch : str
4358 job_prefix : str
59+ config : TopFlowConfig | FlowConfig
4460
4561 logfile : Path
4662 run_dir : Path
@@ -55,41 +71,6 @@ def save(self) -> None:
5571
5672 (self .run_dir / "project.json" ).write_text (meta_json )
5773
58- def load_config (
59- self ,
60- select_cfgs : Sequence [str ] | None ,
61- args : Namespace ,
62- ) -> Mapping :
63- """Load the project configuration.
64-
65- Args:
66- project_cfg: metadata about the project
67- select_cfgs: list of child config names to use from the primary config
68- args: are the arguments passed to the CLI
69-
70- Returns:
71- Project configuration.
72-
73- """
74- log .info ("Loading primary config file: %s" , self .top_cfg_path )
75-
76- # load the whole project config data
77- cfg = dict (
78- load_cfg (
79- path = self .top_cfg_path ,
80- path_resolution_wildcards = {
81- "proj_root" : self .root_path ,
82- },
83- select_cfgs = select_cfgs ,
84- ),
85- )
86-
87- # Tool specified on CLI overrides the file based config
88- if args .tool is not None :
89- cfg ["tool" ] = args .tool
90-
91- return cfg
92-
9374 @staticmethod
9475 def load (path : Path ) -> "Project" :
9576 """Load project meta from file."""
@@ -102,6 +83,8 @@ def init(
10283 proj_root : Path | None ,
10384 scratch_root : Path | None ,
10485 branch : str ,
86+ select_cfgs : Sequence [str ] | None ,
87+ args : Namespace ,
10588 * ,
10689 job_prefix : str = "" ,
10790 purge : bool = False ,
@@ -118,6 +101,19 @@ def init(
118101 This function returns the updated proj_root src and destination path. If
119102 --remote switch is not set, the destination path is identical to the src
120103 path. Likewise, if --dry-run is set.
104+
105+ Args:
106+ args: are the arguments passed to the CLI
107+ branch: version control branch
108+ cfg_path: path to the top flow config
109+ dry_run: do not run any jobs just go through the motions
110+ job_prefix: prefix for the job name
111+ proj_root: path to the project root
112+ purge: bool = False,
113+ remote: remote execution
114+ scratch_root: path to the scratch dir
115+ select_cfgs: list of child config names to use from the primary config
116+
121117 """
122118 if not cfg_path .exists ():
123119 log .fatal ("Path to config file %s appears to be invalid." , cfg_path )
@@ -156,6 +152,14 @@ def init(
156152 cfg_path = root_path / cfg_path .relative_to (src_path )
157153
158154 run_dir = scratch_path / branch
155+
156+ config = _load_flow_config (
157+ top_cfg_path = cfg_path ,
158+ root_path = root_path ,
159+ select_cfgs = select_cfgs ,
160+ args = args ,
161+ )
162+
159163 return Project (
160164 top_cfg_path = cfg_path ,
161165 root_path = root_path ,
@@ -165,9 +169,51 @@ def init(
165169 job_prefix = job_prefix ,
166170 logfile = run_dir / "run.log" ,
167171 run_dir = run_dir ,
172+ config = config ,
168173 )
169174
170175
176+ def _load_flow_config (
177+ top_cfg_path : Path ,
178+ root_path : Path ,
179+ select_cfgs : Sequence [str ] | None ,
180+ args : Namespace ,
181+ ) -> TopFlowConfig | FlowConfig :
182+ """Load the project configuration.
183+
184+ Args:
185+ top_cfg_path: path to the top level config file
186+ root_path: path to the root of the project,
187+ select_cfgs: list of child config names to use from the primary config
188+ args: are the arguments passed to the CLI
189+
190+ Returns:
191+ Project configuration.
192+
193+ """
194+ log .info ("Loading primary config file: %s" , top_cfg_path )
195+
196+ # load the whole project config data
197+ cfg = dict (
198+ load_cfg (
199+ path = top_cfg_path ,
200+ path_resolution_wildcards = {
201+ "proj_root" : root_path ,
202+ },
203+ select_cfgs = select_cfgs ,
204+ ),
205+ )
206+
207+ # Tool specified on CLI overrides the file based config
208+ if args .tool is not None :
209+ cfg ["tool" ] = args .tool
210+
211+ if "cfgs" in cfg :
212+ return TopFlowConfig .model_validate (cfg )
213+
214+ return FlowConfig .model_validate (cfg )
215+
216+
171217def _network_dir_accessible_and_exists (
172218 path : Path ,
173219 timeout : int = 1 ,
0 commit comments