experimaestro 1.11.1__py3-none-any.whl → 2.0.0rc0__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Potentially problematic release.
This version of experimaestro might be problematic. Click here for more details.
- experimaestro/annotations.py +1 -1
- experimaestro/cli/__init__.py +10 -11
- experimaestro/cli/progress.py +269 -0
- experimaestro/core/identifier.py +11 -2
- experimaestro/core/objects/config.py +64 -94
- experimaestro/core/types.py +35 -57
- experimaestro/launcherfinder/registry.py +3 -3
- experimaestro/mkdocs/base.py +6 -8
- experimaestro/notifications.py +12 -3
- experimaestro/progress.py +406 -0
- experimaestro/settings.py +4 -2
- experimaestro/tests/launchers/common.py +2 -2
- experimaestro/tests/restart.py +1 -1
- experimaestro/tests/test_checkers.py +2 -2
- experimaestro/tests/test_dependencies.py +12 -12
- experimaestro/tests/test_experiment.py +3 -3
- experimaestro/tests/test_file_progress.py +425 -0
- experimaestro/tests/test_file_progress_integration.py +477 -0
- experimaestro/tests/test_generators.py +61 -0
- experimaestro/tests/test_identifier.py +90 -81
- experimaestro/tests/test_instance.py +9 -9
- experimaestro/tests/test_objects.py +9 -32
- experimaestro/tests/test_outputs.py +6 -6
- experimaestro/tests/test_param.py +14 -14
- experimaestro/tests/test_progress.py +4 -4
- experimaestro/tests/test_serializers.py +5 -5
- experimaestro/tests/test_tags.py +15 -15
- experimaestro/tests/test_tasks.py +40 -36
- experimaestro/tests/test_tokens.py +8 -6
- experimaestro/tests/test_types.py +10 -10
- experimaestro/tests/test_validation.py +19 -19
- experimaestro/tests/token_reschedule.py +1 -1
- {experimaestro-1.11.1.dist-info → experimaestro-2.0.0rc0.dist-info}/METADATA +1 -1
- {experimaestro-1.11.1.dist-info → experimaestro-2.0.0rc0.dist-info}/RECORD +37 -32
- {experimaestro-1.11.1.dist-info → experimaestro-2.0.0rc0.dist-info}/LICENSE +0 -0
- {experimaestro-1.11.1.dist-info → experimaestro-2.0.0rc0.dist-info}/WHEEL +0 -0
- {experimaestro-1.11.1.dist-info → experimaestro-2.0.0rc0.dist-info}/entry_points.txt +0 -0
|
@@ -69,35 +69,35 @@ def assert_notequal(a, b, message=""):
|
|
|
69
69
|
|
|
70
70
|
|
|
71
71
|
def test_param_int():
|
|
72
|
-
assert_equal(A(a=1), A(a=1))
|
|
72
|
+
assert_equal(A.C(a=1), A.C(a=1))
|
|
73
73
|
|
|
74
74
|
|
|
75
75
|
def test_param_different_type():
|
|
76
|
-
assert_notequal(A(a=1), B(a=1))
|
|
76
|
+
assert_notequal(A.C(a=1), B.C(a=1))
|
|
77
77
|
|
|
78
78
|
|
|
79
79
|
def test_param_order():
|
|
80
|
-
assert_equal(Values(value1=1, value2=2), Values(value2=2, value1=1))
|
|
80
|
+
assert_equal(Values.C(value1=1, value2=2), Values.C(value2=2, value1=1))
|
|
81
81
|
|
|
82
82
|
|
|
83
83
|
def test_param_default():
|
|
84
|
-
assert_equal(C(a=1, b=2), C(b=2))
|
|
84
|
+
assert_equal(C.C(a=1, b=2), C.C(b=2))
|
|
85
85
|
|
|
86
86
|
|
|
87
87
|
def test_identifier_default_field():
|
|
88
|
-
assert_equal(CField(a=1, b=2), CField(b=2))
|
|
88
|
+
assert_equal(CField.C(a=1, b=2), CField.C(b=2))
|
|
89
89
|
|
|
90
90
|
|
|
91
91
|
def test_param_inner_eq():
|
|
92
|
-
assert_equal(D(a=A(a=1)), D(a=A(a=1)))
|
|
92
|
+
assert_equal(D.C(a=A.C(a=1)), D.C(a=A.C(a=1)))
|
|
93
93
|
|
|
94
94
|
|
|
95
95
|
def test_param_float():
|
|
96
|
-
assert_equal(Float(value=1), Float(value=1))
|
|
96
|
+
assert_equal(Float.C(value=1), Float.C(value=1))
|
|
97
97
|
|
|
98
98
|
|
|
99
99
|
def test_param_float2():
|
|
100
|
-
assert_equal(Float(value=1.0), Float(value=1))
|
|
100
|
+
assert_equal(Float.C(value=1.0), Float.C(value=1))
|
|
101
101
|
|
|
102
102
|
|
|
103
103
|
# --- Argument name
|
|
@@ -118,8 +118,8 @@ def test_param_name():
|
|
|
118
118
|
__xpmid__ = "test.identifier.argumentname"
|
|
119
119
|
a: Param[int]
|
|
120
120
|
|
|
121
|
-
assert_notequal(Config0(a=2), Config1(b=2))
|
|
122
|
-
assert_equal(Config0(a=2), Config3(a=2))
|
|
121
|
+
assert_notequal(Config0.C(a=2), Config1.C(b=2))
|
|
122
|
+
assert_equal(Config0.C(a=2), Config3.C(a=2))
|
|
123
123
|
|
|
124
124
|
|
|
125
125
|
# --- Test option
|
|
@@ -131,9 +131,9 @@ def test_param_option():
|
|
|
131
131
|
a: Param[int]
|
|
132
132
|
b: Option[int] = 1
|
|
133
133
|
|
|
134
|
-
assert_notequal(OptionConfig(a=2), OptionConfig(a=1))
|
|
135
|
-
assert_equal(OptionConfig(a=1, b=2), OptionConfig(a=1))
|
|
136
|
-
assert_equal(OptionConfig(a=1, b=2), OptionConfig(a=1, b=2))
|
|
134
|
+
assert_notequal(OptionConfig.C(a=2), OptionConfig.C(a=1))
|
|
135
|
+
assert_equal(OptionConfig.C(a=1, b=2), OptionConfig.C(a=1))
|
|
136
|
+
assert_equal(OptionConfig.C(a=1, b=2), OptionConfig.C(a=1, b=2))
|
|
137
137
|
|
|
138
138
|
|
|
139
139
|
# --- Dictionnary
|
|
@@ -148,11 +148,14 @@ def test_param_identifier_dict():
|
|
|
148
148
|
class A(Config):
|
|
149
149
|
bs: Param[Dict[str, B]]
|
|
150
150
|
|
|
151
|
-
assert_equal(A(bs={"b1": B(x=1)}), A(bs={"b1": B(x=1)}))
|
|
152
|
-
assert_equal(
|
|
151
|
+
assert_equal(A.C(bs={"b1": B.C(x=1)}), A.C(bs={"b1": B.C(x=1)}))
|
|
152
|
+
assert_equal(
|
|
153
|
+
A.C(bs={"b1": B.C(x=1), "b2": B.C(x=2)}),
|
|
154
|
+
A.C(bs={"b2": B.C(x=2), "b1": B.C(x=1)}),
|
|
155
|
+
)
|
|
153
156
|
|
|
154
|
-
assert_notequal(A(bs={"b1": B(x=1)}), A(bs={"b1": B(x=2)}))
|
|
155
|
-
assert_notequal(A(bs={"b1": B(x=1)}), A(bs={"b2": B(x=1)}))
|
|
157
|
+
assert_notequal(A.C(bs={"b1": B.C(x=1)}), A.C(bs={"b1": B.C(x=2)}))
|
|
158
|
+
assert_notequal(A.C(bs={"b1": B.C(x=1)}), A.C(bs={"b2": B.C(x=1)}))
|
|
156
159
|
|
|
157
160
|
|
|
158
161
|
# --- Ignore paths
|
|
@@ -165,8 +168,8 @@ class TypeWithPath(Config):
|
|
|
165
168
|
|
|
166
169
|
def test_param_identifier_path():
|
|
167
170
|
"""Path should be ignored"""
|
|
168
|
-
assert_equal(TypeWithPath(a=1, path="/a/b"), TypeWithPath(a=1, path="/c/d"))
|
|
169
|
-
assert_notequal(TypeWithPath(a=2, path="/a/b"), TypeWithPath(a=1, path="/c/d"))
|
|
171
|
+
assert_equal(TypeWithPath.C(a=1, path="/a/b"), TypeWithPath.C(a=1, path="/c/d"))
|
|
172
|
+
assert_notequal(TypeWithPath.C(a=2, path="/a/b"), TypeWithPath.C(a=1, path="/c/d"))
|
|
170
173
|
|
|
171
174
|
|
|
172
175
|
# --- Test with added arguments
|
|
@@ -184,7 +187,7 @@ def test_param_identifier_pathoption():
|
|
|
184
187
|
__xpmid__ = "pathoption_test"
|
|
185
188
|
a: Param[int]
|
|
186
189
|
|
|
187
|
-
assert_equal(A_with_path(a=1), A_without_path(a=1))
|
|
190
|
+
assert_equal(A_with_path.C(a=1), A_without_path.C(a=1))
|
|
188
191
|
|
|
189
192
|
|
|
190
193
|
def test_param_identifier_enum():
|
|
@@ -198,8 +201,8 @@ def test_param_identifier_enum():
|
|
|
198
201
|
class EnumConfig(Config):
|
|
199
202
|
a: Param[EnumParam]
|
|
200
203
|
|
|
201
|
-
assert_notequal(EnumConfig(a=EnumParam.FIRST), EnumConfig(a=EnumParam.SECOND))
|
|
202
|
-
assert_equal(EnumConfig(a=EnumParam.FIRST), EnumConfig(a=EnumParam.FIRST))
|
|
204
|
+
assert_notequal(EnumConfig.C(a=EnumParam.FIRST), EnumConfig.C(a=EnumParam.SECOND))
|
|
205
|
+
assert_equal(EnumConfig.C(a=EnumParam.FIRST), EnumConfig.C(a=EnumParam.FIRST))
|
|
203
206
|
|
|
204
207
|
|
|
205
208
|
def test_param_identifier_addnone():
|
|
@@ -215,8 +218,8 @@ def test_param_identifier_addnone():
|
|
|
215
218
|
class A(Config):
|
|
216
219
|
__xpmid__ = "defaultnone"
|
|
217
220
|
|
|
218
|
-
assert_equal(A_with_b(), A())
|
|
219
|
-
assert_notequal(A_with_b(b=B(x=1)), A())
|
|
221
|
+
assert_equal(A_with_b.C(), A.C())
|
|
222
|
+
assert_notequal(A_with_b.C(b=B.C(x=1)), A.C())
|
|
220
223
|
|
|
221
224
|
|
|
222
225
|
def test_param_defaultnew():
|
|
@@ -232,8 +235,8 @@ def test_param_defaultnew():
|
|
|
232
235
|
__xpmid__ = "defaultnew"
|
|
233
236
|
a: Param[int]
|
|
234
237
|
|
|
235
|
-
assert_equal(A_with_b(a=1, b=1), A(a=1))
|
|
236
|
-
assert_equal(A_with_b(a=1), A(a=1))
|
|
238
|
+
assert_equal(A_with_b.C(a=1, b=1), A.C(a=1))
|
|
239
|
+
assert_equal(A_with_b.C(a=1), A.C(a=1))
|
|
237
240
|
|
|
238
241
|
|
|
239
242
|
def test_param_taskconfigidentifier():
|
|
@@ -246,15 +249,15 @@ def test_param_taskconfigidentifier():
|
|
|
246
249
|
x: Param[int]
|
|
247
250
|
|
|
248
251
|
def task_outputs(self, dep):
|
|
249
|
-
return dep(MyConfig(a=1))
|
|
252
|
+
return dep(MyConfig.C(a=1))
|
|
250
253
|
|
|
251
254
|
assert_equal(
|
|
252
|
-
MyTask(x=1).submit(run_mode=RunMode.DRY_RUN),
|
|
253
|
-
MyTask(x=1).submit(run_mode=RunMode.DRY_RUN),
|
|
255
|
+
MyTask.C(x=1).submit(run_mode=RunMode.DRY_RUN),
|
|
256
|
+
MyTask.C(x=1).submit(run_mode=RunMode.DRY_RUN),
|
|
254
257
|
)
|
|
255
258
|
assert_notequal(
|
|
256
|
-
MyTask(x=2).submit(run_mode=RunMode.DRY_RUN),
|
|
257
|
-
MyTask(x=1).submit(run_mode=RunMode.DRY_RUN),
|
|
259
|
+
MyTask.C(x=2).submit(run_mode=RunMode.DRY_RUN),
|
|
260
|
+
MyTask.C(x=1).submit(run_mode=RunMode.DRY_RUN),
|
|
258
261
|
)
|
|
259
262
|
|
|
260
263
|
|
|
@@ -269,13 +272,13 @@ def test_param_constant():
|
|
|
269
272
|
__xpmid__ = "test.constant"
|
|
270
273
|
version: Constant[int] = 1
|
|
271
274
|
|
|
272
|
-
assert_equal(A1(), A1bis())
|
|
275
|
+
assert_equal(A1.C(), A1bis.C())
|
|
273
276
|
|
|
274
277
|
class A2(Config):
|
|
275
278
|
__xpmid__ = "test.constant"
|
|
276
279
|
version: Constant[int] = 2
|
|
277
280
|
|
|
278
|
-
assert_notequal(A1(), A2())
|
|
281
|
+
assert_notequal(A1.C(), A2.C())
|
|
279
282
|
|
|
280
283
|
|
|
281
284
|
def test_param_identifier_deprecated_class():
|
|
@@ -293,10 +296,12 @@ def test_param_identifier_deprecated_class():
|
|
|
293
296
|
__xpmid__ = "derived"
|
|
294
297
|
|
|
295
298
|
assert_notequal(
|
|
296
|
-
NewConfig(), DerivedConfig(), "A derived configuration has another ID"
|
|
299
|
+
NewConfig.C(), DerivedConfig.C(), "A derived configuration has another ID"
|
|
297
300
|
)
|
|
298
301
|
assert_equal(
|
|
299
|
-
NewConfig(),
|
|
302
|
+
NewConfig.C(),
|
|
303
|
+
OldConfig.C(),
|
|
304
|
+
"Deprecated and new configuration have the same ID",
|
|
300
305
|
)
|
|
301
306
|
|
|
302
307
|
|
|
@@ -308,7 +313,7 @@ def test_param_identifier_deprecated_attribute():
|
|
|
308
313
|
def value(self, x):
|
|
309
314
|
self.values = [x]
|
|
310
315
|
|
|
311
|
-
assert_equal(Values(values=[1]), Values(value=1))
|
|
316
|
+
assert_equal(Values.C(values=[1]), Values.C(value=1))
|
|
312
317
|
|
|
313
318
|
|
|
314
319
|
class MetaA(Config):
|
|
@@ -331,26 +336,30 @@ def test_param_identifier_meta():
|
|
|
331
336
|
params: Param[Dict[str, MetaA]]
|
|
332
337
|
|
|
333
338
|
# As meta
|
|
334
|
-
assert_notequal(B(a=MetaA(x=1)), B(a=MetaA(x=2)))
|
|
335
|
-
assert_equal(B(a=setmeta(MetaA(x=1), True)), B(a=setmeta(MetaA(x=2), True)))
|
|
339
|
+
assert_notequal(B.C(a=MetaA.C(x=1)), B.C(a=MetaA.C(x=2)))
|
|
340
|
+
assert_equal(B.C(a=setmeta(MetaA.C(x=1), True)), B.C(a=setmeta(MetaA.C(x=2), True)))
|
|
336
341
|
|
|
337
342
|
# As parameter
|
|
338
|
-
assert_equal(C(a=MetaA(x=1)), C(a=MetaA(x=2)))
|
|
339
|
-
assert_notequal(
|
|
343
|
+
assert_equal(C.C(a=MetaA.C(x=1)), C.C(a=MetaA.C(x=2)))
|
|
344
|
+
assert_notequal(
|
|
345
|
+
C.C(a=setmeta(MetaA.C(x=1), False)), C.C(a=setmeta(MetaA.C(x=2), False))
|
|
346
|
+
)
|
|
340
347
|
|
|
341
348
|
# Array with mixed
|
|
342
349
|
assert_equal(
|
|
343
|
-
ArrayConfig(array=[MetaA(x=1)]),
|
|
344
|
-
ArrayConfig(array=[MetaA(x=1), setmeta(MetaA(x=2), True)]),
|
|
350
|
+
ArrayConfig.C(array=[MetaA.C(x=1)]),
|
|
351
|
+
ArrayConfig.C(array=[MetaA.C(x=1), setmeta(MetaA.C(x=2), True)]),
|
|
345
352
|
)
|
|
346
353
|
|
|
347
354
|
# Array with empty list
|
|
348
|
-
assert_equal(
|
|
355
|
+
assert_equal(
|
|
356
|
+
ArrayConfig.C(array=[]), ArrayConfig.C(array=[setmeta(MetaA.C(x=2), True)])
|
|
357
|
+
)
|
|
349
358
|
|
|
350
359
|
# Dict with mixed
|
|
351
360
|
assert_equal(
|
|
352
|
-
DictConfig(params={"a": MetaA(x=1)}),
|
|
353
|
-
DictConfig(params={"a": MetaA(x=1), "b": setmeta(MetaA(x=2), True)}),
|
|
361
|
+
DictConfig.C(params={"a": MetaA.C(x=1)}),
|
|
362
|
+
DictConfig.C(params={"a": MetaA.C(x=1), "b": setmeta(MetaA.C(x=2), True)}),
|
|
354
363
|
)
|
|
355
364
|
|
|
356
365
|
|
|
@@ -359,14 +368,14 @@ def test_param_identifier_meta_default_dict():
|
|
|
359
368
|
params: Param[Dict[str, MetaA]] = {}
|
|
360
369
|
|
|
361
370
|
assert_equal(
|
|
362
|
-
DictConfig(params={}),
|
|
363
|
-
DictConfig(params={"b": setmeta(MetaA(x=2), True)}),
|
|
371
|
+
DictConfig.C(params={}),
|
|
372
|
+
DictConfig.C(params={"b": setmeta(MetaA.C(x=2), True)}),
|
|
364
373
|
)
|
|
365
374
|
|
|
366
375
|
# Dict with mixed
|
|
367
376
|
assert_equal(
|
|
368
|
-
DictConfig(params={"a": MetaA(x=1)}),
|
|
369
|
-
DictConfig(params={"a": MetaA(x=1), "b": setmeta(MetaA(x=2), True)}),
|
|
377
|
+
DictConfig.C(params={"a": MetaA.C(x=1)}),
|
|
378
|
+
DictConfig.C(params={"a": MetaA.C(x=1), "b": setmeta(MetaA.C(x=2), True)}),
|
|
370
379
|
)
|
|
371
380
|
|
|
372
381
|
|
|
@@ -376,13 +385,13 @@ def test_param_identifier_meta_default_array():
|
|
|
376
385
|
|
|
377
386
|
# Array (with default) with mixed
|
|
378
387
|
assert_equal(
|
|
379
|
-
ArrayConfigWithDefault(array=[MetaA(x=1)]),
|
|
380
|
-
ArrayConfigWithDefault(array=[MetaA(x=1), setmeta(MetaA(x=2), True)]),
|
|
388
|
+
ArrayConfigWithDefault.C(array=[MetaA.C(x=1)]),
|
|
389
|
+
ArrayConfigWithDefault.C(array=[MetaA.C(x=1), setmeta(MetaA.C(x=2), True)]),
|
|
381
390
|
)
|
|
382
391
|
# Array (with default) with empty list
|
|
383
392
|
assert_equal(
|
|
384
|
-
ArrayConfigWithDefault(array=[]),
|
|
385
|
-
ArrayConfigWithDefault(array=[setmeta(MetaA(x=2), True)]),
|
|
393
|
+
ArrayConfigWithDefault.C(array=[]),
|
|
394
|
+
ArrayConfigWithDefault.C(array=[setmeta(MetaA.C(x=2), True)]),
|
|
386
395
|
)
|
|
387
396
|
|
|
388
397
|
|
|
@@ -396,19 +405,19 @@ def test_param_identifier_pre_task():
|
|
|
396
405
|
class IdentifierPreTask(Task):
|
|
397
406
|
x: Param[MyConfig]
|
|
398
407
|
|
|
399
|
-
task = IdentifierPreTask(x=MyConfig()).submit(run_mode=RunMode.DRY_RUN)
|
|
408
|
+
task = IdentifierPreTask.C(x=MyConfig.C()).submit(run_mode=RunMode.DRY_RUN)
|
|
400
409
|
task_with_pre = (
|
|
401
|
-
IdentifierPreTask(x=MyConfig())
|
|
402
|
-
.add_pretasks(IdentifierPreLightTask())
|
|
410
|
+
IdentifierPreTask.C(x=MyConfig.C())
|
|
411
|
+
.add_pretasks(IdentifierPreLightTask.C())
|
|
403
412
|
.submit(run_mode=RunMode.DRY_RUN)
|
|
404
413
|
)
|
|
405
414
|
task_with_pre_2 = (
|
|
406
|
-
IdentifierPreTask(x=MyConfig())
|
|
407
|
-
.add_pretasks(IdentifierPreLightTask())
|
|
415
|
+
IdentifierPreTask.C(x=MyConfig.C())
|
|
416
|
+
.add_pretasks(IdentifierPreLightTask.C())
|
|
408
417
|
.submit(run_mode=RunMode.DRY_RUN)
|
|
409
418
|
)
|
|
410
|
-
task_with_pre_3 = IdentifierPreTask(
|
|
411
|
-
x=MyConfig().add_pretasks(IdentifierPreLightTask())
|
|
419
|
+
task_with_pre_3 = IdentifierPreTask.C(
|
|
420
|
+
x=MyConfig.C().add_pretasks(IdentifierPreLightTask.C())
|
|
412
421
|
).submit(run_mode=RunMode.DRY_RUN)
|
|
413
422
|
|
|
414
423
|
assert_notequal(task, task_with_pre, "No pre-task")
|
|
@@ -429,18 +438,18 @@ def test_param_identifier_init_task():
|
|
|
429
438
|
class IdentierTask(Task):
|
|
430
439
|
x: Param[MyConfig]
|
|
431
440
|
|
|
432
|
-
task = IdentierTask(x=MyConfig()).submit(run_mode=RunMode.DRY_RUN)
|
|
433
|
-
task_with_pre = IdentierTask(x=MyConfig()).submit(
|
|
441
|
+
task = IdentierTask.C(x=MyConfig.C()).submit(run_mode=RunMode.DRY_RUN)
|
|
442
|
+
task_with_pre = IdentierTask.C(x=MyConfig.C()).submit(
|
|
434
443
|
run_mode=RunMode.DRY_RUN,
|
|
435
|
-
init_tasks=[IdentifierInitTask(), IdentifierInitTask2()],
|
|
444
|
+
init_tasks=[IdentifierInitTask.C(), IdentifierInitTask2.C()],
|
|
436
445
|
)
|
|
437
|
-
task_with_pre_2 = IdentierTask(x=MyConfig()).submit(
|
|
446
|
+
task_with_pre_2 = IdentierTask.C(x=MyConfig.C()).submit(
|
|
438
447
|
run_mode=RunMode.DRY_RUN,
|
|
439
|
-
init_tasks=[IdentifierInitTask(), IdentifierInitTask2()],
|
|
448
|
+
init_tasks=[IdentifierInitTask.C(), IdentifierInitTask2.C()],
|
|
440
449
|
)
|
|
441
|
-
task_with_pre_3 = IdentierTask(x=MyConfig()).submit(
|
|
450
|
+
task_with_pre_3 = IdentierTask.C(x=MyConfig.C()).submit(
|
|
442
451
|
run_mode=RunMode.DRY_RUN,
|
|
443
|
-
init_tasks=[IdentifierInitTask2(), IdentifierInitTask()],
|
|
452
|
+
init_tasks=[IdentifierInitTask2.C(), IdentifierInitTask.C()],
|
|
444
453
|
)
|
|
445
454
|
|
|
446
455
|
assert_notequal(task, task_with_pre, "No pre-task")
|
|
@@ -475,14 +484,14 @@ class IdentifierReloadConfig(Config):
|
|
|
475
484
|
|
|
476
485
|
def test_param_identifier_reload_config():
|
|
477
486
|
# Creates the configuration
|
|
478
|
-
check_reload(IdentifierReloadConfig(id="123"))
|
|
487
|
+
check_reload(IdentifierReloadConfig.C(id="123"))
|
|
479
488
|
|
|
480
489
|
|
|
481
490
|
class IdentifierReload(Task):
|
|
482
491
|
id: Param[str]
|
|
483
492
|
|
|
484
|
-
def task_outputs(self, dep):
|
|
485
|
-
return IdentifierReloadConfig(id=self.id)
|
|
493
|
+
def task_outputs(self, dep) -> IdentifierReloadConfig.C:
|
|
494
|
+
return IdentifierReloadConfig.C(id=self.id)
|
|
486
495
|
|
|
487
496
|
|
|
488
497
|
class IdentifierReloadDerived(Config):
|
|
@@ -493,8 +502,8 @@ def test_param_identifier_reload_taskoutput():
|
|
|
493
502
|
"""When using a task output, the identifier should not be different"""
|
|
494
503
|
|
|
495
504
|
# Creates the configuration
|
|
496
|
-
task = IdentifierReload(id="123").submit(run_mode=RunMode.DRY_RUN)
|
|
497
|
-
config = IdentifierReloadDerived(task=task)
|
|
505
|
+
task = IdentifierReload.C(id="123").submit(run_mode=RunMode.DRY_RUN)
|
|
506
|
+
config = IdentifierReloadDerived.C(task=task)
|
|
498
507
|
check_reload(config)
|
|
499
508
|
|
|
500
509
|
|
|
@@ -515,9 +524,9 @@ def test_param_identifier_reload_task_direct():
|
|
|
515
524
|
"""When using a direct task output, the identifier should not be different"""
|
|
516
525
|
|
|
517
526
|
# Creates the configuration
|
|
518
|
-
task = IdentifierReloadTask(id="123").submit(run_mode=RunMode.DRY_RUN)
|
|
519
|
-
config = IdentifierReloadTaskDerived(
|
|
520
|
-
task=task, other=IdentifierReloadTaskConfig(x=2)
|
|
527
|
+
task = IdentifierReloadTask.C(id="123").submit(run_mode=RunMode.DRY_RUN)
|
|
528
|
+
config = IdentifierReloadTaskDerived.C(
|
|
529
|
+
task=task, other=IdentifierReloadTaskConfig.C(x=2)
|
|
521
530
|
)
|
|
522
531
|
check_reload(config)
|
|
523
532
|
|
|
@@ -525,9 +534,9 @@ def test_param_identifier_reload_task_direct():
|
|
|
525
534
|
def test_param_identifier_reload_meta():
|
|
526
535
|
"""Test identifier don't change when using meta"""
|
|
527
536
|
# Creates the configuration
|
|
528
|
-
task = IdentifierReloadTask(id="123").submit(run_mode=RunMode.DRY_RUN)
|
|
529
|
-
config = IdentifierReloadTaskDerived(
|
|
530
|
-
task=task, other=setmeta(IdentifierReloadTaskConfig(x=2), True)
|
|
537
|
+
task = IdentifierReloadTask.C(id="123").submit(run_mode=RunMode.DRY_RUN)
|
|
538
|
+
config = IdentifierReloadTaskDerived.C(
|
|
539
|
+
task=task, other=setmeta(IdentifierReloadTaskConfig.C(x=2), True)
|
|
531
540
|
)
|
|
532
541
|
check_reload(config)
|
|
533
542
|
|
|
@@ -546,9 +555,9 @@ class LoopC(Config):
|
|
|
546
555
|
|
|
547
556
|
|
|
548
557
|
def test_param_identifier_loop():
|
|
549
|
-
c = LoopC()
|
|
550
|
-
b = LoopB(param_c=c)
|
|
551
|
-
a = LoopA(param_b=b)
|
|
558
|
+
c = LoopC.C()
|
|
559
|
+
b = LoopB.C(param_c=c)
|
|
560
|
+
a = LoopA.C(param_b=b)
|
|
552
561
|
c.param_a = a
|
|
553
562
|
c.param_b = b
|
|
554
563
|
|
|
@@ -17,16 +17,16 @@ class B(Config):
|
|
|
17
17
|
|
|
18
18
|
|
|
19
19
|
def test_simple_instance():
|
|
20
|
-
a = A1(x=1)
|
|
21
|
-
b = B(a=a)
|
|
20
|
+
a = A1.C(x=1)
|
|
21
|
+
b = B.C(a=a)
|
|
22
22
|
b = b.instance()
|
|
23
23
|
|
|
24
24
|
assert not isinstance(b, ConfigMixin)
|
|
25
|
-
assert isinstance(b, B.__xpmtype__.
|
|
25
|
+
assert isinstance(b, B.__xpmtype__.value_type)
|
|
26
26
|
|
|
27
27
|
assert not isinstance(b.a, ConfigMixin)
|
|
28
|
-
assert isinstance(b.a, A1.__xpmtype__.
|
|
29
|
-
assert isinstance(b.a, A.__xpmtype__.
|
|
28
|
+
assert isinstance(b.a, A1.__xpmtype__.value_type)
|
|
29
|
+
assert isinstance(b.a, A.__xpmtype__.value_type)
|
|
30
30
|
|
|
31
31
|
|
|
32
32
|
# --- Test pre tasks
|
|
@@ -47,9 +47,9 @@ class LoadModel(SerializationLWTask):
|
|
|
47
47
|
|
|
48
48
|
|
|
49
49
|
def test_instance_serialized():
|
|
50
|
-
model = Model()
|
|
51
|
-
model.add_pretasks(LoadModel(value=model))
|
|
52
|
-
trainer = Evaluator(model=model)
|
|
50
|
+
model = Model.C()
|
|
51
|
+
model.add_pretasks(LoadModel.C(value=model))
|
|
52
|
+
trainer = Evaluator.C(model=model)
|
|
53
53
|
instance = trainer.instance()
|
|
54
54
|
|
|
55
55
|
assert isinstance(
|
|
@@ -65,6 +65,6 @@ class ConfigWithOptional(Config):
|
|
|
65
65
|
|
|
66
66
|
def test_instance_optional():
|
|
67
67
|
"""Test that optional parameters are set to None when calling instance"""
|
|
68
|
-
c = ConfigWithOptional().instance()
|
|
68
|
+
c = ConfigWithOptional.C().instance()
|
|
69
69
|
assert c.x == 1
|
|
70
70
|
assert c.y is None
|
|
@@ -1,11 +1,9 @@
|
|
|
1
|
-
import logging
|
|
2
1
|
from pathlib import Path
|
|
3
2
|
|
|
4
3
|
import pytest
|
|
5
4
|
from experimaestro import Config, Task, Annotated, copyconfig, default
|
|
6
5
|
from experimaestro.core.arguments import Param
|
|
7
6
|
from experimaestro.core.objects import ConfigMixin
|
|
8
|
-
from experimaestro.core.types import XPMValue
|
|
9
7
|
from experimaestro.generators import pathgenerator
|
|
10
8
|
from experimaestro.scheduler.workspace import RunMode
|
|
11
9
|
from experimaestro.tests.utils import TemporaryExperiment
|
|
@@ -28,7 +26,7 @@ def test_object_default():
|
|
|
28
26
|
|
|
29
27
|
|
|
30
28
|
class B(Config):
|
|
31
|
-
a: Param[A] = A(x=3)
|
|
29
|
+
a: Param[A] = A.C(x=3)
|
|
32
30
|
|
|
33
31
|
|
|
34
32
|
class C(B):
|
|
@@ -40,27 +38,26 @@ class D(B, A):
|
|
|
40
38
|
|
|
41
39
|
|
|
42
40
|
class DefaultAnnotationConfig(Config):
|
|
43
|
-
a: Annotated[A, default(A(x=3))]
|
|
41
|
+
a: Annotated[A, default(A.C(x=3))]
|
|
44
42
|
|
|
45
43
|
|
|
46
44
|
def test_object_config_default():
|
|
47
45
|
"""Test default configurations as default values"""
|
|
48
|
-
b = B()
|
|
46
|
+
b = B.C()
|
|
49
47
|
assert b.a.x == 3
|
|
50
48
|
|
|
51
|
-
c = C()
|
|
49
|
+
c = C.C()
|
|
52
50
|
assert c.a.x == 3
|
|
53
51
|
|
|
54
|
-
annotationConfig = DefaultAnnotationConfig()
|
|
52
|
+
annotationConfig = DefaultAnnotationConfig.C()
|
|
55
53
|
assert annotationConfig.a.x == 3
|
|
56
54
|
|
|
57
55
|
|
|
58
56
|
def test_hierarchy():
|
|
59
57
|
"""Test if the object hierarchy is OK"""
|
|
60
|
-
OA = A.__getxpmtype__().
|
|
61
|
-
OB = B.__getxpmtype__().
|
|
62
|
-
OC = C.__getxpmtype__().
|
|
63
|
-
OD = D.__getxpmtype__().objecttype
|
|
58
|
+
OA = A.__getxpmtype__().value_type
|
|
59
|
+
OB = B.__getxpmtype__().value_type
|
|
60
|
+
OC = C.__getxpmtype__().value_type
|
|
64
61
|
|
|
65
62
|
assert issubclass(A, Config)
|
|
66
63
|
assert issubclass(B, Config)
|
|
@@ -72,11 +69,6 @@ def test_hierarchy():
|
|
|
72
69
|
|
|
73
70
|
assert issubclass(C, B)
|
|
74
71
|
|
|
75
|
-
assert OA.__bases__ == (A, XPMValue)
|
|
76
|
-
assert OB.__bases__ == (B, XPMValue)
|
|
77
|
-
assert OC.__bases__ == (C, B.XPMValue)
|
|
78
|
-
assert OD.__bases__ == (D, B.XPMValue, A.XPMValue)
|
|
79
|
-
|
|
80
72
|
|
|
81
73
|
class CopyConfig(Task):
|
|
82
74
|
path: Annotated[Path, pathgenerator("hello.txt")]
|
|
@@ -84,7 +76,7 @@ class CopyConfig(Task):
|
|
|
84
76
|
|
|
85
77
|
|
|
86
78
|
def test_copyconfig(xp):
|
|
87
|
-
b = CopyConfig(x=2)
|
|
79
|
+
b = CopyConfig.C(x=2)
|
|
88
80
|
|
|
89
81
|
b.submit()
|
|
90
82
|
|
|
@@ -92,18 +84,3 @@ def test_copyconfig(xp):
|
|
|
92
84
|
|
|
93
85
|
assert copy_b.x == b.x
|
|
94
86
|
assert "path" not in copy_b.__xpm__.values
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
def test_direct_config_warns(caplog):
|
|
98
|
-
"""Test that using a building Config directly raises a warning"""
|
|
99
|
-
message = "Config.__new__ is deprecated"
|
|
100
|
-
|
|
101
|
-
with caplog.at_level(logging.WARNING):
|
|
102
|
-
A(x=3)
|
|
103
|
-
assert message in caplog.text
|
|
104
|
-
|
|
105
|
-
caplog.clear()
|
|
106
|
-
|
|
107
|
-
with caplog.at_level(logging.WARNING):
|
|
108
|
-
A.C(x=3)
|
|
109
|
-
assert message not in caplog.text
|
|
@@ -32,17 +32,17 @@ class MainB(Task):
|
|
|
32
32
|
|
|
33
33
|
|
|
34
34
|
def test_output_taskoutput():
|
|
35
|
-
a = A(b=B())
|
|
36
|
-
output, ioutput = Main(a=a).submit(run_mode=RunMode.DRY_RUN)
|
|
35
|
+
a = A.C(b=B.C())
|
|
36
|
+
output, ioutput = Main.C(a=a).submit(run_mode=RunMode.DRY_RUN)
|
|
37
37
|
|
|
38
38
|
# Direct
|
|
39
|
-
Main(a=output)
|
|
39
|
+
Main.C(a=output)
|
|
40
40
|
|
|
41
41
|
# Via getattr
|
|
42
|
-
Main(a=A(b=output.b))
|
|
42
|
+
Main.C(a=A.C(b=output.b))
|
|
43
43
|
|
|
44
44
|
# Via getitem
|
|
45
|
-
Main(a=ioutput["a"])
|
|
45
|
+
Main.C(a=ioutput["a"])
|
|
46
46
|
|
|
47
47
|
# Now, submits
|
|
48
|
-
Main(a=output).submit(run_mode=RunMode.DRY_RUN)
|
|
48
|
+
Main.C(a=output).submit(run_mode=RunMode.DRY_RUN)
|
|
@@ -148,7 +148,7 @@ def test_generatedpath():
|
|
|
148
148
|
b: Param[B]
|
|
149
149
|
|
|
150
150
|
basepath = Path("/tmp/testconflict")
|
|
151
|
-
c = C(b=B(a=A())).instance(DirectoryContext(basepath))
|
|
151
|
+
c = C.C(b=B.C(a=A.C())).instance(DirectoryContext(basepath))
|
|
152
152
|
assert c.b.a.path.relative_to(basepath) == Path("out/b/a/test.txt")
|
|
153
153
|
|
|
154
154
|
|
|
@@ -158,13 +158,13 @@ def test_config_class():
|
|
|
158
158
|
class A(Config):
|
|
159
159
|
x: Param[int]
|
|
160
160
|
|
|
161
|
-
a = A(x=1)
|
|
161
|
+
a = A.C(x=1)
|
|
162
162
|
assert a.x == 1
|
|
163
163
|
|
|
164
164
|
class B(A):
|
|
165
165
|
y: Param[int]
|
|
166
166
|
|
|
167
|
-
b = B(x=1, y=2)
|
|
167
|
+
b = B.C(x=1, y=2)
|
|
168
168
|
assert b.x == 1
|
|
169
169
|
assert b.y == 2
|
|
170
170
|
|
|
@@ -174,7 +174,7 @@ def test_config_class():
|
|
|
174
174
|
class C(Config):
|
|
175
175
|
d: Param[D]
|
|
176
176
|
|
|
177
|
-
c = C(d=D(x=1))
|
|
177
|
+
c = C.C(d=D.C(x=1))
|
|
178
178
|
assert c.d.x == 1
|
|
179
179
|
|
|
180
180
|
|
|
@@ -182,7 +182,7 @@ def test_constant():
|
|
|
182
182
|
class A(Config):
|
|
183
183
|
x: Constant[int] = 2
|
|
184
184
|
|
|
185
|
-
a = A()
|
|
185
|
+
a = A.C()
|
|
186
186
|
assert a.x == 2, "Constant value not set"
|
|
187
187
|
|
|
188
188
|
# We should not be able to change the value
|
|
@@ -202,7 +202,7 @@ class EnumConfig(Config):
|
|
|
202
202
|
def test_param_enum():
|
|
203
203
|
"""Test for enum values"""
|
|
204
204
|
|
|
205
|
-
a = EnumConfig(x=EnumParam.OTHER)
|
|
205
|
+
a = EnumConfig.C(x=EnumParam.OTHER)
|
|
206
206
|
_a = serializeCycle(a)
|
|
207
207
|
|
|
208
208
|
assert isinstance(_a, EnumConfig)
|
|
@@ -216,7 +216,7 @@ def test_inheritance():
|
|
|
216
216
|
class B(A):
|
|
217
217
|
y: Param[int] = 3
|
|
218
218
|
|
|
219
|
-
b = B()
|
|
219
|
+
b = B.C()
|
|
220
220
|
b.x = 2
|
|
221
221
|
assert b.__xpm__.values["y"] == 3
|
|
222
222
|
assert b.__xpm__.values["x"] == 2
|
|
@@ -247,7 +247,7 @@ def test_param_dict():
|
|
|
247
247
|
assert isinstance(xarg.keytype, StrType)
|
|
248
248
|
assert isinstance(xarg.valuetype, IntType)
|
|
249
249
|
|
|
250
|
-
A(x={"OK": 1})
|
|
250
|
+
A.C(x={"OK": 1})
|
|
251
251
|
|
|
252
252
|
with pytest.raises(TypeError):
|
|
253
253
|
A(x={"wrong": "string"})
|
|
@@ -263,7 +263,7 @@ class ConfigWithDefault(Config):
|
|
|
263
263
|
|
|
264
264
|
|
|
265
265
|
def test_param_default():
|
|
266
|
-
assert ConfigWithDefault().x == 1
|
|
266
|
+
assert ConfigWithDefault.C().x == 1
|
|
267
267
|
|
|
268
268
|
|
|
269
269
|
class ConfigWithDefaultFactory(Config):
|
|
@@ -271,7 +271,7 @@ class ConfigWithDefaultFactory(Config):
|
|
|
271
271
|
|
|
272
272
|
|
|
273
273
|
def test_param_default_factory():
|
|
274
|
-
value = ConfigWithDefaultFactory()
|
|
274
|
+
value = ConfigWithDefaultFactory.C()
|
|
275
275
|
context = DirectoryContext(Path("/__fakepath__"))
|
|
276
276
|
value.__xpm__.seal(context)
|
|
277
277
|
assert value.x == 1
|
|
@@ -299,15 +299,15 @@ def test_param_default_set():
|
|
|
299
299
|
class A0(Config):
|
|
300
300
|
x: Param[int] = 2
|
|
301
301
|
|
|
302
|
-
assert A0().instance().x == 2
|
|
303
|
-
assert A0(x=3).instance().x == 3
|
|
302
|
+
assert A0.C().instance().x == 2
|
|
303
|
+
assert A0.C(x=3).instance().x == 3
|
|
304
304
|
|
|
305
305
|
class A(Config):
|
|
306
306
|
x: Param[int] = field(default_factory=lambda: 2)
|
|
307
307
|
|
|
308
|
-
assert A().instance().x == 2
|
|
308
|
+
assert A.C().instance().x == 2
|
|
309
309
|
|
|
310
|
-
assert A(x=3).instance().x == 3
|
|
310
|
+
assert A.C(x=3).instance().x == 3
|
|
311
311
|
|
|
312
312
|
|
|
313
313
|
# --- Handling help annotations
|