-
Notifications
You must be signed in to change notification settings - Fork 0
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Refactor workflow_state
xtrig pre-8.3.0-back-compat
#51
Refactor workflow_state
xtrig pre-8.3.0-back-compat
#51
Conversation
a1f7b6c
to
f97f314
Compare
77c44bd
to
960fb61
Compare
outputs_map = json.loads(row[2]) | ||
if is_message: | ||
# task message | ||
try: | ||
outputs = list(outputs_map.values()) | ||
except AttributeError: | ||
# Cylc 8 pre 8.3.0 back-compat: list of output messages | ||
outputs = list(outputs_map) | ||
outputs: Union[Dict[str, str], List[str]] = json.loads(row[2]) | ||
if isinstance(outputs, dict): | ||
messages: Iterable[str] = outputs.values() | ||
else: | ||
# task output | ||
outputs = list(outputs_map) | ||
# Cylc 8 pre 8.3.0 back-compat: list of output messages | ||
messages = outputs | ||
if warn_output_fallback: | ||
LOG.warning(output_fallback_msg) | ||
warn_output_fallback = False |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Clearer distinction between messages and outputs, added warning for 8.0.0-8.3.0 tasks
@@ -52,10 +52,7 @@ cmp_ok "${TEST_NAME}.stderr" - </dev/null | |||
#------------------------------------------------------------------------------- | |||
TEST_NAME="${TEST_NAME_BASE}-section2" | |||
run_ok "${TEST_NAME}" cylc config -d --item=[runtime] "${WORKFLOW_NAME}" | |||
# Crude sorting to handle against change of dict order when new items added: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This output is deterministic and should not be sorted, otherwise we're not checking that settings are in the right sections
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
git blame
says the sorting dates back to 2015. Maybe we weren't using an ordered dict then...
LOG.warning( | ||
"(8.3.0) Deprecated function signature used for " | ||
"workflow_state xtrigger was automatically upgraded. Please " | ||
"alter your workflow to use the new syntax:\n" | ||
f" {old_sig_str} --> {upg_sig_str}" | ||
) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Added deprecation warning, also added grep test in tests/functional/workflow-state/11-multi.t
task_outputs = json.loads(task_outputs) | ||
# BACK COMPAT: In Cylc >8.0.0,<8.3.0, only the task | ||
# messages were stored in the DB as a list. | ||
# from: 8.0.0 | ||
# to: 8.3.0 | ||
outputs: Union[ | ||
Dict[str, str], List[str] | ||
] = json.loads(task_outputs) | ||
messages = ( | ||
outputs.values() if isinstance(outputs, dict) | ||
else outputs | ||
) | ||
return ( | ||
'satisfied from database' | ||
if output in task_outputs | ||
if output_msg in messages | ||
else False | ||
) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Spotted this as well
if flow_nums.intersection(fnums): | ||
for msg in json.loads(outputs_str): | ||
itask.state.outputs.set_message_complete(msg) | ||
self._load_historical_outputs(itask) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ha, good spot.
return _workflow_state_backcompat( | ||
suite, task, point, offset, status, message, cylc_run_dir |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good (I initially did this prior to adding the backcompat function).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nice. Thanks @MetRonnie
Against cylc#5809