experimaestro 1.11.1__py3-none-any.whl → 2.0.0a8__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.

Files changed (52) hide show
  1. experimaestro/annotations.py +1 -1
  2. experimaestro/cli/__init__.py +10 -11
  3. experimaestro/cli/progress.py +269 -0
  4. experimaestro/connectors/__init__.py +2 -2
  5. experimaestro/core/arguments.py +20 -1
  6. experimaestro/core/identifier.py +21 -7
  7. experimaestro/core/objects/config.py +174 -274
  8. experimaestro/core/objects/config_walk.py +4 -6
  9. experimaestro/core/objects.pyi +2 -6
  10. experimaestro/core/serializers.py +1 -8
  11. experimaestro/core/types.py +35 -57
  12. experimaestro/launcherfinder/registry.py +3 -3
  13. experimaestro/mkdocs/base.py +6 -8
  14. experimaestro/notifications.py +12 -3
  15. experimaestro/progress.py +406 -0
  16. experimaestro/scheduler/__init__.py +18 -1
  17. experimaestro/scheduler/base.py +87 -906
  18. experimaestro/scheduler/experiment.py +387 -0
  19. experimaestro/scheduler/jobs.py +475 -0
  20. experimaestro/scheduler/signal_handler.py +32 -0
  21. experimaestro/scheduler/state.py +1 -1
  22. experimaestro/server/__init__.py +36 -5
  23. experimaestro/settings.py +4 -2
  24. experimaestro/tests/launchers/common.py +2 -2
  25. experimaestro/tests/restart.py +1 -1
  26. experimaestro/tests/tasks/all.py +7 -0
  27. experimaestro/tests/test_checkers.py +2 -2
  28. experimaestro/tests/test_dependencies.py +11 -17
  29. experimaestro/tests/test_experiment.py +3 -3
  30. experimaestro/tests/test_file_progress.py +425 -0
  31. experimaestro/tests/test_file_progress_integration.py +477 -0
  32. experimaestro/tests/test_generators.py +93 -0
  33. experimaestro/tests/test_identifier.py +155 -135
  34. experimaestro/tests/test_instance.py +13 -18
  35. experimaestro/tests/test_objects.py +9 -32
  36. experimaestro/tests/test_outputs.py +6 -6
  37. experimaestro/tests/test_param.py +14 -14
  38. experimaestro/tests/test_progress.py +4 -4
  39. experimaestro/tests/test_serializers.py +0 -59
  40. experimaestro/tests/test_tags.py +15 -15
  41. experimaestro/tests/test_tasks.py +42 -51
  42. experimaestro/tests/test_tokens.py +8 -6
  43. experimaestro/tests/test_types.py +10 -10
  44. experimaestro/tests/test_validation.py +19 -19
  45. experimaestro/tests/token_reschedule.py +1 -1
  46. experimaestro/tools/diff.py +8 -1
  47. experimaestro/typingutils.py +11 -2
  48. {experimaestro-1.11.1.dist-info → experimaestro-2.0.0a8.dist-info}/METADATA +3 -2
  49. {experimaestro-1.11.1.dist-info → experimaestro-2.0.0a8.dist-info}/RECORD +52 -44
  50. {experimaestro-1.11.1.dist-info → experimaestro-2.0.0a8.dist-info}/WHEEL +1 -1
  51. {experimaestro-1.11.1.dist-info → experimaestro-2.0.0a8.dist-info}/entry_points.txt +0 -0
  52. {experimaestro-1.11.1.dist-info → experimaestro-2.0.0a8.dist-info/licenses}/LICENSE +0 -0
@@ -68,42 +68,42 @@ def assert_notequal(a, b, message=""):
68
68
  assert getidentifier(a) != getidentifier(b), message
69
69
 
70
70
 
71
- def test_param_int():
72
- assert_equal(A(a=1), A(a=1))
71
+ def test_identifier_int():
72
+ assert_equal(A.C(a=1), A.C(a=1))
73
73
 
74
74
 
75
- def test_param_different_type():
76
- assert_notequal(A(a=1), B(a=1))
75
+ def test_identifier_different_type():
76
+ assert_notequal(A.C(a=1), B.C(a=1))
77
77
 
