Skip to content

Commit 3b8022f

Browse files
committed
Create branch
1 parent b60478b commit 3b8022f

File tree

4 files changed

+210
-107
lines changed

4 files changed

+210
-107
lines changed

AMLorchestrator.py

Lines changed: 97 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,97 @@
1+
# -*- coding: utf-8 -*-
2+
"""
3+
Created on Wed Mar 27 14:24:06 2024
4+
5+
@author: SMO
6+
When launched, the workflow information is read from an AutmationML file.
7+
If ADDPATH is in the workflow definition, a request is sent to them with the
8+
required information to launch their simulations. (ADDPATH communication is TBD)
9+
When finished, HPC is requested to launch the rest of the workflow.
10+
11+
"""
12+
13+
#%% required modules
14+
from pyautomationml import PyAutomationML
15+
import subprocess
16+
import sys
17+
18+
#%% functions
19+
class HTPorchestrator():
20+
def __init__(self, AMLfile):
21+
#Read AML file and extract selected workflow
22+
AMLojb = PyAutomationML(AMLfile)
23+
WorkflowIE = AMLojb.root.find("./*[@Name='Workflow']")
24+
WorkflowDefinitionIE = WorkflowIE.find("./*[@Name='Workflow_definition']")
25+
self.selected_workflow = HTPorchestrator.get_attribute_from_AML_element(self, WorkflowDefinitionIE, 'Sequence', 'Simulations')
26+
27+
def launch_curl_request(self):
28+
# curl command definition
29+
curl_command = [
30+
"curl",
31+
"-X", "POST",
32+
"-H", "Authorization: Token XXXXX",
33+
"-H", "MachineChoice: bsce81722@nord1.bsc.es",
34+
"-H", "SecToken: YYYYY",
35+
"-H", "Content-Type: multipart/form-data",
36+
"-F", "numNodes=1",
37+
"-F", "name_sim=remote_test",
38+
"-F", "execTime=20",
39+
"-F", "qos=cc_cs",
40+
"-F", "branch=main",
41+
"-F", "document=@C:\\Users\\SMO\\Template.aml",
42+
"https://caelestis.bsc.es/simulations/"
43+
]
44+
45+
completed_process = subprocess.run(curl_command, stdout=subprocess.PIPE, stderr=subprocess.PIPE)
46+
47+
# Get the stdout and stderr
48+
stdout = completed_process.stdout.decode('utf-8')
49+
stderr = completed_process.stderr.decode('utf-8')
50+
51+
print("Standard Output:")
52+
print(stdout)
53+
print("\nStandard Error:")
54+
print(stderr)
55+
56+
def get_attribute_from_AML_element(self, AML, attribute_name, InternalElement_name):
57+
def find_element_by_name(InternalElement, InternalElement_name):
58+
if InternalElement.attrib.get('Name') == InternalElement_name:
59+
return InternalElement
60+
else:
61+
for child in InternalElement.iterchildren():
62+
found_element = find_element_by_name(child, InternalElement_name)
63+
if found_element is not None:
64+
return found_element
65+
return None
66+
# Find the element with the specified name within the AML tree
67+
InternalElement = find_element_by_name(AML, InternalElement_name)
68+
# If InternalElement is found, get the attribute value
69+
if InternalElement is not None:
70+
for atribute in InternalElement.iterchildren():
71+
if atribute.__element__.attrib['Name'] == attribute_name:
72+
attribute_value = atribute.text()
73+
return attribute_value
74+
75+
# If InternalElement is not found, return None
76+
return None
77+
78+
def main():
79+
if len(sys.argv) != 2:
80+
print("Usage: python AMLorchestrator.py workflow_file.aml")
81+
82+
wfile = sys.argv[1]
83+
HTPo = HTPorchestrator(wfile)
84+
85+
ADDPATH_ID = 'ADD'
86+
#%% call ADDPATH in case
87+
if ADDPATH_ID in HTPo.selected_workflow:
88+
#call ADDPATH
89+
print('ADDPATH communication under testing')
90+
#%% call HPC
91+
HTPo.launch_curl_request()
92+
93+
# #%% start application
94+
if __name__ == "__main__":
95+
main()
96+
97+

