Skip to content

Update Runway status codes depending on exit code from provided Runway script

Oliver Baldwin Edwards requested to merge oliver-add-status-code-checking into main

Purpose

To make Runway's status codes smarter. Before this MR, Runway would return a status code of 0 if a script ran without crashing and burning. However, if the script returned an exit code of 1, Runway would not catch this and still return a Runway status code of 0. This MR makes Runway smarter by checking what the exit code of the Runway script in question is. This MR also adds some clearer logging (see example outputs below) as well as color 🌈 to the terminal (if :dev-mode? is true).

Related PRs

https://github.com/sig-gis/triangulum/pull/100 Adds a new sh-with-exec function so that we are able to see what the exit code of the script being ran is.

Example outputs

Example output when the Runway script returns with a status code of 0. For context, please note that this Runway script is essentially just a glorified script runner for a Python script (which is why a second script is run).

clojure -M:run -c ../runway-scripts/pyrecast/dev/dps.edn
runway: server-ize a command line tool and let it strut its stuff
Copyright © 2022 Spatial Informatics Group, LLC.

12/27 17:04:07 Running server on port 1339.
12/27 17:04:40 Received Request: {"jobId": 1, "scriptArgs": {"dpsInputArgs": {"fireName": "Test 123", "ignitionTime":"2022-12-20 06:
00 UTC"}}}
12/27 17:04:40 -> Queue addition status: [INFO] You are number 1 in the queue.
12/27 17:04:40 Processing Request: {:job-id 1, :script-args {:dps-input-args {:fire-name "Test 123", :ignition-time "2022-12-20 06:0
0 UTC"}}}
12/27 17:04:40 -> Running command: ./dps.clj `{:fire-name "Test 123", :ignition-time "2022-12-20 06:00 UTC"}`
12/27 17:04:41 -> Server action status: [DONE]
╔══════════════════════════════╗
║        Standard Output       ║
╚══════════════════════════════╝
Running: ./home/oliver/sig-gis/runway-scripts/pyrecast/dev/fuel_wx_ign_cli.py --name='Test 123' --ignition_time='2022-12-20 06:00 UTC'
Standard Output from fuel_wx_ign_cli.py:
name Test 123
ignition_time 2022-12-20 06:00 UTC
center_lat None
center_lon None
west_buffer 30000.0
east_buffer 30000.0
south_buffer 30000.0
north_buffer 30000.0
do_fuel True
fuel_source landfire
fuel_version 2.2.0
do_wx True
wx_type forecast
wx_start_time None
wx_num_hours 24
do_ignition True
point_ignition True
ignition_lat None
ignition_lon None
polygon_ignition False
active_fire_timestamp null
already_burned_timestamp null
ignition_radius 300.0
lfmdate None
transfer_mode wget

Standard Error from fuel_wx_ign_cli.py:

Exit code from fuel_wx_ign_cli.py: 0

╔══════════════════════════════╗
║        Standard Error        ║
╚══════════════════════════════╝

╔══════════════════════════════╗
║           Exit Code          ║
╚══════════════════════════════╝
0

Example Runway output when the script in question returns with a code of 1 (in this case because of a missing required ignition-time argument):

clojure -M:run -c ../runway-scripts/pyrecast/dev/dps.edn
runway: server-ize a command line tool and let it strut its stuff
Copyright © 2022 Spatial Informatics Group, LLC.

12/27 17:06:24 Running server on port 1339.
12/27 17:06:35 Received Request: {"jobId": 1, "scriptArgs": {"dpsInputArgs": {"fireName": "Test 123"}}}
12/27 17:06:35 -> Queue addition status: [INFO] You are number 1 in the queue.
12/27 17:06:35 Processing Request: {:job-id 1, :script-args {:dps-input-args {:fire-name "Test 123"}}}
12/27 17:06:35 -> Running command: ./dps.clj `{:fire-name "Test 123"}`
12/27 17:06:35 -> Server action status: [ERROR]
╔══════════════════════════════╗
║       Standard Output        ║
╚══════════════════════════════╝

╔══════════════════════════════╗
║        Standard Error        ║
╚══════════════════════════════╝
The fireName and ignitionTime arguments are required.

╔══════════════════════════════╗
║          Exit Code           ║
╚══════════════════════════════╝
1

Screenshots

Color was added using https://github.com/trhura/clojure-term-colors

Screenshot_from_2022-12-27_17-48-31

Edited by Oliver Baldwin Edwards

Merge request reports

Loading