Skip to content

Commit ed2680f

Browse files
authored
capture exit code (#37)
* capture exit code more attempts at getting timeout test failure reason bump version * update page title
1 parent e808736 commit ed2680f

File tree

10 files changed

+17
-19
lines changed

10 files changed

+17
-19
lines changed

frontend/src/TaskDetail.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ export default class TaskDetail extends React.Component {
3737
API.get(`/api/tasks/${this.props.params.id}/`, (payload, error) => {
3838
let execution = null;
3939
if (payload) {
40-
document.title = `YAWN - Task ${payload.name}`;
40+
document.title = `YAWN - Task: ${payload.name}`;
4141
// keep the currently selected execution, or get the latest
4242
execution = this.state.execution || payload.executions.length;
4343

frontend/src/UserDetail.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ export default class UserDetail extends React.Component {
2020
} else {
2121
API.get(`/api/users/${this.props.params.id}/`, (payload, error) => {
2222
if (payload) {
23-
document.title = `YAWN - User ${payload.username}`;
23+
document.title = `YAWN - User: ${payload.username}`;
2424
}
2525
this.setState({user: payload, error});
2626
});

frontend/src/WorkerDetail.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ export default class WorkerDetail extends React.Component {
1515
this.setState({worker: payload, error});
1616

1717
if (payload) { // only get if worker returns... not strictly necessary
18-
document.title = `YAWN - Worker ${payload.name}`;
18+
document.title = `YAWN - Worker: ${payload.name}`;
1919
API.get(`/api/executions/?worker=${this.props.params.id}`, (payload, error) => {
2020
this.setState({executions: payload, error});
2121
});

frontend/src/WorkerList.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ export default class WorkerList extends React.Component {
2121
if (this.state.workers === null) {
2222
return (
2323
<tr>
24-
<td colSpan="3">Loading...</td>
24+
<td colSpan="4">Loading...</td>
2525
</tr>
2626
)
2727
} else {

frontend/src/WorkflowDetail.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ export default class WorkflowDetail extends React.Component {
2525
loadWorkflow(version) {
2626
API.get(`/api/workflows/${version}/`, (payload, error) => {
2727
if (payload) {
28-
document.title = `YAWN - Workflow ${payload.name}`;
28+
document.title = `YAWN - Workflow: ${payload.name}`;
2929
}
3030
this.setState({workflow: payload, error});
3131
});

frontend/src/tests/__snapshots__/WorkerList.test.js.snap

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ exports[`WorkerList failure 1`] = `
3333
<tbody>
3434
<tr>
3535
<td
36-
colSpan="3"
36+
colSpan="4"
3737
>
3838
Loading...
3939
</td>
@@ -70,7 +70,7 @@ exports[`WorkerList loading 1`] = `
7070
<tbody>
7171
<tr>
7272
<td
73-
colSpan="3"
73+
colSpan="4"
7474
>
7575
Loading...
7676
</td>

setup.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@
2222
# Versions should comply with PEP440. For a discussion on single-sourcing
2323
# the version across setup.py and the project code, see
2424
# https://packaging.python.org/en/latest/single_source_version.html
25-
version='0.2.1',
25+
version='0.2.2',
2626

2727
description='Yet Another Workflow Engine, a subprocess-based DAG execution system',
2828
long_description=long_description,

yawn/task/models.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -181,5 +181,6 @@ def mark_finished(self, exit_code=None, lost=False):
181181
self.task.run.update_status()
182182

183183
self.stop_timestamp = functions.Now()
184+
self.exit_code = exit_code
184185
# need to be careful not to overwrite stdout/stderr
185-
self.save(update_fields=['status', 'stop_timestamp'])
186+
self.save(update_fields=['status', 'stop_timestamp', 'exit_code'])

yawn/worker/executor.py

Lines changed: 6 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ def __init__(self, execution_id):
2525

2626
def __str__(self):
2727
return 'Result(id={}, stdout={}, stderr={}, returncode={})'.format(
28-
self.execution_id, bool(self.stdout), bool(self.stderr), self.returncode)
28+
self.execution_id, self.stdout, self.stderr, self.returncode)
2929

3030

3131
class Execution:
@@ -39,7 +39,7 @@ def __init__(self, process, execution_id, timeout):
3939

4040
def __str__(self):
4141
return 'Result(id={}, stdout={}, stderr={}, returncode={})'.format(
42-
self.id, bool(self.process.stdout), bool(self.process.stderr), self.process.returncode)
42+
self.id, self.process.stdout, self.process.stderr, self.process.returncode)
4343

4444

4545
class Manager:
@@ -71,8 +71,6 @@ def start_subprocess(self, execution_id: int, command: str, environment: dict, t
7171
# all variables must be strings, be explicit so it fail in our code
7272
process_environment[key] = str(value)
7373

74-
logger.info('Starting execution #%s', execution_id)
75-
7674
process = subprocess.Popen(command, stdout=subprocess.PIPE, stderr=subprocess.PIPE,
7775
preexec_fn=os.setpgrp, env=process_environment, shell=True)
7876

@@ -155,14 +153,13 @@ def read_output(self, timeout=0.1) -> typing.List[Result]:
155153
continue # we'll check again later
156154

157155
# we may not have read everything available, so only cleanup after all pipes are closed
158-
open_pipes = {execution.process.stdout.raw, execution.process.stderr.raw
159-
} & set(self.pipes.keys())
156+
open_pipes = (
157+
{execution.process.stdout.raw, execution.process.stderr.raw}
158+
& set(self.pipes.keys())
159+
)
160160
if not open_pipes:
161161
result = all_results.setdefault(execution.id, Result(execution.id))
162162
result.returncode = execution.process.returncode
163-
run_time = time.monotonic() - execution.start_time
164-
logger.info('Execution #%s exited with code %s after %s seconds',
165-
execution.id, result.returncode, run_time)
166163
del self.running[execution.id]
167164

168165
return list(all_results.values())

yawn/worker/main.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ class State(enum.Enum):
2424

2525

2626
class Main:
27-
results = None # type: typing.List[Result]
27+
results = None # type: typing.Deque[Result]
2828
executor = None
2929
state = State.stopped
3030
worker = None

0 commit comments

Comments
 (0)