AMLtool.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@
1818
class AML_GUI_App:
1919
def __init__(self, root):
2020
self.root = root
21-
self.root.title("Checkbox Selection")
21+
self.root.title("AutomationML tool")
2222
# Graphical configuration
2323
#self.root.geometry("600x400")
2424

AutomationML_files/Master.aml

Lines changed: 111 additions & 106 deletions
Original file line numberDiff line numberDiff line change
@@ -1,106 +1,111 @@
1-
<CAEXFile xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://www.dke.de/CAEX" SchemaVersion="3.0" FileName="C:\Users\SMO\OneDrive - ESI Group\Documents\Work\Proyectos\CAELESTIS\02 WP_2\T2.2\ManagingAML\Testing_code\AutomationML_files\Master.aml" xsi:schemaLocation="http://www.dke.de/CAEX CAEX_ClassModel_V.3.0.xsd">
2-
<AdditionalInformation AutomationMLVersion="2.0" />
3-
<AdditionalInformation DocumentVersions="Recommendations" />
4-
<SuperiorStandardVersion>AutomationML 2.10</SuperiorStandardVersion>
5-
<SourceDocumentInformation OriginName="AutomationML Editor" OriginID="916578CA-FE0D-474E-A4FC-9E1719892369" OriginVersion="6.1.7.0" LastWritingDateTime="2023-11-07T14:50:07.2596127+01:00" OriginVendor="AutomationML e.V." OriginVendorURL="www.AutomationML.org" OriginRelease="6.1.7.0" OriginProjectTitle="unspecified" OriginProjectID="unspecified" />
6-
<InstanceHierarchy Name="Workflow">
7-
<Version>0</Version>
8-
<InternalElement Name="Information" ID="0b28cbce-27cf-4e53-aa38-1dbf5819b4eb">
9-
<Attribute Name="Project" AttributeDataType="xs:string">
10-
<Value>CAELESTIS</Value>
11-
</Attribute>
12-
</InternalElement>
13-
<InternalElement Name="Workflows" ID="3dae3160-f7f6-41ea-ba60-a19dfcfc267f" />
14-
</InstanceHierarchy>
15-
<InterfaceClassLib Name="AutomationMLInterfaceClassLib">
16-
<Description>Standard Automation Markup Language Interface Class Library - Part 1 Content extended with Part 3 and Part 4 Content</Description>
17-
<Version>2.2.2</Version>
18-
<InterfaceClass Name="AutomationMLBaseInterface">
19-
<InterfaceClass Name="Order" RefBaseClassPath="AutomationMLBaseInterface">
20-
<Attribute Name="Direction" AttributeDataType="xs:string" />
21-
</InterfaceClass>
22-
<InterfaceClass Name="PortConnector" RefBaseClassPath="AutomationMLBaseInterface" />
23-
<InterfaceClass Name="InterlockingConnector" RefBaseClassPath="AutomationMLBaseInterface" />
24-
<InterfaceClass Name="PPRConnector" RefBaseClassPath="AutomationMLBaseInterface" />
25-
<InterfaceClass Name="ExternalDataConnector" RefBaseClassPath="AutomationMLBaseInterface">
26-
<Attribute Name="refURI" AttributeDataType="xs:anyURI" />
27-
<InterfaceClass Name="COLLADAInterface" RefBaseClassPath="ExternalDataConnector">
28-
<Attribute Name="refType" AttributeDataType="xs:string" />
29-
<Attribute Name="target" AttributeDataType="xs:token" />
30-
</InterfaceClass>
31-
<InterfaceClass Name="PLCopenXMLInterface" RefBaseClassPath="ExternalDataConnector">
32-
<InterfaceClass Name="LogicInterface" RefBaseClassPath="PLCopenXMLInterface">
33-
<InterfaceClass Name="SequencingLogicInterface" RefBaseClassPath="AutomationMLInterfaceClassLib/AutomationMLBaseInterface/ExternalDataConnector/PLCopenXMLInterface/LogicInterface" />
34-
<InterfaceClass Name="BehaviourLogicInterface" RefBaseClassPath="AutomationMLInterfaceClassLib/AutomationMLBaseInterface/ExternalDataConnector/PLCopenXMLInterface/LogicInterface" />
35-
<InterfaceClass Name="SequencingBehaviourLogicInterface" RefBaseClassPath="AutomationMLInterfaceClassLib/AutomationMLBaseInterface/ExternalDataConnector/PLCopenXMLInterface/LogicInterface" />
36-
<InterfaceClass Name="InterlockingLogicInterface" RefBaseClassPath="AutomationMLInterfaceClassLib/AutomationMLBaseInterface/ExternalDataConnector/PLCopenXMLInterface/LogicInterface" />
37-
</InterfaceClass>
38-
<InterfaceClass Name="LogicElementInterface" RefBaseClassPath="PLCopenXMLInterface" />
39-
<InterfaceClass Name="VariableInterface" RefBaseClassPath="PLCopenXMLInterface">
40-
<InterfaceClass Name="InterlockingVariableInterface" RefBaseClassPath="AutomationMLInterfaceClassLib/AutomationMLBaseInterface/ExternalDataConnector/PLCopenXMLInterface/VariableInterface">
41-
<Attribute Name="SafeConditionEquals" AttributeDataType="xs:boolean">
42-
<DefaultValue>true</DefaultValue>
43-
</Attribute>
44-
</InterfaceClass>
45-
</InterfaceClass>
46-
</InterfaceClass>
47-
</InterfaceClass>
48-
<InterfaceClass Name="Communication" RefBaseClassPath="AutomationMLBaseInterface">
49-
<InterfaceClass Name="SignalInterface" RefBaseClassPath="Communication" />
50-
</InterfaceClass>
51-
<InterfaceClass Name="AttachmentInterface" RefBaseClassPath="AutomationMLBaseInterface" />
52-
<InterfaceClass Name="ExternalDataReference" RefBaseClassPath="AutomationMLInterfaceClassLib/AutomationMLBaseInterface" />
53-
</InterfaceClass>
54-
</InterfaceClassLib>
55-
<RoleClassLib Name="AutomationMLBaseRoleClassLib">
56-
<Description>Automation Markup Language Base Role Class Library - Part 1 Content extended with Part 3 and Part 4 Content</Description>
57-
<Version>2.2.2</Version>
58-
<RoleClass Name="AutomationMLBaseRole">
59-
<RoleClass Name="Group" RefBaseClassPath="AutomationMLBaseRole">
60-
<Attribute Name="AssociatedFacet" AttributeDataType="xs:string" />
61-
<RoleClass Name="InterlockingSourceGroup" RefBaseClassPath="Group" />
62-
<RoleClass Name="InterlockingTargetGroup" RefBaseClassPath="Group" />
63-
</RoleClass>
64-
<RoleClass Name="Facet" RefBaseClassPath="AutomationMLBaseRole" />
65-
<RoleClass Name="Port" RefBaseClassPath="AutomationMLBaseRole">
66-
<Attribute Name="Direction" AttributeDataType="xs:string" />
67-
<Attribute Name="Cardinality">
68-
<Attribute Name="MinOccur" AttributeDataType="xs:unsignedInt" />
69-
<Attribute Name="MaxOccur" AttributeDataType="xs:unsignedInt" />
70-
</Attribute>
71-
<Attribute Name="Category" AttributeDataType="xs:string" />
72-
<ExternalInterface Name="ConnectionPoint" ID="9942bd9c-c19d-44e4-a197-11b9edf264e7" RefBaseClassPath="AutomationMLInterfaceClassLib/AutomationMLBaseInterface/PortConnector" />
73-
</RoleClass>
74-
<RoleClass Name="Resource" RefBaseClassPath="AutomationMLBaseRole" />
75-
<RoleClass Name="Product" RefBaseClassPath="AutomationMLBaseRole" />
76-
<RoleClass Name="Process" RefBaseClassPath="AutomationMLBaseRole" />
77-
<RoleClass Name="Structure" RefBaseClassPath="AutomationMLBaseRole">
78-
<RoleClass Name="ProductStructure" RefBaseClassPath="Structure" />
79-
<RoleClass Name="ProcessStructure" RefBaseClassPath="Structure" />
80-
<RoleClass Name="ResourceStructure" RefBaseClassPath="Structure" />
81-
</RoleClass>
82-
<RoleClass Name="PropertySet" RefBaseClassPath="AutomationMLBaseRole" />
83-
<RoleClass Name="Frame" RefBaseClassPath="AutomationMLBaseRole" />
84-
<RoleClass Name="LogicObject" RefBaseClassPath="AutomationMLBaseRole" />
85-
</RoleClass>
86-
</RoleClassLib>
87-
<RoleClassLib Name="CaelestisBaseRoleClassLib">
88-
<Version>0</Version>
89-
<RoleClass Name="CaelestisBaseRole">
90-
<RoleClass Name="Simulation" RefBaseClassPath="CaelestisBaseRoleClassLib/CaelestisBaseRole" />
91-
<RoleClass Name="Sensor" RefBaseClassPath="CaelestisBaseRoleClassLib/CaelestisBaseRole" />
92-
</RoleClass>
93-
</RoleClassLib>
94-
<SystemUnitClassLib Name="WorkflowUnitClass">
95-
<Version>0</Version>
96-
<SystemUnitClass Name="Workflow_Unit" ID="4c8c88cc-1cf8-43cb-8d4b-e4f89155dcd6">
97-
<Attribute Name="ID" AttributeDataType="xs:string" />
98-
</SystemUnitClass>
99-
</SystemUnitClassLib>
100-
<SystemUnitClassLib Name="DoEUnitClass">
101-
<Version>0</Version>
102-
</SystemUnitClassLib>
103-
<SystemUnitClassLib Name="SystemUnitClassLib">
104-
<Version>0</Version>
105-
</SystemUnitClassLib>
106-
</CAEXFile>
1+
<CAEXFile xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://www.dke.de/CAEX" SchemaVersion="3.0" FileName="C:\Users\SMO\OneDrive - ESI Group\Documents\Work\Proyectos\CAELESTIS\02 WP_2\T2.2\ManagingAML\Testing_code\AutomationML_files\Master.aml" xsi:schemaLocation="http://www.dke.de/CAEX CAEX_ClassModel_V.3.0.xsd">
2+
<AdditionalInformation AutomationMLVersion="2.0"/>
3+
<AdditionalInformation DocumentVersions="Recommendations"/>
4+
<SuperiorStandardVersion>AutomationML 2.10</SuperiorStandardVersion>
5+
<SourceDocumentInformation OriginName="AutomationML Editor" OriginID="916578CA-FE0D-474E-A4FC-9E1719892369" OriginVersion="6.1.7.0" LastWritingDateTime="2023-11-07T14:50:07.2596127+01:00" OriginVendor="AutomationML e.V." OriginVendorURL="www.AutomationML.org" OriginRelease="6.1.7.0" OriginProjectTitle="unspecified" OriginProjectID="unspecified"/>
6+
<InstanceHierarchy Name="Workflow">
7+
<Version>0</Version>
8+
<InternalElement Name="Information" ID="0b28cbce-27cf-4e53-aa38-1dbf5819b4eb">
9+
<Attribute Name="Project" AttributeDataType="xs:string">
10+
<Value>CAELESTIS</Value>
11+
</Attribute>
12+
</InternalElement>
13+
<InternalElement Name="Workflows" ID="3dae3160-f7f6-41ea-ba60-a19dfcfc267f">
14+
<Attribute Name="w1" AttributeDataType="xs:string"/>
15+
<InternalElement Name="w1">
16+
<Attribute Name="path" AttributeDataType="xs:string"/>
17+
</InternalElement>
18+
</InternalElement>
19+
</InstanceHierarchy>
20+
<InterfaceClassLib Name="AutomationMLInterfaceClassLib">
21+
<Description>Standard Automation Markup Language Interface Class Library - Part 1 Content extended with Part 3 and Part 4 Content</Description>
22+
<Version>2.2.2</Version>
23+
<InterfaceClass Name="AutomationMLBaseInterface">
24+
<InterfaceClass Name="Order" RefBaseClassPath="AutomationMLBaseInterface">
25+
<Attribute Name="Direction" AttributeDataType="xs:string"/>
26+
</InterfaceClass>
27+
<InterfaceClass Name="PortConnector" RefBaseClassPath="AutomationMLBaseInterface"/>
28+
<InterfaceClass Name="InterlockingConnector" RefBaseClassPath="AutomationMLBaseInterface"/>
29+
<InterfaceClass Name="PPRConnector" RefBaseClassPath="AutomationMLBaseInterface"/>
30+
<InterfaceClass Name="ExternalDataConnector" RefBaseClassPath="AutomationMLBaseInterface">
31+
<Attribute Name="refURI" AttributeDataType="xs:anyURI"/>
32+
<InterfaceClass Name="COLLADAInterface" RefBaseClassPath="ExternalDataConnector">
33+
<Attribute Name="refType" AttributeDataType="xs:string"/>
34+
<Attribute Name="target" AttributeDataType="xs:token"/>
35+
</InterfaceClass>
36+
<InterfaceClass Name="PLCopenXMLInterface" RefBaseClassPath="ExternalDataConnector">
37+
<InterfaceClass Name="LogicInterface" RefBaseClassPath="PLCopenXMLInterface">
38+
<InterfaceClass Name="SequencingLogicInterface" RefBaseClassPath="AutomationMLInterfaceClassLib/AutomationMLBaseInterface/ExternalDataConnector/PLCopenXMLInterface/LogicInterface"/>
39+
<InterfaceClass Name="BehaviourLogicInterface" RefBaseClassPath="AutomationMLInterfaceClassLib/AutomationMLBaseInterface/ExternalDataConnector/PLCopenXMLInterface/LogicInterface"/>
40+
<InterfaceClass Name="SequencingBehaviourLogicInterface" RefBaseClassPath="AutomationMLInterfaceClassLib/AutomationMLBaseInterface/ExternalDataConnector/PLCopenXMLInterface/LogicInterface"/>
41+
<InterfaceClass Name="InterlockingLogicInterface" RefBaseClassPath="AutomationMLInterfaceClassLib/AutomationMLBaseInterface/ExternalDataConnector/PLCopenXMLInterface/LogicInterface"/>
42+
</InterfaceClass>
43+
<InterfaceClass Name="LogicElementInterface" RefBaseClassPath="PLCopenXMLInterface"/>
44+
<InterfaceClass Name="VariableInterface" RefBaseClassPath="PLCopenXMLInterface">
45+
<InterfaceClass Name="InterlockingVariableInterface" RefBaseClassPath="AutomationMLInterfaceClassLib/AutomationMLBaseInterface/ExternalDataConnector/PLCopenXMLInterface/VariableInterface">
46+
<Attribute Name="SafeConditionEquals" AttributeDataType="xs:boolean">
47+
<DefaultValue>true</DefaultValue>
48+
</Attribute>
49+
</InterfaceClass>
50+
</InterfaceClass>
51+
</InterfaceClass>
52+
</InterfaceClass>
53+
<InterfaceClass Name="Communication" RefBaseClassPath="AutomationMLBaseInterface">
54+
<InterfaceClass Name="SignalInterface" RefBaseClassPath="Communication"/>
55+
</InterfaceClass>
56+
<InterfaceClass Name="AttachmentInterface" RefBaseClassPath="AutomationMLBaseInterface"/>
57+
<InterfaceClass Name="ExternalDataReference" RefBaseClassPath="AutomationMLInterfaceClassLib/AutomationMLBaseInterface"/>
58+
</InterfaceClass>
59+
</InterfaceClassLib>
60+
<RoleClassLib Name="AutomationMLBaseRoleClassLib">
61+
<Description>Automation Markup Language Base Role Class Library - Part 1 Content extended with Part 3 and Part 4 Content</Description>
62+
<Version>2.2.2</Version>
63+
<RoleClass Name="AutomationMLBaseRole">
64+
<RoleClass Name="Group" RefBaseClassPath="AutomationMLBaseRole">
65+
<Attribute Name="AssociatedFacet" AttributeDataType="xs:string"/>
66+
<RoleClass Name="InterlockingSourceGroup" RefBaseClassPath="Group"/>
67+
<RoleClass Name="InterlockingTargetGroup" RefBaseClassPath="Group"/>
68+
</RoleClass>
69+
<RoleClass Name="Facet" RefBaseClassPath="AutomationMLBaseRole"/>
70+
<RoleClass Name="Port" RefBaseClassPath="AutomationMLBaseRole">
71+
<Attribute Name="Direction" AttributeDataType="xs:string"/>
72+
<Attribute Name="Cardinality">
73+
<Attribute Name="MinOccur" AttributeDataType="xs:unsignedInt"/>
74+
<Attribute Name="MaxOccur" AttributeDataType="xs:unsignedInt"/>
75+
</Attribute>
76+
<Attribute Name="Category" AttributeDataType="xs:string"/>
77+
<ExternalInterface Name="ConnectionPoint" ID="9942bd9c-c19d-44e4-a197-11b9edf264e7" RefBaseClassPath="AutomationMLInterfaceClassLib/AutomationMLBaseInterface/PortConnector"/>
78+
</RoleClass>
79+
<RoleClass Name="Resource" RefBaseClassPath="AutomationMLBaseRole"/>
80+
<RoleClass Name="Product" RefBaseClassPath="AutomationMLBaseRole"/>
81+
<RoleClass Name="Process" RefBaseClassPath="AutomationMLBaseRole"/>
82+
<RoleClass Name="Structure" RefBaseClassPath="AutomationMLBaseRole">
83+
<RoleClass Name="ProductStructure" RefBaseClassPath="Structure"/>
84+
<RoleClass Name="ProcessStructure" RefBaseClassPath="Structure"/>
85+
<RoleClass Name="ResourceStructure" RefBaseClassPath="Structure"/>
86+
</RoleClass>
87+
<RoleClass Name="PropertySet" RefBaseClassPath="AutomationMLBaseRole"/>
88+
<RoleClass Name="Frame" RefBaseClassPath="AutomationMLBaseRole"/>
89+
<RoleClass Name="LogicObject" RefBaseClassPath="AutomationMLBaseRole"/>
90+
</RoleClass>
91+
</RoleClassLib>
92+
<RoleClassLib Name="CaelestisBaseRoleClassLib">
93+
<Version>0</Version>
94+
<RoleClass Name="CaelestisBaseRole">
95+
<RoleClass Name="Simulation" RefBaseClassPath="CaelestisBaseRoleClassLib/CaelestisBaseRole"/>
96+
<RoleClass Name="Sensor" RefBaseClassPath="CaelestisBaseRoleClassLib/CaelestisBaseRole"/>
97+
</RoleClass>
98+
</RoleClassLib>
99+
<SystemUnitClassLib Name="WorkflowUnitClass">
100+
<Version>0</Version>
101+
<SystemUnitClass Name="Workflow_Unit" ID="4c8c88cc-1cf8-43cb-8d4b-e4f89155dcd6">
102+
<Attribute Name="ID" AttributeDataType="xs:string"/>
103+
</SystemUnitClass>
104+
</SystemUnitClassLib>
105+
<SystemUnitClassLib Name="DoEUnitClass">
106+
<Version>0</Version>
107+
</SystemUnitClassLib>
108+
<SystemUnitClassLib Name="SystemUnitClassLib">
109+
<Version>0</Version>
110+
</SystemUnitClassLib>
111+
</CAEXFile>

src/W_IDs.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
1

0 commit comments

Comments
 (0)