def immigrate_existing(builder, remote_data, seal=True): """Immigrate a Calculation that was not run using AiiDa. :param builder: a populated builder instance for a CalcJob :type builder: aiida.engine.processes.builder.ProcessBuilder :param remote_data: a remote data folder, containing the output files required for parsing :type remote_data: aiida.orm.RemoteData :param seal: whether to seal the calc node, from further attribute changes :type seal: bool :rtype: aiida.orm.CalcJobNode """ # initialise calcjob runner = get_manager().get_runner() pw_calc_cls = builder._process_class process = instantiate_process(runner, pw_calc_cls, **builder) calc_node = process.node # prepare for submission with SandboxFolder() as temp_folder: calc_info = process.presubmit(temp_folder) # noqa F841 calc_node.put_object_from_tree(temp_folder.abspath, force=True) # link remote folder to calc_node if not remote_data.is_stored: remote_data.store() remote_data.add_incoming( calc_node, link_type=LinkType.CREATE, link_label="remote_folder" ) calc_node.set_remote_workdir(remote_data.get_remote_path()) transport = remote_data.computer.get_transport() with SandboxFolder() as temp_retrieved: # retrieved output files retrieve_calculation(calc_node, transport, temp_retrieved.abspath) # parse output calc_node.set_state(CalcJobState.PARSING) exit_code = process.parse(temp_retrieved.abspath) # link outgoing nodes process.update_outputs() # finalise calc node calc_node.delete_state() calc_node.delete_checkpoint() calc_node.set_process_state(ProcessState.FINISHED) calc_node.set_exit_status(exit_code.status) calc_node.set_exit_message(exit_code.message) if seal: calc_node.seal() # record that the node was created via immigration calc_node.set_extra("immigrated", True) calc_node.set_extra("immigration_func", __name__) return calc_node
def do_retrieve(): with transport_queue.request_transport(authinfo) as request: transport = yield cancellable.with_interrupt(request) # Perform the job accounting and set it on the node if successful. If the scheduler does not implement this # still set the attribute but set it to `None`. This way we can distinguish calculation jobs for which the # accounting was called but could not be set. scheduler = node.computer.get_scheduler() scheduler.set_transport(transport) try: detailed_job_info = scheduler.get_detailed_job_info(node.get_job_id()) except FeatureNotAvailable: logger.info('detailed job info not available for scheduler of CalcJob<{}>'.format(node.pk)) node.set_detailed_job_info(None) else: node.set_detailed_job_info(detailed_job_info) raise Return(execmanager.retrieve_calculation(node, transport, retrieved_temporary_folder))
nlcgcalc = CalculationFactory('sirius.py.nlcg') calc = nlcgcalc(inputs) with SandboxFolder() as sandbox_folder: calc_info, script_filename = calc.presubmit(sandbox_folder) calc_info.uuid = calc.node.uuid # calc_info = calc.prepare_for_submission(folder=None) from aiida.engine.daemon import execmanager with computer.get_transport() as transport: calc_info, script_filename = execmanager.upload_calculation( calc.node, transport, calc_info, script_filename=script_filename) # dummy submit job_id = -1 calc.node.set_job_id(job_id) # copy stdout to workdir instead of running the actual calculation remote_workdir = calc.node.attributes['remote_workdir'] copyfile('sirius.py.nlcg.out', os.path.join(remote_workdir, 'sirius.py.nlcg.out')) calc.node.set_state(CalcJobState.RETRIEVING) execmanager.retrieve_calculation(calc.node, transport, retrieved_temporary_folder=None) calc.node.set_state(CalcJobState.PARSING) execmanager.parse_results(calc) for out in calc.outputs: calc.outputs[out].store() calc.kill()
def do_retrieve(): with transport_queue.request_transport(authinfo) as request: transport = yield cancellable.with_interrupt(request) raise Return( execmanager.retrieve_calculation(node, transport, retrieved_temporary_folder))