@@ -34,6 +34,17 @@ function ConfigManager(config_file::String, rootdir::String, manager::DM = HDF5M
3434 return cm
3535end
3636
37+ function Base. copy (cm:: ConfigManager{DM} ) where {DM<: DataManager }
38+ ConfigManager {DM} (
39+ deepcopy (cm. config_dict),
40+ copy (cm. parsed_config),
41+ cm. total_combinations,
42+ Dict (" save_path" => getPermutation (cm. parsed_config, 1 )[" save_path" ]),
43+ cm. rootdir,
44+ typeof (cm. dataManager)()
45+ )
46+ end
47+
3748
3849haskey (self:: ConfigManager , k:: String ) = k ∈ keys (self. spec)
3950getindex (self:: ConfigManager , param:: String ) = self. spec[param]
@@ -45,6 +56,42 @@ _checklists(self::ConfigManager) = joinpath(_data_root(self), "checklists")
4556
4657total_combinations (self:: ConfigManager ) = self. total_combinations
4758
59+ struct _CM_Iterator{CM<: ConfigManager }
60+ manager:: CM
61+ num_runs:: Int
62+ end
63+
64+ Base. length (iter:: _CM_Iterator ) = total_combinations (iter. manager)* iter. num_runs
65+
66+ iterator (cm:: ConfigManager , num_runs) = _CM_Iterator (cm, num_runs)
67+
68+ function Base. iterate (iter:: _CM_Iterator , state= (1 ,1 ))
69+
70+ if state[1 ] > total_combinations (iter. manager)
71+ return nothing
72+ end
73+
74+ new_state = begin
75+ if state[2 ] == iter. num_runs
76+ (state[1 ] + 1 , 1 )
77+ else
78+ (state[1 ], state[2 ]+ 1 )
79+ end
80+ end
81+ cm = copy (iter. manager)
82+
83+ parse! (cm, state[1 ], state[2 ])
84+ return cm, new_state
85+
86+ end
87+
88+
89+
90+ """
91+ parse!
92+
93+ get spec while modifying config manager. repercusions.
94+ """
4895function parse! (self:: ConfigManager , idx:: Int , run:: Int = 1 )
4996 self. spec = getPermutation (self. parsed_config, idx)
5097
@@ -77,6 +124,7 @@ function params_with(self::ConfigManager, cfg_dict::Dict)
77124 return indices
78125end
79126
127+
80128function get_expdir (self:: ConfigManager )
81129 return joinpath (_output_root (self), self[" save_path" ])
82130end
@@ -147,3 +195,5 @@ function get_subconfig(self::ConfigManager, keys...)
147195 end
148196 return sub
149197end
198+
199+
0 commit comments