20
20
MagOrderParameterConstraint ,
21
21
MagOrderingTransformation ,
22
22
)
23
+ from pymatgen .alchemy .materials import TransformedStructure
23
24
24
25
from atomate .utils .utils import get_logger
25
26
@@ -198,6 +199,13 @@ def __init__(
198
199
self .num_orderings = 64
199
200
self .max_unique_sites = 8
200
201
202
+ self .uuid = str (uuid4 ())
203
+ self .wf_meta = {
204
+ "wf_uuid" : self .uuid ,
205
+ "wf_name" : self .__class__ .__name__ ,
206
+ "wf_version" : __magnetic_ordering_wf_version__ ,
207
+ }
208
+
201
209
# kwargs to pass to transformation (ultimately to enumlib)
202
210
default_transformation_kwargs = {"check_ordered_symmetry" : False , "timeout" : 5 }
203
211
transformation_kwargs = transformation_kwargs or {}
@@ -248,7 +256,7 @@ def __init__(
248
256
)
249
257
250
258
@staticmethod
251
- def _sanitize_input_structure ( input_structure ):
259
+ def _sanitize_input_structure (input_structure ):
252
260
"""
253
261
Sanitize our input structure by removing magnetic information
254
262
and making primitive.
@@ -565,6 +573,24 @@ def _add_structures(
565
573
origin = origin ,
566
574
)
567
575
576
+ def _add_metadata (structure ):
577
+ """
578
+ For book-keeping, store useful metadata with the Structure
579
+ object for later database ingestion.
580
+
581
+ Args:
582
+ structure: Structure
583
+
584
+ Returns: TransformedStructure
585
+ """
586
+ # this could be further improved by storing full transformation
587
+ # history, but would require an improved transformation pipeline
588
+ return TransformedStructure (
589
+ structure , other_parameters = {"wf_meta" : self .wf_meta }
590
+ )
591
+
592
+ ordered_structures = [_add_metadata (struct ) for struct in ordered_structures ]
593
+
568
594
# in case we've introduced duplicates, let's remove them
569
595
logger .info ("Pruning duplicate structures." )
570
596
structures_to_remove = []
@@ -791,11 +817,10 @@ def get_wf(
791
817
792
818
analysis_parents .append (fws [- 1 ])
793
819
794
- uuid = str (uuid4 ())
795
820
fw_analysis = Firework (
796
821
MagneticOrderingsToDB (
797
822
db_file = c ["DB_FILE" ],
798
- wf_uuid = uuid ,
823
+ wf_uuid = self . uuid ,
799
824
auto_generated = False ,
800
825
name = "MagneticOrderingsToDB" ,
801
826
parent_structure = self .sanitized_structure ,
@@ -816,18 +841,9 @@ def get_wf(
816
841
wf_name += " - SCAN"
817
842
wf = Workflow (fws , name = wf_name )
818
843
819
- wf = add_additional_fields_to_taskdocs (
820
- wf ,
821
- {
822
- "wf_meta" : {
823
- "wf_uuid" : uuid ,
824
- "wf_name" : "magnetic_orderings" ,
825
- "wf_version" : __magnetic_ordering_wf_version__ ,
826
- }
827
- },
828
- )
844
+ wf = add_additional_fields_to_taskdocs (wf , {"wf_meta" : self .wf_meta })
829
845
830
- tag = "magnetic_orderings group: >>{}<<" .format (uuid )
846
+ tag = "magnetic_orderings group: >>{}<<" .format (self . uuid )
831
847
wf = add_tags (wf , [tag , ordered_structure_origins ])
832
848
833
849
self ._wf = wf
0 commit comments