@@ -558,42 +558,19 @@ def process_repair(manager, broker, dry_run):
558
558
echo .echo_report (f'Revived process `{ pid } `' )
559
559
560
560
561
- @verdi_process .command (' dump' )
561
+ @verdi_process .command (" dump" )
562
562
@arguments .PROCESS ()
563
563
@options .PATH ()
564
564
@options .OVERWRITE ()
565
- @click .option (
566
- '--include-inputs/--exclude-inputs' ,
567
- default = True ,
568
- show_default = True ,
569
- help = 'Include the linked input nodes of the `CalculationNode`(s).' ,
570
- )
571
- @click .option (
572
- '--include-outputs/--exclude-outputs' ,
573
- default = False ,
574
- show_default = True ,
575
- help = 'Include the linked output nodes of the `CalculationNode`(s).' ,
576
- )
577
- @click .option (
578
- '--include-attributes/--exclude-attributes' ,
579
- default = True ,
580
- show_default = True ,
581
- help = 'Include attributes in the `.aiida_node_metadata.yaml` written for every `ProcessNode`.' ,
582
- )
583
- @click .option (
584
- '--include-extras/--exclude-extras' ,
585
- default = True ,
586
- show_default = True ,
587
- help = 'Include extras in the `.aiida_node_metadata.yaml` written for every `ProcessNode`.' ,
588
- )
589
- @click .option (
590
- '-f' ,
591
- '--flat' ,
592
- is_flag = True ,
593
- default = False ,
594
- show_default = True ,
595
- help = 'Dump files in a flat directory for every step of the workflow.' ,
596
- )
565
+ @options .FLAT ()
566
+ @options .INCLUDE_INPUTS ()
567
+ @options .INCLUDE_OUTPUTS ()
568
+ @options .INCLUDE_ATTRIBUTES ()
569
+ @options .INCLUDE_EXTRAS ()
570
+ @options .ALSO_RAW ()
571
+ @options .ALSO_RICH ()
572
+ @options .RICH_SPEC ()
573
+ @options .RICH_DUMP_ALL ()
597
574
@click .option (
598
575
'--dump-unsealed' ,
599
576
is_flag = True ,
@@ -602,17 +579,23 @@ def process_repair(manager, broker, dry_run):
602
579
help = 'Also allow the dumping of unsealed process nodes.' ,
603
580
)
604
581
@options .INCREMENTAL ()
582
+ # TODO: Also add CONFIG_FILE option here
583
+ # TODO: Currently, setting rich options is not supported here directly
605
584
def process_dump (
606
585
process ,
607
586
path ,
608
587
overwrite ,
588
+ flat ,
609
589
include_inputs ,
610
590
include_outputs ,
611
591
include_attributes ,
612
592
include_extras ,
613
- flat ,
614
593
dump_unsealed ,
615
594
incremental ,
595
+ also_raw ,
596
+ also_rich ,
597
+ rich_spec ,
598
+ rich_dump_all ,
616
599
) -> None :
617
600
"""Dump process input and output files to disk.
618
601
@@ -630,29 +613,74 @@ def process_dump(
630
613
node data for further inspection.
631
614
"""
632
615
633
- from aiida .tools .archive . exceptions import ExportValidationError
616
+ from aiida .tools .dumping . data import DataDumper
634
617
from aiida .tools .dumping .processes import ProcessDumper
618
+ from aiida .tools .archive .exceptions import ExportValidationError
619
+
620
+ # from aiida.tools.dumping.utils import validate_rich_options
621
+ from aiida .tools .dumping .rich import rich_from_cli
622
+
623
+ processdumper_kwargs = {
624
+ "include_inputs" : include_inputs ,
625
+ "include_outputs" : include_outputs ,
626
+ "include_attributes" : include_attributes ,
627
+ "include_extras" : include_extras ,
628
+ "flat" : flat ,
629
+ "dump_unsealed" : dump_unsealed ,
630
+ "incremental" : incremental ,
631
+ }
632
+
633
+ rich_kwargs = {
634
+ "rich_dump_all" : rich_dump_all ,
635
+ }
636
+
637
+ datadumper_kwargs = {
638
+ "also_raw" : also_raw ,
639
+ "also_rich" : also_rich ,
640
+ }
641
+
642
+ # if also_rich:
643
+ # try:
644
+ # validate_rich_options(
645
+ # rich_options=rich_options, rich_config_file=rich_config_file
646
+ # )
647
+ # except ValueError as exc:
648
+ # echo.echo_critical(f"{exc!s}")
649
+
650
+ if rich_spec is not None :
651
+ rich_spec_dict = rich_from_cli (rich_spec = rich_spec , ** rich_kwargs )
652
+ else :
653
+ rich_spec_dict = {}
654
+
655
+ data_dumper = DataDumper (
656
+ overwrite = overwrite ,
657
+ rich_spec_dict = rich_spec_dict ,
658
+ ** datadumper_kwargs ,
659
+ ** rich_kwargs ,
660
+ )
635
661
636
662
process_dumper = ProcessDumper (
637
- include_inputs = include_inputs ,
638
- include_outputs = include_outputs ,
639
- include_attributes = include_attributes ,
640
- include_extras = include_extras ,
641
663
overwrite = overwrite ,
642
- flat = flat ,
643
- dump_unsealed = dump_unsealed ,
644
- incremental = incremental ,
664
+ ** processdumper_kwargs ,
665
+ ** rich_kwargs ,
666
+ data_dumper = data_dumper ,
645
667
)
646
668
647
669
try :
648
- dump_path = process_dumper .dump (process_node = process , output_path = path )
670
+ dump_path = process_dumper .dump (
671
+ process_node = process ,
672
+ output_path = path ,
673
+ )
674
+ echo .echo_success (
675
+ f"Raw files for { process .__class__ .__name__ } <{ process .pk } > dumped into folder `{ dump_path } `."
676
+ )
649
677
except FileExistsError :
650
678
echo .echo_critical (
651
- ' Dumping directory exists and overwrite is False. Set overwrite to True, or delete directory manually.'
679
+ " Dumping directory exists and overwrite is False. Set overwrite to True, or delete directory manually."
652
680
)
653
681
except ExportValidationError as e :
654
- echo .echo_critical (f' { e !s} ' )
682
+ echo .echo_critical (f" { e !s} " )
655
683
except Exception as e :
656
- echo .echo_critical (f'Unexpected error while dumping { process . __class__ . __name__ } < { process . pk } >: \n ( { e !s } ).' )
657
-
658
- echo . echo_success ( f'Raw files for { process . __class__ . __name__ } < { process . pk } > dumped into folder ` { dump_path } `.' )
684
+ echo .echo_critical (
685
+ f"Unexpected error while dumping { process . __class__ . __name__ } < { process . pk } >: \n ( { e !s } )."
686
+ )
0 commit comments