Skip to content

Commit 34f1d54

Browse files
author
Alan Christie
committed
style: Add debug to API call responses
1 parent e935f0e commit 34f1d54

File tree

1 file changed

+37
-3
lines changed

1 file changed

+37
-3
lines changed

workflow/workflow_engine.py

Lines changed: 37 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -85,7 +85,7 @@ def _handle_workflow_message(self, msg: WorkflowMessage) -> None:
8585
step (or steps) to launch (run) first."""
8686
assert msg
8787

88-
_LOGGER.debug("WorkflowMessage:\n%s", str(msg))
88+
_LOGGER.info("WorkflowMessage:\n%s", str(msg))
8989
assert msg.action in ["START", "STOP"]
9090

9191
r_wfid = msg.running_workflow
@@ -106,14 +106,17 @@ def _handle_workflow_start_message(self, r_wfid: str) -> None:
106106
response, _ = self._wapi_adapter.get_running_workflow(
107107
running_workflow_id=r_wfid
108108
)
109+
_LOGGER.debug(
110+
"API.get_running_workflow(%s) returned: -\n%s", r_wfid, str(response)
111+
)
109112
assert "running_workflow" in response
110113
running_workflow = response["running_workflow"]
111114
assert "user_id" in running_workflow
112115
launching_user_name: str = running_workflow["user_id"]
113-
_LOGGER.debug("RunningWorkflow: %s", running_workflow)
114116
# Now get the workflow definition (to get all the steps)
115117
wfid = running_workflow["workflow"]["id"]
116118
response, _ = self._wapi_adapter.get_workflow(workflow_id=wfid)
119+
_LOGGER.debug("API.get_workflow(%s) returned: -\n%s", wfid, str(response))
117120
assert "workflow" in response
118121
workflow = response["workflow"]
119122

@@ -125,6 +128,12 @@ def _handle_workflow_start_message(self, r_wfid: str) -> None:
125128
running_workflow_id=r_wfid,
126129
step=first_step_name,
127130
)
131+
_LOGGER.debug(
132+
"API.create_running_workflow_step(%s, %s) returned: -\n%s",
133+
r_wfid,
134+
first_step_name,
135+
str(response),
136+
)
128137
assert "id" in response
129138
r_wfsid = response["id"]
130139

@@ -136,6 +145,15 @@ def _handle_workflow_start_message(self, r_wfid: str) -> None:
136145

137146
project_id = running_workflow["project_id"]
138147
variables = running_workflow["variables"]
148+
149+
_LOGGER.info(
150+
"RunningWorkflow: %s (name=%s project=%s, variables=%s)",
151+
r_wfid,
152+
running_workflow["name"],
153+
project_id,
154+
variables,
155+
)
156+
139157
lp: LaunchParameters = LaunchParameters(
140158
project_id=project_id,
141159
application_id=DM_JOB_APPLICATION_ID,
@@ -171,7 +189,7 @@ def _handle_pod_message(self, msg: PodMessage) -> None:
171189
assert msg
172190

173191
# The PodMessage has a 'instance', 'has_exit_code', and 'exit_code' values.
174-
_LOGGER.debug("PodMessage:\n%s", str(msg))
192+
_LOGGER.info("PodMessage:\n%s", str(msg))
175193

176194
# ALL THIS CODE ADDED SIMPLY TO DEMONSTRATE THE USE OF THE API ADAPTER
177195
# AND THE INSTANCE LAUNCHER FOR THE SIMPLEST OF WORKFLOWS: -
@@ -188,10 +206,16 @@ def _handle_pod_message(self, msg: PodMessage) -> None:
188206
instance_id: str = msg.instance
189207
exit_code: int = msg.exit_code
190208
response, _ = self._wapi_adapter.get_instance(instance_id=instance_id)
209+
_LOGGER.debug(
210+
"API.get_instance(%s) returned: -\n%s", instance_id, str(response)
211+
)
191212
r_wfsid: str = response["running_workflow_step"]
192213
response, _ = self._wapi_adapter.get_running_workflow_step(
193214
running_workflow_step_id=r_wfsid
194215
)
216+
_LOGGER.debug(
217+
"API.get_running_workflow_step(%s) returned: -\n%s", r_wfsid, str(response)
218+
)
195219
step_name: str = response["running_workflow_step"]["step"]
196220

197221
# Get the step's running workflow record.
@@ -200,6 +224,9 @@ def _handle_pod_message(self, msg: PodMessage) -> None:
200224
response, _ = self._wapi_adapter.get_running_workflow(
201225
running_workflow_id=r_wfid
202226
)
227+
_LOGGER.debug(
228+
"API.get_running_workflow(%s) returned: -\n%s", r_wfid, str(response)
229+
)
203230

204231
if exit_code:
205232
# The job was launched but it failed.
@@ -219,6 +246,7 @@ def _handle_pod_message(self, msg: PodMessage) -> None:
219246
wfid = running_workflow["workflow"]["id"]
220247
assert wfid
221248
response, _ = self._wapi_adapter.get_workflow(workflow_id=wfid)
249+
_LOGGER.debug("API.get_workflow(%s) returned: -\n%s", wfid, str(response))
222250
workflow = response["workflow"]
223251

224252
# Given the step for the instance just finished (successfully),
@@ -242,6 +270,12 @@ def _handle_pod_message(self, msg: PodMessage) -> None:
242270
running_workflow_id=r_wfid,
243271
step=next_step_name,
244272
)
273+
_LOGGER.debug(
274+
"API.create_running_workflow_step(%s, %s) returned: -\n%s",
275+
r_wfid,
276+
next_step_name,
277+
str(response),
278+
)
245279
assert "id" in response
246280
r_wfsid = response["id"]
247281
project_id = running_workflow["project_id"]

0 commit comments

Comments
 (0)