@@ -18,15 +18,14 @@ def test_parse_build_arg_sets():
1818 with tempfile .TemporaryDirectory () as tmpdir :
1919 copy_data_to_tmpdir (tmpdir )
2020 workspace = Workspace (dir = tmpdir )
21- config = workspace .load_config (path = Path (tmpdir ) / "test.depsets.yaml" )
22- assert config .build_arg_sets ["py311_cpu" ].build_args == {
23- "CUDA_VERSION" : "cpu" ,
24- "PYTHON_VERSION" : "py311" ,
25- }
26- assert config .build_arg_sets ["py311_cuda128" ].build_args == {
27- "CUDA_VERSION" : 128 ,
28- "PYTHON_VERSION" : "py311" ,
29- }
21+ config = workspace .load_config (config_path = Path (tmpdir ) / "test.depsets.yaml" )
22+ assert "general_depset__py311_cpu" in [depset .name for depset in config .depsets ]
23+ assert "build_args_test_depset__py311_cpu" in [
24+ depset .name for depset in config .depsets
25+ ]
26+ assert "expanded_depset__py311_cpu" in [
27+ depset .name for depset in config .depsets
28+ ]
3029
3130
3231def test_substitute_build_args ():
@@ -65,17 +64,78 @@ def test_invalid_build_arg_set():
6564 )
6665 with pytest .raises (KeyError ):
6766 workspace = Workspace (dir = tmpdir )
68- workspace .load_config (path = Path (tmpdir ) / "test.depsets.yaml" )
67+ workspace .load_config (config_path = Path (tmpdir ) / "test.depsets.yaml" )
6968
7069
7170def test_parse_pre_hooks ():
7271 with tempfile .TemporaryDirectory () as tmpdir :
7372 copy_data_to_tmpdir (tmpdir )
7473 workspace = Workspace (dir = tmpdir )
75- config = workspace .load_config (path = Path (tmpdir ) / "test .depsets.yaml" )
74+ config = workspace .load_config (config_path = Path (tmpdir ) / "test2 .depsets.yaml" )
7675 pre_hook_depset = get_depset_by_name (config .depsets , "pre_hook_test_depset" )
7776 assert pre_hook_depset .pre_hooks == ["pre-hook-test.sh" ]
7877
7978
79+ def test_load_first_config ():
80+ with tempfile .TemporaryDirectory () as tmpdir :
81+ copy_data_to_tmpdir (tmpdir )
82+ workspace = Workspace (dir = tmpdir )
83+ config = workspace .load_config (config_path = Path (tmpdir ) / "test.depsets.yaml" )
84+ assert config .depsets is not None
85+ assert len (config .depsets ) == 8
86+
87+
88+ def test_load_second_config ():
89+ with tempfile .TemporaryDirectory () as tmpdir :
90+ copy_data_to_tmpdir (tmpdir )
91+ workspace = Workspace (dir = tmpdir )
92+ config = workspace .load_config (config_path = Path (tmpdir ) / "test2.depsets.yaml" )
93+ assert config .depsets is not None
94+ assert len (config .depsets ) == 3
95+
96+
97+ # load all configs should always load all depsets
98+ def test_load_all_configs_first_config ():
99+ with tempfile .TemporaryDirectory () as tmpdir :
100+ copy_data_to_tmpdir (tmpdir )
101+ workspace = Workspace (dir = tmpdir )
102+ config = workspace .load_configs (config_path = Path (tmpdir ) / "test.depsets.yaml" )
103+ assert config .depsets is not None
104+ assert len (config .depsets ) == 11
105+
106+
107+ # load all configs should always load all depsets
108+ def test_load_all_configs_second_config ():
109+ with tempfile .TemporaryDirectory () as tmpdir :
110+ copy_data_to_tmpdir (tmpdir )
111+ workspace = Workspace (dir = tmpdir )
112+ config = workspace .load_configs (config_path = Path (tmpdir ) / "test2.depsets.yaml" )
113+ assert config .depsets is not None
114+ assert len (config .depsets ) == 11
115+
116+
117+ def test_merge_configs ():
118+ with tempfile .TemporaryDirectory () as tmpdir :
119+ copy_data_to_tmpdir (tmpdir )
120+ workspace = Workspace (dir = tmpdir )
121+ config = workspace .load_config (config_path = Path (tmpdir ) / "test.depsets.yaml" )
122+ config2 = workspace .load_config (config_path = Path (tmpdir ) / "test2.depsets.yaml" )
123+ merged_config = workspace .merge_configs ([config , config2 ])
124+ assert merged_config .depsets is not None
125+ assert len (merged_config .depsets ) == 11
126+
127+
128+ def test_get_configs_dir ():
129+ with tempfile .TemporaryDirectory () as tmpdir :
130+ copy_data_to_tmpdir (tmpdir )
131+ workspace = Workspace (dir = tmpdir )
132+ configs_dir = workspace .get_configs_dir (
133+ configs_path = Path (tmpdir ) / "test.depsets.yaml"
134+ )
135+ assert len (configs_dir ) == 2
136+ assert f"{ tmpdir } /test.depsets.yaml" in configs_dir
137+ assert f"{ tmpdir } /test2.depsets.yaml" in configs_dir
138+
139+
80140if __name__ == "__main__" :
81141 sys .exit (pytest .main (["-v" , __file__ ]))
0 commit comments