78
78
 
79
- def test_param_order():
80
- assert_equal(Values(value1=1, value2=2), Values(value2=2, value1=1))
79
+ def test_identifier_order():
80
+ assert_equal(Values.C(value1=1, value2=2), Values.C(value2=2, value1=1))
81
81
 
82
82
 
83
- def test_param_default():
84
- assert_equal(C(a=1, b=2), C(b=2))
83
+ def test_identifier_default():
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
- def test_param_inner_eq():
92
- assert_equal(D(a=A(a=1)), D(a=A(a=1)))
91
+ def test_identifier_inner_eq():
92
+ assert_equal(D.C(a=A.C(a=1)), D.C(a=A.C(a=1)))
93
93
 
94
94
 
95
- def test_param_float():
96
- assert_equal(Float(value=1), Float(value=1))
95
+ def test_identifier_float():
96
+ assert_equal(Float.C(value=1), Float.C(value=1))
97
97
 
98
98
 
99
- def test_param_float2():
100
- assert_equal(Float(value=1.0), Float(value=1))
99
+ def test_identifier_float2():
100
+ assert_equal(Float.C(value=1.0), Float.C(value=1))
101
101
 
102
102
 
103
103
  # --- Argument name
104
104
 
105
105
 
106
- def test_param_name():
106
+ def test_identifier_name():
107
107
  """The identifier fully determines the hash code"""
108
108
 
109
109
  class Config0(Config):
@@ -118,28 +118,28 @@ 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
126
126
 
127
127
 
128
- def test_param_option():
128
+ def test_identifier_option():
129
129
  class OptionConfig(Config):
130
130
  __xpmid__ = "test.identifier.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
140
140
 
141
141
 
142
- def test_param_identifier_dict():
142
+ def test_identifier_dict():
143
143
  """Test identifiers of dictionary structures"""
144
144
 
145
145
  class B(Config):
@@ -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(A(bs={"b1": B(x=1), "b2": B(x=2)}), A(bs={"b2": B(x=2), "b1": B(x=1)}))
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
@@ -163,16 +166,16 @@ class TypeWithPath(Config):
163
166
  path: Param[Path]
164
167
 
165
168
 
166
- def test_param_identifier_path():
169
+ def test_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
173
176
 
174
177
 
175
- def test_param_identifier_pathoption():
178
+ def test_identifier_pathoption():
176
179
  """Path arguments should be ignored"""
177
180
 
178
181
  class A_with_path(Config):
@@ -184,10 +187,10 @@ 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
- def test_param_identifier_enum():
193
+ def test_identifier_enum():
191
194
  """test enum parameters"""
192
195
  from enum import Enum
193
196
 
@@ -198,11 +201,11 @@ 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
- def test_param_identifier_addnone():
208
+ def test_identifier_addnone():
206
209
  """Test the case of new parameter (with None default)"""
207
210
 
208
211
  class B(Config):
@@ -215,11 +218,11 @@ 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
- def test_param_defaultnew():
225
+ def test_identifier_defaultnew():
223
226
  """Path arguments should be ignored"""
224
227
 
225
228
  class A_with_b(Config):
@@ -232,11 +235,11 @@ 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
- def test_param_taskconfigidentifier():
242
+ def test_identifier_taskconfigidentifier():
240
243
  """Test whether the embedded task arguments make the configuration different"""
241
244
 
242
245
  class MyConfig(Config):
@@ -246,19 +249,19 @@ 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
 
261
- def test_param_constant():
264
+ def test_identifier_constant():
262
265
  """Test if constants are taken into account for signature computation"""
263
266
 
264
267
  class A1(Config):
@@ -269,16 +272,16 @@ 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
- def test_param_identifier_deprecated_class():
284
+ def test_identifier_deprecated_class():
282
285
  """Test that when submitting the task, the computed identifier is the one of
283
286
  the new class"""
284
287
 
@@ -293,14 +296,16 @@ 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(), OldConfig(), "Deprecated and new configuration have the same ID"
302
+ NewConfig.C(),
303
+ OldConfig.C(),
304
+ "Deprecated and new configuration have the same ID",
300
305
  )
