Skip to content

Commit

Permalink
Merge pull request #6193 from cylc/8.3.x-sync
Browse files Browse the repository at this point in the history
🤖 Merge 8.3.x-sync into master
  • Loading branch information
oliver-sanders authored Jul 4, 2024
2 parents cc28eb3 + 1af3999 commit abb8d47
Show file tree
Hide file tree
Showing 3 changed files with 57 additions and 22 deletions.
7 changes: 4 additions & 3 deletions cylc/flow/hostuserutil.py
Original file line number Diff line number Diff line change
Expand Up @@ -120,10 +120,11 @@ def _get_host_info(self, target=None):
target = socket.getfqdn()
if (
IS_MAC_OS
and target == (
and target in {
'1.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.'
'0.0.0.0.0.0.ip6.arpa'
)
'0.0.0.0.0.0.ip6.arpa',
'1.0.0.127.in-addr.arpa'
}
):
# Python's socket bindings don't play nicely with mac os
# so by default we get the above ip6.arpa address from
Expand Down
4 changes: 2 additions & 2 deletions cylc/flow/scripts/tui.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
to the GUI.
Press "h" whilst running Tui to bring up the help screen, use the arrow
keys to navigage.
keys to navigate.
"""

Expand Down Expand Up @@ -66,7 +66,7 @@ def get_option_parser() -> COP:
metavar='SEC',
help=(
"Set a timeout for network connections"
" to the running workflow. The default is no timeout."
" to the running workflow. The default is 3 seconds."
" For task messaging connections see"
" site/user config file documentation."
),
Expand Down
68 changes: 51 additions & 17 deletions cylc/flow/tui/updater.py
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,36 @@ def get_default_filters():
}


def set_message(data, workflow_id, message, prefix='Error - '):
"""Set a message to display instead of the workflow contents.
This is for critical errors that mean we are unable to load a workflow.
Args:
data:
The updater data.
workflow_id:
The ID of the workflow to set the error for.
message:
A message string or an Exception instance to use for the error
text. If a string is provided, it may not contain newlines.
prefix:
A string that will be prepended to the message.
"""
if isinstance(message, Exception):
# use the first line of the error message.
message = str(message).splitlines()[0]
for workflow in data['workflows']:
# find the workflow in the data
if workflow['id'] == workflow_id:
# use the _tui_data field to hold the message
workflow['_tui_data'] = (
f'{prefix}{message}'
)
break


class Updater():
"""The bit of Tui which provides the data.
Expand Down Expand Up @@ -266,17 +296,19 @@ async def _update_workflow(self, w_id, client, data):
'id': w_id,
'status': 'stopped',
})
except ClientTimeout:
self._clients[w_id] = None
set_message(
data,
w_id,
'Timeout communicating with workflow.'
' Use "--comms-timeout" to increase the timeout',
)
except (CylcError, ZMQError) as exc:
# something went wrong :(
# remove the client on any error, we'll reconnect next time
self._clients[w_id] = None
for workflow in data['workflows']:
if workflow['id'] == w_id:
workflow['_tui_data'] = (
f'Error - {str(exc).splitlines()[0]}'
)
break

set_message(data, w_id, exc)
else:
# the data arrived, add it to the update
workflow_data = workflow_update['workflows'][0]
Expand All @@ -295,16 +327,18 @@ def _connect(self, data):
timeout=self.client_timeout,
)
except WorkflowStopped:
for workflow in data['workflows']:
if workflow['id'] == w_id:
workflow['_tui_data'] = 'Workflow is not running'
except (ZMQError, ClientError, ClientTimeout) as exc:
for workflow in data['workflows']:
if workflow['id'] == w_id:
workflow['_tui_data'] = (
f'Error - {str(exc).splitlines()[0]}'
)
break
set_message(
data, w_id, 'Workflow is not running', prefix=''
)
except ClientTimeout:
set_message(
data,
w_id,
'Timeout connecting to workflow.'
' Use "--comms-timeout" to increase the timeout',
)
except (ZMQError, ClientError) as exc:
set_message(data, w_id, exc)

async def _scan(self):
"""Scan for workflows on the filesystem."""
Expand Down

0 comments on commit abb8d47

Please sign in to comment.