Skip to content

Commit 386bf79

Browse files
committed
Update demo code to reflect TM changes
Signed-off-by: Victor Chang <[email protected]>
1 parent 8d3bd81 commit 386bf79

File tree

1 file changed

+23
-22
lines changed

1 file changed

+23
-22
lines changed

demos/ig-tm-map/app.py

+23-22
Original file line numberDiff line numberDiff line change
@@ -78,23 +78,25 @@ def _handle_workflow_request(self, properties, method, request_message):
7878
self._send_acknowledgement(method.delivery_tag)
7979
return
8080

81-
workflow_id = str(uuid.uuid4())
82-
output_dir = f"/spleen-output/{workflow_id}"
81+
workflow_instance_id = str(uuid.uuid4())
82+
output_dir = f"spleen-output/{workflow_instance_id}"
8383
task_dispatch = {
84-
"workflow_id": workflow_id,
84+
"workflow_instance_id": workflow_instance_id,
8585
"task_id": str(uuid.uuid4()),
8686
"execution_id": str(uuid.uuid4()),
8787
"correlation_id": correlation_id,
8888
"type": "argo",
89+
"payload_id": request_message['payload_id'],
8990
"task_plugin_arguments": {
90-
"baseUrl": self._config['argo']['baseUrl'],
91-
"workflowTemplateName": request_message['workflows'][0],
92-
"workflowTemplateEntrypoint": request_message['workflows'][1],
93-
"messagingEndpoint": f"{self._config['messaging']['host']}/{self._config['messaging']['virtual_host']}",
94-
"messagingUsername": self._config['messaging']['username'],
95-
"messagingPassword": self._config['messaging']['password'],
96-
"messagingExchange": self._config['messaging']['exchange'],
97-
"messagingTopic": "md.tasks.callback",
91+
"server_url": self._config['argo']['baseUrl'],
92+
"workflow_id": workflow_instance_id,
93+
"workflow_template_name": request_message['workflows'][0],
94+
"messaging_endpoint": f"{self._config['messaging']['host']}",
95+
"messaging_username": self._config['messaging']['username'],
96+
"messaging_password": self._config['messaging']['password'],
97+
"messaging_exchange": self._config['messaging']['exchange'],
98+
"messaging_topic": "md.tasks.callback",
99+
"messaging_vhost": self._config['messaging']['virtual_host'],
98100
},
99101
"inputs": [],
100102
"outputs": []
@@ -106,16 +108,15 @@ def _handle_workflow_request(self, properties, method, request_message):
106108
"endpoint": self._config['storage']['endpoint'],
107109
"bucket": self._config['storage']['bucket'],
108110
"secured_connection": False,
109-
"relative_root_path": f"{request_message['payload_id']}/"
111+
"relative_root_path": f"{request_message['payload_id']}"
110112
})
111-
task_dispatch['outputs'].append(
112-
{
113+
task_dispatch['intermediate_storage'] = {
113114
"name": "tempStorage",
114115
"endpoint": self._config['storage']['endpoint'],
115116
"bucket": self._config['storage']['bucket'],
116117
"secured_connection": False,
117-
"relative_root_path": "/rabbit"
118-
})
118+
"relative_root_path": "rabbit"
119+
}
119120
task_dispatch['outputs'].append(
120121
{
121122
"name": "output",
@@ -125,22 +126,22 @@ def _handle_workflow_request(self, properties, method, request_message):
125126
"relative_root_path": output_dir
126127
})
127128
self._publish(task_dispatch, 'md.tasks.dispatch')
128-
self._output_directories[workflow_id] = output_dir
129+
self._output_directories[workflow_instance_id] = output_dir
129130
self._send_acknowledgement(method.delivery_tag)
130131

131132
def _handle_task_update(self, properties, method, message):
132133

133134
if message['status'] == 'Succeeded':
134-
if message['workflow_id'] not in self._output_directories:
135+
if message['workflow_instance_id'] not in self._output_directories:
135136
self._logger.warn('Unable to send an export request due to missing workflow')
136137
return
137138

138139
export_request = {
139-
"workflow_id": message['workflow_id'],
140+
"workflow_instance_id": message['workflow_instance_id'],
140141
"export_task_id": str(uuid.uuid4()),
141142
"destination": 'ORTHANC',
142143
"correlation_id": message['correlation_id'],
143-
"files": self._list_files(message['workflow_id'])
144+
"files": self._list_files(message['workflow_instance_id'])
144145
}
145146
self._publish(export_request, 'md.export.request.monaiscu')
146147
self._logger.info("==> Export request sent.")
@@ -151,10 +152,10 @@ def _handle_task_update(self, properties, method, message):
151152

152153
self._send_acknowledgement(method.delivery_tag)
153154

154-
def _list_files(self, workflow_id):
155+
def _list_files(self, workflow_instance_id):
155156
objects = self._storage_client.list_objects(
156157
self._config['storage']['bucket'],
157-
prefix=f"/spleen-output/{workflow_id}",
158+
prefix=f"/spleen-output/{workflow_instance_id}",
158159
recursive=True)
159160

160161
files = []

0 commit comments

Comments
 (0)