Skip to content

initial commit

To make it possible, to send data to a workflow on another machine, the interfaces were put into the scripts nested_loop_control (UNICADOworklow_dir and reference_aircraft_dir as inputs) and post_operations_of_workflow (result_dir as an output).

The following code was added to nested_loop_control (line 130):

	if not os.path.isdir(install_path_directory + 'workingDirectoryRCE/' + current_workflow_name):
		os.makedirs(install_path_directory + 'workingDirectoryRCE/' + current_workflow_name + '/temp')
		external_input = False
	try:
		reference_aircraft = RCE.read_input("reference_aircraft_dir")
		external_workflow = RCE.read_input("UNICADOworklow_dir")
		external_input = True
	
	except Exception:
		pass
	
	if external_input:
		print("Workflow started with external input: Adapt workflow configuration and load aircraft refernce.")
		aircraft_dir = install_path_directory + 'workingDirectoryRCE/' + current_workflow_name + '/'
		aircraft_name = os.path.basename(os.path.normpath(str(RCE.read_input("reference_aircraft_dir"))))
		shutil.copytree(reference_aircraft, aircraft_dir + aircraft_name)
		
		# Set the aircraft directory 
		wf_tree = xml.etree.ElementTree.parse(external_workflow + '/unicado_workflow_conf.xml')
		wf_root = wf_tree.getroot()
		
		# Set the config parameters
		updates = {
		    'control_settings/aircraft_exchange_file_name/value': aircraft_name + '.xml',
		    'control_settings/aircraft_exchange_file_directory/value': aircraft_dir,
		}
		# Update config parameters
		for subpath, new_value in updates.items():
		    item_node = wf_root.find(subpath)
		    if item_node is not None:
		        item_node.text = new_value
		    else:
		        raise ValueError(f'Node {subpath} in workflow config not existing!')
		
		# Save updated XML and send it into workspace
		wf_tree.write(external_workflow + '/unicado_workflow_conf.xml', encoding='utf-8', xml_declaration=True)
		
		# Copy external workflow files into the servers workflow directory
		files = ['/unicado_workflow_conf.xml', '/optimization_conf.xml', '/parameter_study_conf.xml', '/parameter_study_values.csv', '/range_type_specific_factors.xml']
		for file in files:
			if os.path.isfile(external_workflow + file):
				shutil.copyfile(external_workflow + file, install_path_directory + 'workingDirectoryRCE/UNICADOworkflow' + file)
			else:
				print("Warning: The file " + file + " was not provided in the external workflow directory. If it's needed, the server's " + file + " will be used")

For post_operations_of_workflow, only these lines were added at the end:

result_dir = paths_and_names[1][1] + "workflowResults/" 
result_dir = result_dir + paths_and_names[4][1] + "_" + paths_and_names[10][1]
RCE.write_output("result_dir", result_dir)

I've added an ExternalWorklow.wf were you can easily put a wrapped workflow in (please mind, you need to set the input providers workflow dir to your own workflow dir where the workflow config is. With the installer, we might provide that automatically later, if we want to give away this workflow, too). To wrap the workflow, right click on it and "integrate the workflow as a tool". There you need to set a name and make sure, you map these inputs and outputs (this would not have to be done by the user, once I put it, e.g. on my server):

image

Merge request reports

Loading