301
306
 
302
307
 
303
- def test_param_identifier_deprecated_attribute():
308
+ def test_identifier_deprecated_attribute():
304
309
  class Values(Config):
305
310
  values: Param[List[int]] = []
306
311
 
@@ -308,14 +313,14 @@ 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):
315
320
  x: Param[int]
316
321
 
317
322
 
318
- def test_param_identifier_meta():
323
+ def test_identifier_meta():
319
324
  """Test forced meta-parameter"""
320
325
 
321
326
  class B(Config):
@@ -331,121 +336,136 @@ 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(C(a=setmeta(MetaA(x=1), False)), C(a=setmeta(MetaA(x=2), False)))
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(ArrayConfig(array=[]), ArrayConfig(array=[setmeta(MetaA(x=2), True)]))
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
 
357
- def test_param_identifier_meta_default_dict():
366
+ def test_identifier_meta_default_dict():
358
367
  class DictConfig(Config):
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
 
373
- def test_param_identifier_meta_default_array():
382
+ def test_identifier_meta_default_array():
374
383
  class ArrayConfigWithDefault(Config):
375
384
  array: Param[List[MetaA]] = []
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
 
389
- def test_param_identifier_pre_task():
398
+ def test_identifier_init_task():
390
399
  class MyConfig(Config):
391
400
  pass
392
401
 
393
- class IdentifierPreLightTask(LightweightTask):
402
+ class IdentifierInitTask(LightweightTask):
403
+ pass
404
+
405
+ class IdentifierInitTask2(Task):
394
406
  pass
395
407
 
396
- class IdentifierPreTask(Task):
408
+ class IdentifierTask(Task):
397
409
  x: Param[MyConfig]
398
410
 
399
- task = IdentifierPreTask(x=MyConfig()).submit(run_mode=RunMode.DRY_RUN)
400
- task_with_pre = (
401
- IdentifierPreTask(x=MyConfig())
402
- .add_pretasks(IdentifierPreLightTask())
403
- .submit(run_mode=RunMode.DRY_RUN)
411
+ task = IdentifierTask.C(x=MyConfig.C()).submit(run_mode=RunMode.DRY_RUN)
412
+ task_with_pre = IdentifierTask.C(x=MyConfig.C()).submit(
413
+ run_mode=RunMode.DRY_RUN,
414
+ init_tasks=[IdentifierInitTask.C(), IdentifierInitTask2.C()],
415
+ )
416
+ task_with_pre_2 = IdentifierTask.C(x=MyConfig.C()).submit(
417
+ run_mode=RunMode.DRY_RUN,
418
+ init_tasks=[IdentifierInitTask.C(), IdentifierInitTask2.C()],
404
419
  )
405
- task_with_pre_2 = (
406
- IdentifierPreTask(x=MyConfig())
407
- .add_pretasks(IdentifierPreLightTask())
408
- .submit(run_mode=RunMode.DRY_RUN)
420
+ task_with_pre_3 = IdentifierTask.C(x=MyConfig.C()).submit(
421
+ run_mode=RunMode.DRY_RUN,
422
+ init_tasks=[IdentifierInitTask2.C(), IdentifierInitTask.C()],
409
423
  )
410
- task_with_pre_3 = IdentifierPreTask(
411
- x=MyConfig().add_pretasks(IdentifierPreLightTask())
412
- ).submit(run_mode=RunMode.DRY_RUN)
413
424
 
414
- assert_notequal(task, task_with_pre, "No pre-task")
425
+ assert_notequal(task, task_with_pre, "Should be different with init-task")
415
426
  assert_equal(task_with_pre, task_with_pre_2, "Same parameters")
416
- assert_equal(task_with_pre, task_with_pre_3, "Pre-tasks are order-less")
427
+ assert_notequal(task_with_pre, task_with_pre_3, "Other parameters")
417
428
 
418
429
 
419
- def test_param_identifier_init_task():
420
- class MyConfig(Config):
421
- pass
430
+ def test_identifier_init_task_dep():
431
+ class Loader(LightweightTask):
432
+ param1: Param[float]
422
433
 
423
- class IdentifierInitTask(LightweightTask):
424
- pass
434
+ def execute(self):
435
+ pass
425
436
 
426
- class IdentifierInitTask2(Task):
427
- pass
437
+ class FirstTask(Task):
438
+ def task_outputs(self, dep):
439
+ return dep(Loader.C(param1=1))
428
440
 
429
- class IdentierTask(Task):
430
- x: Param[MyConfig]
441
+ def execute(self):
442
+ pass
431
443
 
432
- task = IdentierTask(x=MyConfig()).submit(run_mode=RunMode.DRY_RUN)
433
- task_with_pre = IdentierTask(x=MyConfig()).submit(
434
- run_mode=RunMode.DRY_RUN,
435
- init_tasks=[IdentifierInitTask(), IdentifierInitTask2()],
436
- )
437
- task_with_pre_2 = IdentierTask(x=MyConfig()).submit(
438
- run_mode=RunMode.DRY_RUN,
439
- init_tasks=[IdentifierInitTask(), IdentifierInitTask2()],
444
+ class SecondTask(Task):
445
+ param3: Param[int]
446
+
447
+ def execute(self):
448
+ pass
449
+
450
+ # Two identical tasks
451
+ task_a_1 = FirstTask.C()
452
+ task_a_2 = FirstTask.C()
453
+ assert_equal(task_a_1, task_a_2)
454
+
455
+ # We process them with two different init tasks
456
+ loader_1 = task_a_1.submit(
457
+ init_tasks=[Loader.C(param1=0.5)], run_mode=RunMode.DRY_RUN
440
458
  )
441
- task_with_pre_3 = IdentierTask(x=MyConfig()).submit(
442
- run_mode=RunMode.DRY_RUN,
443
- init_tasks=[IdentifierInitTask2(), IdentifierInitTask()],
459
+ loader_2 = task_a_2.submit(
460
+ init_tasks=[Loader.C(param1=5)], run_mode=RunMode.DRY_RUN
444
461
  )
462
+ assert_notequal(loader_1, loader_2)
445
463
 
446
- assert_notequal(task, task_with_pre, "No pre-task")
447
- assert_equal(task_with_pre, task_with_pre_2, "Same parameters")
448
- assert_notequal(task_with_pre, task_with_pre_3, "Same parameters")
464
+ # Now, we process
465
+ c_1 = SecondTask.C(param3=2).submit(init_tasks=[loader_1], run_mode=RunMode.DRY_RUN)
466
+
467
+ c_2 = SecondTask.C(param3=2).submit(init_tasks=[loader_2], run_mode=RunMode.DRY_RUN)
468
+ assert_notequal(c_1, c_2)
449
469
 
450
470
 
451
471
  # --- Check configuration reloads
@@ -463,7 +483,7 @@ def check_reload(config):
463
483
  new_config = ConfigInformation.fromParameters(
464
484
  data, as_instance=False, discard_id=True
465
485
  )
466
- assert new_config.__xpm__._full_identifier is None
486
+ assert new_config.__xpm__._identifier is None
467
487
  new_identifier = new_config.__xpm__.identifier.all
468
488
 
469
489
  assert new_identifier == old_identifier
@@ -473,28 +493,28 @@ class IdentifierReloadConfig(Config):
473
493
  id: Param[str]
474
494
 
475
495
 
476
- def test_param_identifier_reload_config():
496
+ def test_identifier_reload_config():
477
497
  # Creates the configuration
478
- check_reload(IdentifierReloadConfig(id="123"))
498
+ check_reload(IdentifierReloadConfig.C(id="123"))
479
499
 
480
500
 
481
501
  class IdentifierReload(Task):
482
502
  id: Param[str]
483
503
 
484
- def task_outputs(self, dep):
485
- return IdentifierReloadConfig(id=self.id)
504
+ def task_outputs(self, dep) -> IdentifierReloadConfig.C:
505
+ return IdentifierReloadConfig.C(id=self.id)
486
506
 
487
507
 
488
508
  class IdentifierReloadDerived(Config):
489
509
  task: Param[IdentifierReloadConfig]
490
510
 
491
511
 
492
- def test_param_identifier_reload_taskoutput():
512
+ def test_identifier_reload_taskoutput():
493
513
  """When using a task output, the identifier should not be different"""
494
514
 
495
515
  # Creates the configuration
496
- task = IdentifierReload(id="123").submit(run_mode=RunMode.DRY_RUN)
497
- config = IdentifierReloadDerived(task=task)
516
+ task = IdentifierReload.C(id="123").submit(run_mode=RunMode.DRY_RUN)
517
+ config = IdentifierReloadDerived.C(task=task)
498
518
  check_reload(config)
499
519
 
500
520
 
@@ -511,23 +531,23 @@ class IdentifierReloadTaskDerived(Config):
511
531
  other: Param[IdentifierReloadTaskConfig]
512
532
 
513
533
 
514
- def test_param_identifier_reload_task_direct():
534
+ def test_identifier_reload_task_direct():
515
535
  """When using a direct task output, the identifier should not be different"""
516
536
 
517
537
  # Creates the configuration
518
- task = IdentifierReloadTask(id="123").submit(run_mode=RunMode.DRY_RUN)
519
- config = IdentifierReloadTaskDerived(
520
- task=task, other=IdentifierReloadTaskConfig(x=2)
538
+ task = IdentifierReloadTask.C(id="123").submit(run_mode=RunMode.DRY_RUN)
539
+ config = IdentifierReloadTaskDerived.C(
540
+ task=task, other=IdentifierReloadTaskConfig.C(x=2)
521
541
  )
522
542
  check_reload(config)
523
543
 
524
544
 
525
- def test_param_identifier_reload_meta():
545
+ def test_identifier_reload_meta():
526
546
  """Test identifier don't change when using meta"""
527
547
  # 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)
548
+ task = IdentifierReloadTask.C(id="123").submit(run_mode=RunMode.DRY_RUN)
549
+ config = IdentifierReloadTaskDerived.C(
550
+ task=task, other=setmeta(IdentifierReloadTaskConfig.C(x=2), True)
531
551
  )
532
552
  check_reload(config)
533
553
 
@@ -545,10 +565,10 @@ class LoopC(Config):
545
565
  param_b: Param["LoopB"]
546
566
 
547
567
 
548
- def test_param_identifier_loop():
549
- c = LoopC()
550
- b = LoopB(param_c=c)
551
- a = LoopA(param_b=b)
568
+ def test_identifier_loop():
569
+ c = LoopC.C()
570
+ b = LoopB.C(param_c=c)
571
+ a = LoopA.C(param_b=b)
552
572
  c.param_a = a
553
573
  c.param_b = b
554
574
 
@@ -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__.objecttype)
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__.objecttype)
29
- assert isinstance(b.a, A.__xpmtype__.basetype)
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
@@ -46,18 +46,6 @@ class LoadModel(SerializationLWTask):
46
46
  self.value.initialized = True
47
47
 
48
48
 
49
- def test_instance_serialized():
50
- model = Model()
51
- model.add_pretasks(LoadModel(value=model))
52
- trainer = Evaluator(model=model)
53
- instance = trainer.instance()
54
-
55
- assert isinstance(
56
- instance.model, Model
57
- ), f"The model is not a Model but a {type(instance.model).__qualname__}"
58
- assert instance.model.initialized, "The model was not initialized"
59
-
60
-
61
49
  class ConfigWithOptional(Config):
62
50
  x: Param[int] = 1
63
51
  y: Param[Optional[int]]
@@ -65,6 +53,13 @@ class ConfigWithOptional(Config):
65
53
 
66
54
  def test_instance_optional():
67
55
  """Test that optional parameters are set to None when calling instance"""
68
- c = ConfigWithOptional().instance()
56
+ c = ConfigWithOptional.C().instance()
69
57
  assert c.x == 1
70
58
  assert c.y is None
59
+
60
+
61
+ def test_instance_keep_config():
62
+ evaluator = Evaluator.C(model=Model.C())
63
+ instance = evaluator.instance(keep=True)
64
+
65
+ assert instance.__config__ is evaluator