-
Notifications
You must be signed in to change notification settings - Fork 7
/
Copy pathconftest.py
953 lines (868 loc) · 29.8 KB
/
conftest.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
import random
import uuid
from copy import deepcopy
import pytest
from citrine.informatics.predictors import AutoMLEstimator
from citrine.resources.status_detail import StatusDetail, StatusLevelEnum
from tests.utils.factories import (PredictorEntityDataFactory, PredictorDataDataFactory,
PredictorMetadataDataFactory, StatusDataFactory)
def build_predictor_entity(instance, status_name="READY", status_detail=[]):
user = str(uuid.uuid4())
time = '2020-04-23T15:46:26Z'
return dict(
id=str(uuid.uuid4()),
data=dict(
name=instance.get("name"),
description=instance.get("description"),
instance=instance
),
metadata=dict(
status=dict(
name=status_name,
detail=status_detail
),
created=dict(
user=user,
time=time
),
updated=dict(
user=user,
time=time
)
)
)
@pytest.fixture
def valid_product_design_space_data():
"""Produce valid product design space data."""
from citrine.informatics.descriptors import FormulationDescriptor
user = str(uuid.uuid4())
time = '2020-04-23T15:46:26Z'
return dict(
id=str(uuid.uuid4()),
data=dict(
name='my design space',
description='does some things',
instance=dict(
type='ProductDesignSpace',
name='my design space',
description='does some things',
subspaces=[
dict(
type='FormulationDesignSpace',
name='first subspace',
description='',
formulation_descriptor=FormulationDescriptor.hierarchical().dump(),
ingredients=['foo'],
labels={'bar': ['foo']},
constraints=[],
resolution=0.1
),
dict(
type='FormulationDesignSpace',
name='second subspace',
description='formulates some things',
formulation_descriptor=FormulationDescriptor.hierarchical().dump(),
ingredients=['baz'],
labels={},
constraints=[],
resolution=0.1
)
],
dimensions=[
dict(
type='ContinuousDimension',
descriptor=dict(
type='Real',
descriptor_key='alpha',
units='',
lower_bound=5.0,
upper_bound=10.0,
),
lower_bound=6.0,
upper_bound=7.0
),
dict(
type='EnumeratedDimension',
descriptor=dict(
type='Categorical',
descriptor_key='color',
descriptor_values=['blue', 'green', 'red'],
),
list=['red']
)
]
)
),
metadata=dict(
created=dict(
user=user,
time=time
),
updated=dict(
user=user,
time=time
),
status=dict(
name='VALIDATING',
detail=[]
)
)
)
@pytest.fixture
def valid_enumerated_design_space_data():
"""Produce valid enumerated design space data."""
user = str(uuid.uuid4())
time = '2020-04-23T15:46:26Z'
return dict(
id=str(uuid.uuid4()),
data=dict(
name='my enumerated design space',
description='enumerates some things',
instance=dict(
type='EnumeratedDesignSpace',
name='my enumerated design space',
description='enumerates some things',
descriptors=[
dict(
type='Real',
descriptor_key='x',
units='',
lower_bound=1.0,
upper_bound=2.0,
),
dict(
type='Categorical',
descriptor_key='color',
descriptor_values=['blue', 'green', 'red'],
),
dict(
type='Inorganic',
descriptor_key='formula'
)
],
data=[
dict(x='1', color='red', formula='C44H54Si2'),
dict(x='2.0', color='green', formula='V2O3')
]
)
),
metadata=dict(
created=dict(
user=user,
time=time
),
updated=dict(
user=user,
time=time
),
archived=dict(
user=user,
time=time
),
status=dict(
name='VALIDATING',
detail=[]
)
)
)
@pytest.fixture
def valid_formulation_design_space_data():
"""Produce valid formulation design space data."""
from citrine.informatics.constraints import IngredientCountConstraint
from citrine.informatics.descriptors import FormulationDescriptor
descriptor = FormulationDescriptor.hierarchical()
constraint = IngredientCountConstraint(formulation_descriptor=descriptor, min=0, max=1)
user = str(uuid.uuid4())
time = '2020-04-23T15:46:26Z'
return dict(
id=str(uuid.uuid4()),
data=dict(
name='formulation design space',
description='formulates some things',
instance=dict(
type='FormulationDesignSpace',
name='formulation design space',
description='formulates some things',
formulation_descriptor=descriptor.dump(),
ingredients=['foo'],
labels={'bar': ['foo']},
constraints=[constraint.dump()],
resolution=0.1
)
),
metadata=dict(
created=dict(
user=user,
time=time
),
updated=dict(
user=user,
time=time
),
archived=dict(
user=user,
time=time
),
status=dict(
name='VALIDATING',
detail=[]
)
)
)
@pytest.fixture
def valid_hierarchical_design_space_data(
valid_material_node_definition_data,
valid_gem_data_source_dict
):
"""Produce valid hierarchical design space data."""
import copy
name = 'hierarchical design space'
description = 'does things but in levels'
user = str(uuid.uuid4())
time = '2020-04-23T15:46:26Z'
return dict(
id=str(uuid.uuid4()),
data=dict(
name=name,
description=description,
instance=dict(
type='HierarchicalDesignSpace',
name=name,
description=description,
root=copy.deepcopy(valid_material_node_definition_data),
subspaces=[copy.deepcopy(valid_material_node_definition_data)],
data_sources=[valid_gem_data_source_dict]
)
),
metadata=dict(
created=dict(
user=user,
time=time
),
updated=dict(
user=user,
time=time
),
archived=dict(
user=user,
time=time
),
status=dict(
name='VALIDATING',
detail=[]
)
)
)
@pytest.fixture
def valid_material_node_definition_data(valid_formulation_design_space_data):
return dict(
identifier=dict(
id=f"Material Node-{uuid.uuid4()}",
scope="Custom Scope"
),
attributes=[
dict(
type='ContinuousDimension',
descriptor=dict(
type='Real',
descriptor_key='alpha',
units='',
lower_bound=5.0,
upper_bound=10.0,
),
lower_bound=6.0,
upper_bound=7.0
),
dict(
type='EnumeratedDimension',
descriptor=dict(
type='Categorical',
descriptor_key='color',
descriptor_values=['blue', 'green', 'red'],
),
list=['red']
)
],
formulation=valid_formulation_design_space_data["data"]["instance"],
template=dict(
material_template=str(uuid.uuid4()),
process_template=str(uuid.uuid4()),
),
display_name="Material Node"
)
@pytest.fixture()
def valid_gem_data_source_dict():
return {
"type": "hosted_table_data_source",
"table_id": 'e5c51369-8e71-4ec6-b027-1f92bdc14762',
"table_version": 2
}
@pytest.fixture
def valid_auto_ml_predictor_data(valid_gem_data_source_dict):
"""Produce valid data used for tests."""
from citrine.informatics.descriptors import RealDescriptor
x = RealDescriptor("x", lower_bound=0, upper_bound=100, units="")
z = RealDescriptor("z", lower_bound=0, upper_bound=100, units="")
return dict(
type='AutoML',
name='AutoML predictor',
description='Predicts z from input x',
inputs=[x.dump()],
outputs=[z.dump()],
estimators=[AutoMLEstimator.RANDOM_FOREST.value],
training_data=[]
)
@pytest.fixture
def valid_graph_predictor_data(
valid_simple_mixture_predictor_data,
valid_label_fractions_predictor_data,
valid_expression_predictor_data,
valid_mean_property_predictor_data,
valid_auto_ml_predictor_data
):
"""Produce valid data used for tests."""
from citrine.informatics.data_sources import GemTableDataSource
instance = dict(
name='Graph predictor',
description='description',
predictors=[
valid_simple_mixture_predictor_data,
valid_label_fractions_predictor_data,
valid_expression_predictor_data,
valid_mean_property_predictor_data,
valid_auto_ml_predictor_data
],
training_data=[GemTableDataSource(table_id=uuid.uuid4(), table_version=0).dump()]
)
return PredictorEntityDataFactory(data=PredictorDataDataFactory(instance=instance))
@pytest.fixture
def valid_graph_predictor_data_empty():
"""Another predictor valid data used for tests."""
instance = dict(
type='Graph',
name='Empty Graph predictor',
description='description',
predictors=[],
training_data=[]
)
return PredictorEntityDataFactory(data=PredictorDataDataFactory(instance=instance))
@pytest.fixture
def valid_deprecated_expression_predictor_data():
"""Produce valid data used for tests."""
from citrine.informatics.descriptors import RealDescriptor
shear_modulus = RealDescriptor('Property~Shear modulus', lower_bound=0, upper_bound=100, units='GPa')
return dict(
type='Expression',
name='Expression predictor',
description='Computes shear modulus from Youngs modulus and Poissons ratio',
expression='Y / (2 * (1 + v))',
output=shear_modulus.dump(),
aliases={
'Y': "Property~Young's modulus",
'v': "Property~Poisson's ratio",
}
)
@pytest.fixture
def valid_expression_predictor_data():
"""Produce valid data used for tests."""
from citrine.informatics.descriptors import RealDescriptor
shear_modulus = RealDescriptor('Property~Shear modulus', lower_bound=0, upper_bound=100, units='GPa')
youngs_modulus = RealDescriptor('Property~Young\'s modulus', lower_bound=0, upper_bound=100, units='GPa')
poissons_ratio = RealDescriptor('Property~Poisson\'s ratio', lower_bound=-1, upper_bound=0.5, units='')
return dict(
type='AnalyticExpression',
name='Expression predictor',
description='Computes shear modulus from Youngs modulus and Poissons ratio',
expression='Y / (2 * (1 + v))',
output=shear_modulus.dump(),
aliases={
'Y': youngs_modulus.dump(),
'v': poissons_ratio.dump(),
}
)
@pytest.fixture
def valid_predictor_report_data(example_categorical_pva_metrics, example_f1_metrics):
"""Produce valid data used for tests."""
from citrine.informatics.descriptors import RealDescriptor
x = RealDescriptor("x", lower_bound=0, upper_bound=1, units="")
y = RealDescriptor("y", lower_bound=0, upper_bound=100, units="")
z = RealDescriptor("z", lower_bound=0, upper_bound=101, units="")
return dict(
id='7c2dda5d-675a-41b6-829c-e485163f0e43',
module_id='31c7f311-6f3d-4a93-9387-94cc877f170c',
status='OK',
create_time='2020-04-23T15:46:26Z',
update_time='2020-04-23T15:46:26Z',
report=dict(
models=[
dict(
name='GeneralLoloModel_1',
type='ML Model',
inputs=[x.key],
outputs=[y.key],
display_name='ML Model',
model_settings=[
dict(
name='Algorithm',
value='Ensemble of non-linear estimators',
children=[
dict(name='Number of estimators', value=64, children=[]),
dict(name='Leaf model', value='Mean', children=[]),
dict(name='Use jackknife', value=True, children=[])
]
)
],
feature_importances=[
dict(
response_key='y',
importances=dict(x=1.00),
top_features=5
)
],
selection_summary=dict(
n_folds=4,
evaluation_results=[
dict(
model_settings=[
dict(
name='Algorithm',
value='Ensemble of non-linear estimators',
children=[
dict(name='Number of estimators', value=64, children=[]),
dict(name='Leaf model', value='Mean', children=[]),
dict(name='Use jackknife', value=True, children=[])
]
)
],
response_results=dict(
response_name=dict(
metrics=dict(
predicted_vs_actual=example_categorical_pva_metrics,
f1=example_f1_metrics
)
)
)
)
]
),
predictor_configuration_name="Predict y from x with ML"
),
dict(
name='GeneralLosslessModel_2',
type='Analytic Model',
inputs=[x.key, y.key],
outputs=[z.key],
display_name='GeneralLosslessModel_2',
model_settings=[
dict(
name="Expression",
value="(z) <- (x + y)",
children=[]
)
],
feature_importances=[],
predictor_configuration_name="Expression for z",
predictor_configuration_uid="249bf32c-6f3d-4a93-9387-94cc877f170c"
)
],
descriptors=[x.dump(), y.dump(), z.dump()]
)
)
@pytest.fixture
def valid_ing_formulation_predictor_data():
"""Produce valid data used for tests."""
from citrine.informatics.descriptors import RealDescriptor
return dict(
type='IngredientsToSimpleMixture',
name='Ingredients to formulation predictor',
description='Constructs mixtures from ingredients',
id_to_quantity={
'water': RealDescriptor('water quantity', lower_bound=0, upper_bound=1, units="").dump(),
'salt': RealDescriptor('salt quantity', lower_bound=0, upper_bound=1, units="").dump()
},
labels={
'solvent': ['water'],
'solute': ['salt'],
}
)
@pytest.fixture
def valid_generalized_mean_property_predictor_data():
"""Produce valid data used for tests."""
from citrine.informatics.descriptors import FormulationDescriptor
formulation_descriptor = FormulationDescriptor.hierarchical()
return dict(
type='GeneralizedMeanProperty',
name='Mean property predictor',
description='Computes mean ingredient properties',
input=formulation_descriptor.dump(),
properties=['density'],
p=2,
impute_properties=True,
default_properties={'density': 1.0},
label='solvent'
)
@pytest.fixture
def valid_mean_property_predictor_data():
"""Produce valid data used for tests."""
from citrine.informatics.descriptors import FormulationDescriptor, RealDescriptor
formulation_descriptor = FormulationDescriptor.flat()
density = RealDescriptor(key='density', lower_bound=0, upper_bound=100, units='g/cm^3')
return dict(
type='MeanProperty',
name='Mean property predictor',
description='Computes mean ingredient properties',
input=formulation_descriptor.dump(),
properties=[density.dump()],
p=2.0,
impute_properties=True,
default_properties={'density': 1.0},
label='solvent',
training_data=[]
)
@pytest.fixture
def valid_label_fractions_predictor_data():
"""Produce valid data used for tests."""
from citrine.informatics.descriptors import FormulationDescriptor
return dict(
type='LabelFractions',
name='Label fractions predictor',
description='Computes relative proportions of labeled ingredients',
input=FormulationDescriptor.hierarchical().dump(),
labels=['solvent']
)
@pytest.fixture
def valid_ingredient_fractions_predictor_data():
"""Produce valid data used for tests."""
from citrine.informatics.descriptors import FormulationDescriptor
return dict(
type='IngredientFractions',
name='Ingredient fractions predictor',
description='Computes ingredient fractions',
input=FormulationDescriptor.hierarchical().dump(),
ingredients=['Blue dye', 'Red dye']
)
@pytest.fixture
def valid_data_source_design_space_dict(valid_gem_data_source_dict):
user = str(uuid.uuid4())
time = '2020-04-23T15:46:26Z'
return dict(
id=str(uuid.uuid4()),
data=dict(
name="Example valid data source design space",
description="Example valid data source design space based on a GEM Table Data Source.",
instance=dict(
type="DataSourceDesignSpace",
name="Example valid data source design space",
description="Example valid data source design space based on a GEM Table Data Source.",
data_source=valid_gem_data_source_dict
)
),
metadata=dict(
created=dict(
user=user,
time=time
),
updated=dict(
user=user,
time=time
),
status=dict(
name='VALIDATING',
detail=[]
)
)
)
@pytest.fixture
def invalid_predictor_node_data():
"""Produce invalid valid data used for tests."""
from citrine.informatics.descriptors import RealDescriptor
x = RealDescriptor("x", lower_bound=0, upper_bound=100, units="")
y = RealDescriptor("y", lower_bound=0, upper_bound=100, units="")
z = RealDescriptor("z", lower_bound=0, upper_bound=100, units="")
return dict(
type='invalid',
name='my predictor',
description='does some things',
inputs=[x.dump(), y.dump()],
output=z.dump()
)
@pytest.fixture
def invalid_graph_predictor_data():
"""Produce valid data used for tests."""
from citrine.informatics.descriptors import RealDescriptor
x = RealDescriptor("x", lower_bound=0, upper_bound=100, units="")
y = RealDescriptor("y", lower_bound=0, upper_bound=100, units="")
z = RealDescriptor("z", lower_bound=0, upper_bound=100, units="")
instance = dict(
type='invalid',
name='my predictor',
description='does some things badly',
predictors=[x.dump(), y.dump()],
)
detail = [
StatusDetail(level=StatusLevelEnum.WARNING, msg='Something is wrong'),
StatusDetail(level="Error", msg='Very wrong')
]
status = StatusDataFactory(name='INVALID', detail=detail)
return PredictorEntityDataFactory(
data=PredictorDataDataFactory(instance=instance),
meatadata=PredictorMetadataDataFactory(status=status)
)
@pytest.fixture
def valid_simple_mixture_predictor_data():
"""Produce valid data used for tests."""
return dict(
type='SimpleMixture',
name='Simple mixture predictor',
description='simple mixture description',
training_data=[]
)
@pytest.fixture
def example_cv_evaluator_dict():
return {
"type": "CrossValidationEvaluator",
"name": "Example evaluator",
"description": "An evaluator for testing",
"responses": ["salt?", "saltiness"],
"n_folds": 6,
"n_trials": 8,
"metrics": [
{"type": "PVA"}, {"type": "RMSE"}, {"type": "F1"}
],
"ignore_when_grouping": ["temperature"]
}
@pytest.fixture
def example_holdout_evaluator_dict(valid_gem_data_source_dict):
return {
"type": "HoldoutSetEvaluator",
"name": "Example holdout evaluator",
"description": "",
"responses": ["sweetness"],
"data_source": valid_gem_data_source_dict,
"metrics": [{"type": "RMSE"}]
}
@pytest.fixture()
def example_rmse_metrics():
return {
"type": "RealMetricValue",
"mean": 0.4,
"standard_error": 0.12
}
@pytest.fixture
def example_f1_metrics():
return {
"type": "RealMetricValue",
"mean": 0.3
}
@pytest.fixture
def example_real_pva_metrics():
return {
"type": "RealPredictedVsActual",
"value": [
{
"uuid": "0ca80829-fd17-45fb-93c9-62ea4e4c294d",
"identifiers": ["Foo", "Bar"],
"trial": 1,
"fold": 3,
"predicted": {
"type": "RealMetricValue",
"mean": 1.0,
"standard_error": 0.12
},
"actual": {
"type": "RealMetricValue",
"mean": 1.2,
"standard_error": 0.0
}
}
]
}
@pytest.fixture
def example_categorical_pva_metrics():
return {
"type": "CategoricalPredictedVsActual",
"value": [
{
"uuid": "0ca80829-fd17-45fb-93c9-62ea4e4c294d",
"identifiers": ["Foo", "Bar"],
"trial": 1,
"fold": 3,
"predicted": {
"salt": 0.3,
"not salt": 0.7
},
"actual": {
"not salt": 1.0
}
}
]
}
@pytest.fixture()
def example_cv_result_dict(example_cv_evaluator_dict, example_rmse_metrics, example_categorical_pva_metrics, example_f1_metrics, example_real_pva_metrics):
return {
"type": "CrossValidationResult",
"evaluator": example_cv_evaluator_dict,
"response_results": {
"salt?": {
"metrics": {
"predicted_vs_actual": example_categorical_pva_metrics,
"f1": example_f1_metrics
}
},
"saltiness": {
"metrics": {
"predicted_vs_actual": example_real_pva_metrics,
"rmse": example_rmse_metrics
}
}
}
}
@pytest.fixture()
def example_holdout_result_dict(example_holdout_evaluator_dict, example_rmse_metrics):
return {
"type": "HoldoutSetResult",
"evaluator": example_holdout_evaluator_dict,
"response_results": {
"sweetness": {
"metrics": {
"rmse": example_rmse_metrics
}
}
}
}
@pytest.fixture
def sample_design_space_execution_dict(generic_entity):
ret = generic_entity.copy()
ret.update(
{
"design_space_id": str(uuid.uuid4()),
"status": {
"major": ret.get("status"),
"minor": ret.get("status_description"),
"detail": ret.get("status_detail")
}
}
)
return ret
@pytest.fixture()
def example_design_material():
return {
'vars': {
'Temperature': {'type': 'R', 'm': 475.8, 's': 0},
'Flour': {'type': 'C', 'cp': {'flour': 100.0}},
'Water': {'type': 'M', 'q': {'water': 72.5}, 'l': {}},
'Salt': {'type': 'F', 'f': 'NaCl'},
'Yeast': {'type': 'S', 's': 'O1C=2C=C(C=3SC=C4C=CNC43)CC2C=5C=CC=6C=CNC6C15'}
},
'identifiers': {
'id': str(uuid.uuid4()),
'identifiers': [],
'material_template': str(uuid.uuid4()),
'process_template': str(uuid.uuid4())
}
}
@pytest.fixture()
def example_hierarchical_design_material(example_design_material):
return {
'terminal': example_design_material,
'sub_materials': [example_design_material],
'mixtures': {
str(uuid.uuid4()): {'q': {'A': 0.5, 'B': 0.5}, 'l': {}}
}
}
@pytest.fixture()
def example_candidates(example_design_material):
return {
"page": 2,
"per_page": 4,
"response": [{
"id": str(uuid.uuid4()),
"material_id": str(uuid.uuid4()),
"identifiers": [],
"primary_score": 0,
"material": example_design_material,
"name": "Example candidate",
"hidden": True
}]
}
@pytest.fixture()
def example_sample_design_space_response(example_hierarchical_design_material):
return {
"per_page": 4,
"response": [{
"id": str(uuid.uuid4()),
"execution_id": str(uuid.uuid4()),
"material": example_hierarchical_design_material
}]
}
@pytest.fixture
def generic_entity():
user = str(uuid.uuid4())
return {
"id": str(uuid.uuid4()),
"status": "INPROGRESS",
"status_description": "VALIDATING",
"status_detail": [{"level": "Info", "msg": "System processing"}],
"experimental": False,
"experimental_reasons": [],
"create_time": '2020-04-23T15:46:26Z',
"update_time": '2020-04-23T15:46:26Z',
"created_by": user,
"updated_by": user,
}
@pytest.fixture
def predictor_evaluation_execution_dict(generic_entity):
ret = deepcopy(generic_entity)
ret.update({
"workflow_id": str(uuid.uuid4()),
"predictor_id": str(uuid.uuid4()),
"predictor_version": random.randint(1, 10),
"evaluator_names": ["Example evaluator"]
})
return ret
@pytest.fixture
def design_execution_dict(generic_entity):
ret = generic_entity.copy()
ret.update({
"workflow_id": str(uuid.uuid4()),
"version_number": 2,
"score": {
"type": "MLI",
"baselines": [],
"constraints": [],
"objectives": [],
"name": "score",
"description": ""
},
"descriptors": []
})
return ret
@pytest.fixture
def generative_design_execution_dict(generic_entity):
ret = generic_entity.copy()
return ret
@pytest.fixture
def example_generation_results():
return {
"page": 1,
"per_page": 4,
"response": [{
"id": str(uuid.uuid4()),
"execution_id": str(uuid.uuid4()),
"result": {
"seed": "CCCCO",
"mutated": "CCCN",
"fingerprint_similarity": 0.41,
"fingerprint_type": "ECFP4",
}
}]
}
@pytest.fixture
def predictor_evaluation_workflow_dict(generic_entity, example_cv_evaluator_dict, example_holdout_evaluator_dict):
ret = deepcopy(generic_entity)
ret.update({
"name": "Example PEW",
"description": "Example PEW for testing",
"evaluators": [example_cv_evaluator_dict, example_holdout_evaluator_dict]
})
return ret