diff --git a/aiida_fleur/cmdline/launch/launch.py b/aiida_fleur/cmdline/launch/launch.py index eee8cdce4..dffe93327 100755 --- a/aiida_fleur/cmdline/launch/launch.py +++ b/aiida_fleur/cmdline/launch/launch.py @@ -155,7 +155,7 @@ def launch_fleur(fleurinp, fleur, parent_folder, settings, daemon, max_num_machi @click.command('scf') -@options.STRUCTURE_OR_FILE(default="inp.xml", show_default=True) +@options.STRUCTURE_OR_FILE(default='inp.xml', show_default=True) @options.INPGEN() @options.CALC_PARAMETERS() @options.SETTINGS() @@ -171,13 +171,13 @@ def launch_scf(structure, inpgen, calc_parameters, fleurinp, fleur, wf_parameter """ Launch a scf workchain """ - fleurinp=None - + fleurinp = None + if isinstance(structure, FleurinpData): - fleurinp=structure - structure=None - inpgen=None - + fleurinp = structure + structure = None + inpgen = None + workchain_class = WorkflowFactory('fleur.scf') inputs = { 'inpgen': inpgen, @@ -194,26 +194,27 @@ def launch_scf(structure, inpgen, calc_parameters, fleurinp, fleur, wf_parameter inputs = clean_nones(inputs) builder = workchain_class.get_builder() builder.update(inputs) - pk=utils.launch_process(builder, daemon) + pk = utils.launch_process(builder, daemon) #Now create output files if fleurinp and not daemon: from aiida.orm import load_node - wf=load_node(pk) - scf_output=wf.outputs.output_scf_wc_para.get_dict() + wf = load_node(pk) + scf_output = wf.outputs.output_scf_wc_para.get_dict() #json with dict import json - with open("scf.json","w") as file: - json.dump(scf_output,file,indent=2) + with open('scf.json', 'w') as file: + json.dump(scf_output, file, indent=2) #plot from aiida_fleur.tools.plot.fleur import plot_fleur - plot_fleur(wf,save=True,show=False) + plot_fleur(wf, save=True, show=False) #store files - for file in ["out.xml","cdn1","cdn_last.hdf"]: + for file in ['out.xml', 'cdn1', 'cdn_last.hdf']: if file in wf.outputs.last_calc.retrieved.list_object_names(): - with open(file,"wb") as f: - f.write(wf.outputs.last_calc.retrieved.get_object_content(file,"rb")) + with open(file, 'wb') as f: + f.write(wf.outputs.last_calc.retrieved.get_object_content(file, 'rb')) + @click.command('relax') @options.STRUCTURE_OR_FILE(default=defaults.get_si_bulk_structure, show_default=True) @@ -251,7 +252,7 @@ def launch_relax(structure, inpgen, calc_parameters, fleur, wf_parameters, scf_p @click.command('eos') -@options.STRUCTURE_OR_FILE(default="inp.xml", show_default=True) +@options.STRUCTURE_OR_FILE(default='inp.xml', show_default=True) @options.INPGEN() @options.CALC_PARAMETERS() @options.FLEUR() @@ -266,13 +267,13 @@ def launch_eos(structure, inpgen, calc_parameters, fleur, wf_parameters, scf_par """ workchain_class = WorkflowFactory('fleur.eos') - - fleurinp=None - + + fleurinp = None + if isinstance(structure, FleurinpData): - fleurinp=structure - structure=None - + fleurinp = structure + structure = None + inputs = { 'scf': { 'wf_parameters': scf_parameters, @@ -288,34 +289,34 @@ def launch_eos(structure, inpgen, calc_parameters, fleur, wf_parameters, scf_par inputs = clean_nones(inputs) builder = workchain_class.get_builder() builder.update(inputs) - pk=utils.launch_process(builder, daemon) + pk = utils.launch_process(builder, daemon) #Now create output files if fleurinp and not daemon: from aiida.orm import load_node - wf=load_node(pk) - eos_output=wf.outputs.output_eos_wc_para.get_dict() + wf = load_node(pk) + eos_output = wf.outputs.output_eos_wc_para.get_dict() #json with dict import json - with open("eos.json","w") as file: - json.dump(eos_output,file,indent=2) + with open('eos.json', 'w') as file: + json.dump(eos_output, file, indent=2) #cif file - if "output_eos_wc_structure" in wf.outputs: + if 'output_eos_wc_structure' in wf.outputs: import os.path - if os.path.isfile("opt_struct.cif"): os.remove("opt_struct.cif") - cif_struct=wf.outputs.output_eos_wc_structure.get_cif() - cif_struct.export("opt_struct.cif") + if os.path.isfile('opt_struct.cif'): + os.remove('opt_struct.cif') + cif_struct = wf.outputs.output_eos_wc_structure.get_cif() + cif_struct.export('opt_struct.cif') #plot - if eos_output["volume_gs"] >0 : + if eos_output['volume_gs'] > 0: from aiida_fleur.tools.plot.fleur import plot_fleur - plot_fleur(wf,save=True,show=False) - - for i,uuid in enumerate(eos_output["calculations"]): - scf=load_node(uuid) - scale=eos_output["scaling"][i] - with open(f"out_{scale}.xml","w") as f: - f.write(scf.outputs.last_calc.retrieved.get_object_content("out.xml")) + plot_fleur(wf, save=True, show=False) + for i, uuid in enumerate(eos_output['calculations']): + scf = load_node(uuid) + scale = eos_output['scaling'][i] + with open(f"out_{scale}.xml", 'w') as f: + f.write(scf.outputs.last_calc.retrieved.get_object_content('out.xml')) @click.command('banddos') diff --git a/aiida_fleur/cmdline/util/types.py b/aiida_fleur/cmdline/util/types.py index c88e9cb04..20f9dbf4c 100644 --- a/aiida_fleur/cmdline/util/types.py +++ b/aiida_fleur/cmdline/util/types.py @@ -37,11 +37,11 @@ def convert(self, value, param, ctx): # aiida allows also for shorten uuids from aiida.orm import StructureData, QueryBuilder - if value in ["inp.xml",".",'./']: + if value in ['inp.xml', '.', './']: from aiida_fleur.data.fleurinp import FleurinpData - inp_files=["inp.xml"] + inp_files = ['inp.xml'] #check if there are included files in this dir - for file in ["kpts.xml","sym.xml","relax.xml"]: + for file in ['kpts.xml', 'sym.xml', 'relax.xml']: import os.path if os.path.isfile(file): inp_files.append(file) diff --git a/aiida_fleur/cmdline/util/utils.py b/aiida_fleur/cmdline/util/utils.py index fa6f02bce..d47fe7a3e 100644 --- a/aiida_fleur/cmdline/util/utils.py +++ b/aiida_fleur/cmdline/util/utils.py @@ -63,4 +63,4 @@ def launch_process(process, daemon, **inputs): _, node = launch.run_get_node(process, **inputs) echo_process_results(node) - return node.pk + return node.pk diff --git a/aiida_fleur/cmdline/workflows/__init__.py b/aiida_fleur/cmdline/workflows/__init__.py index b52a1fa82..e82170a59 100755 --- a/aiida_fleur/cmdline/workflows/__init__.py +++ b/aiida_fleur/cmdline/workflows/__init__.py @@ -28,8 +28,9 @@ def cmd_workflow(): @cmd_workflow.command('res') -@arguments.PROCESS('process', type=ProcessParamType() - ) #, type=WorkflowParamType(sub_classes=('aiida.node:process.workflow.workchain',))) +@arguments.PROCESS( + 'process', + type=ProcessParamType()) #, type=WorkflowParamType(sub_classes=('aiida.node:process.workflow.workchain',))) @click.option('--info/--no-info', default=False, help='Print an info header above each node.') @click.option('-l', '--label', 'label', type=str, help='Print only output dicts with a certain link_label.') @options_fl.SHOW() @@ -69,8 +70,9 @@ def workchain_res(process, info, label, show, keys, fmt): @cmd_workflow.command('inputdict') -@arguments.PROCESS('process', type=ProcessParamType() - ) #, type=WorkflowParamType(sub_classes=('aiida.node:process.workflow.workchain',))) +@arguments.PROCESS( + 'process', + type=ProcessParamType()) #, type=WorkflowParamType(sub_classes=('aiida.node:process.workflow.workchain',))) @click.option('--info/--no-info', default=False, help='Print an info header above each node.') @click.option('-l', '--label', 'label', type=str, help='Print only output dicts with a certain link_label.') @options_fl.SHOW() diff --git a/aiida_fleur/parsers/fleur.py b/aiida_fleur/parsers/fleur.py index 6f275066d..ec96fffbc 100644 --- a/aiida_fleur/parsers/fleur.py +++ b/aiida_fleur/parsers/fleur.py @@ -131,9 +131,9 @@ def parse(self, **kwargs): # Open log-file as well try: - run_was_successful="finished successfully" in error_file_lines + run_was_successful = 'finished successfully' in error_file_lines except: - run_was_successful=False + run_was_successful = False if FleurCalculation._LOG_FILE_NAME in list_of_files: logfile = FleurCalculation._LOG_FILE_NAME # read @@ -141,13 +141,13 @@ def parse(self, **kwargs): try: with output_folder.open(logfile, 'r') as efile: log_file_entries = json.load(efile) - run_was_successful="Success" in log_file_entries[-1] + run_was_successful = 'Success' in log_file_entries[-1] except OSError: self.logger.error(f'Failed to open log file: {logfile}.') return self.exit_codes.ERROR_OPENING_OUTPUTS except json.JSONDecodeError: - self.logger.error("logfile not correctly formatted") - + self.logger.error('logfile not correctly formatted') + #Now check for different kind of errors if not run_was_successful: self.logger.warning('The following was written into std error and piped to {}' @@ -159,8 +159,7 @@ def parse(self, **kwargs): kb_used = 0.0 if has_xml_outfile: - with output_folder.open(FleurCalculation._OUTXML_FILE_NAME, - 'r') as out_file: # lazy out.xml parsing + with output_folder.open(FleurCalculation._OUTXML_FILE_NAME, 'r') as out_file: # lazy out.xml parsing outlines = out_file.read() try: line_avail = re.findall(r'