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

Cylc cli runN fix #4228

Merged
merged 4 commits into from
May 26, 2021
Merged

Cylc cli runN fix #4228

merged 4 commits into from
May 26, 2021

Conversation

datamel
Copy link
Contributor

@datamel datamel commented May 25, 2021

This fixes a bug whereby if using runN on the cli, the flow name is not correctly mapped to the actual run number.

To reproduce the bug..
Have an installed workflow, myflow/runN which maps to e.g. myflow/run1
start a workflow off cylc play myflow/runN
stop the workflow cylc stop myflow/run1 --now --now
a cylc scan should confirm the workflow is still running - since the workflow was started with myflow/runN, this is used rather than myflow/run1 as the registered workflow name.

This is a small change with no associated Issue.

  • I have read CONTRIBUTING.md and added my name as a Code Contributor.
  • Contains logically grouped changes (else tidy your branch by rebase).
  • Does not contain off-topic changes (use other PRs for other changes).
  • Applied any dependency changes to both setup.py and
    conda-environment.yml.
  • Appropriate tests are included (unit and/or functional).
  • Appropriate change log entry included.
  • No documentation update required.

@datamel datamel added this to the cylc-8.0b2 milestone May 25, 2021
@datamel datamel self-assigned this May 25, 2021
@hjoliver
Copy link
Member

Good spot @datamel, I hadn't noticed this bug.

r'(?:run)(\d*$)',
os.readlink(workflow_dir)).group(1)
# importing here to counter circular dependancy errors.
from cylc.flow.workflow_files import WorkflowFiles
Copy link
Member

Choose a reason for hiding this comment

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

Oh really, workflow_files imports from here? or is it more indirect?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yes, more indirect. Circle of dependencies can be seen pulling the import to the top... something like scripts/__init__ => terminal => workflow_files => remote => options_parser => terminal .
I'm just pushing a change to fix this, rather than leaving the import at time of use.

Copy link
Member

@dwsutherland dwsutherland left a comment

Choose a reason for hiding this comment

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

LGTM .. Reproduced bug, and this branch fixed it:
image

workflow_dir = get_workflow_run_dir(arg)
else:
workflow_dir = arg
run_number = re.search( #type: ignore
Copy link
Contributor Author

Choose a reason for hiding this comment

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

I think this is ok ignoring this mypy...
Unless I am missing something, as far as I can see, mypy thinks that re.search could return none, and therefore can not have group(1) applied. This is called on condition that the arg ends in runN (or runN/) and so should never return none when the symlink is followed.

Copy link
Member

Choose a reason for hiding this comment

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

Shouldn't happen but is technically possible, could add an if statement to handle this case.

@datamel datamel requested a review from oliver-sanders May 26, 2021 12:41
Comment on lines +237 to +241
endings = (WorkflowFiles.RUN_N, f'{WorkflowFiles.RUN_N}/')
args = [
parse_reg(cli_arg) if cli_arg.endswith(endings)
else cli_arg for cli_arg in args
]
Copy link
Member

@oliver-sanders oliver-sanders May 26, 2021

Choose a reason for hiding this comment

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

I'm not very keen on doing this to CLI args arbitrarily, however, the parsing of the registration argument is not properly centralised at the moment so there isn't really anywhere better to put it.

Adding a note to #4230 (comment) as we should be getting onto that shortly so can leave until then.

@oliver-sanders oliver-sanders added the bug Something is wrong :( label May 26, 2021
Copy link
Member

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

👍

@hjoliver hjoliver merged commit 114fa89 into cylc:master May 26, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something is wrong :(
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants