Skip to content
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

Merged

Conversation

MetRonnie
Copy link

@MetRonnie MetRonnie commented May 31, 2024

Against cylc#5809

@MetRonnie MetRonnie force-pushed the workflow-state branch 2 times, most recently from a1f7b6c to f97f314 Compare June 4, 2024 17:27
@hjoliver hjoliver force-pushed the fix-workflow-state-check branch 2 times, most recently from 77c44bd to 960fb61 Compare June 5, 2024 07:00
Comment on lines -282 to +298
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
Copy link
Author

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:
Copy link
Author

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

Copy link
Owner

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...

Comment on lines +395 to +400
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}"
)
Copy link
Author

@MetRonnie MetRonnie Jun 5, 2024

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

Comment on lines -447 to 462
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
)
Copy link
Author

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)
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ha, good spot.

Comment on lines +75 to +76
return _workflow_state_backcompat(
suite, task, point, offset, status, message, cylc_run_dir
Copy link
Owner

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).

Copy link
Owner

@hjoliver hjoliver left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice. Thanks @MetRonnie

@hjoliver hjoliver merged commit 344759f into hjoliver:fix-workflow-state-check Jun 5, 2024
27 checks passed
@MetRonnie MetRonnie deleted the workflow-state branch June 6, 2024 09:19
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants