@@ -176,7 +176,9 @@ def test_compose_and_dump_overrides(tmp_dir, suffix, overrides, expected):
176
176
output_file = tmp_dir / f"params.{ suffix } "
177
177
config_dir = hydra_setup (tmp_dir , "conf" , "config" )
178
178
config_module = None
179
- compose_and_dump (output_file , config_dir , config_module , config_name , overrides )
179
+ compose_and_dump (
180
+ output_file , config_dir , config_module , config_name , str (tmp_dir ), overrides
181
+ )
180
182
assert output_file .parse () == expected
181
183
182
184
@@ -229,7 +231,9 @@ def test_compose_and_dump_dir_module(
229
231
)
230
232
231
233
with error_context :
232
- compose_and_dump (output_file , config_dir , config_module , config_name , [])
234
+ compose_and_dump (
235
+ output_file , config_dir , config_module , config_name , str (tmp_dir ), []
236
+ )
233
237
assert output_file .parse () == config_content
234
238
235
239
@@ -241,7 +245,7 @@ def test_compose_and_dump_yaml_handles_string(tmp_dir):
241
245
config .parent .mkdir ()
242
246
config .write_text ("foo: 'no'\n " )
243
247
output_file = tmp_dir / "params.yaml"
244
- compose_and_dump (output_file , str (config .parent ), None , "config" , [])
248
+ compose_and_dump (output_file , str (config .parent ), None , "config" , str ( tmp_dir ), [])
245
249
assert output_file .read_text () == "foo: 'no'\n "
246
250
247
251
@@ -253,12 +257,38 @@ def test_compose_and_dump_resolves_interpolation(tmp_dir):
253
257
config .parent .mkdir ()
254
258
config .dump ({"data" : {"root" : "path/to/root" , "raw" : "${.root}/raw" }})
255
259
output_file = tmp_dir / "params.yaml"
256
- compose_and_dump (output_file , str (config .parent ), None , "config" , [])
260
+ compose_and_dump (output_file , str (config .parent ), None , "config" , str ( tmp_dir ), [])
257
261
assert output_file .parse () == {
258
262
"data" : {"root" : "path/to/root" , "raw" : "path/to/root/raw" }
259
263
}
260
264
261
265
266
+ def test_compose_and_dump_plugins (tmp_dir ):
267
+ """Ensure Hydra plugins are loaded."""
268
+ from hydra .core .plugins import Plugins
269
+
270
+ from dvc .utils .hydra import compose_and_dump
271
+
272
+ # clear cached plugins
273
+ Plugins ._instances .pop (Plugins , None )
274
+
275
+ config = tmp_dir / "conf" / "config.yaml"
276
+ config .parent .mkdir ()
277
+ config .write_text ("foo: '${plus_10:1}'\n " )
278
+
279
+ plugins = tmp_dir / "hydra_plugins"
280
+ plugins .mkdir ()
281
+ (plugins / "resolver.py" ).write_text (
282
+ """\
283
+ from omegaconf import OmegaConf
284
+ OmegaConf.register_new_resolver('plus_10', lambda x: x + 10)"""
285
+ )
286
+
287
+ output_file = tmp_dir / "params.yaml"
288
+ compose_and_dump (output_file , str (config .parent ), None , "config" , str (tmp_dir ), [])
289
+ assert output_file .read_text () == "foo: 11\n "
290
+
291
+
262
292
@pytest .mark .parametrize (
263
293
"overrides, expected" ,
264
294
[
0 commit comments