@@ -34,7 +34,34 @@ def write_registry(
3434 url : str ,
3535 prefix : str = "" ,
3636 append : bool = False ,
37+ namefile : str = "mfsim.nam" ,
3738):
39+ """
40+ Make registry files for a directory of models.
41+
42+ The directory may contain model subdirectories
43+ at arbitrary depth. Model input subdirectories
44+ are identified by the presence of a namefile
45+ matching the provided pattern. A prefix may be
46+ specified for model names to avoid collisions.
47+ The registry files are written to the registry
48+ folder alongside this script. Typically, this
49+ function will run once or more in append mode
50+ to iteratively create a registry.
51+
52+ Parameters
53+ ----------
54+ path : str | PathLike
55+ Path to the directory containing the models.
56+ url : str
57+ Base URL for the models.
58+ prefix : str
59+ Prefix to add to model names.
60+ append : bool
61+ Append to the registry files instead of overwriting them.
62+ namefile : str
63+ Namefile pattern to look for in the model directories.
64+ """
3865 path = Path (path ).expanduser ().absolute ()
3966 if not path .is_dir ():
4067 raise NotADirectoryError (f"Path { path } is not a directory." )
@@ -46,7 +73,7 @@ def write_registry(
4673 if is_zip := url .endswith ((".zip" , ".tar" )):
4774 registry [url .rpartition ("/" )[2 ]] = {"hash" : None , "url" : url }
4875
49- model_paths = get_model_paths (path )
76+ model_paths = get_model_paths (path , namefile = namefile )
5077 for model_path in model_paths :
5178 model_path = model_path .expanduser ().absolute ()
5279 rel_path = model_path .relative_to (path )
@@ -112,5 +139,18 @@ def drop_none_or_empty(path, key, value):
112139 help = "Base URL for models." ,
113140 default = BASE_URL ,
114141 )
142+ parser .add_argument (
143+ "--namefile" ,
144+ "-n" ,
145+ type = str ,
146+ help = "Namefile pattern to look for in the model directories." ,
147+ default = "mfsim.nam" ,
148+ )
115149 args = parser .parse_args ()
116- write_registry (path = args .path , url = args .url , prefix = args .prefix , append = args .append )
150+ write_registry (
151+ path = args .path ,
152+ url = args .url ,
153+ prefix = args .prefix ,
154+ append = args .append ,
155+ namefile = args .namefile ,
156+ )
0 commit comments