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

Fix bugs in cylc broadcast #5933

Merged
merged 4 commits into from
Jan 24, 2024
Merged

Fix bugs in cylc broadcast #5933

merged 4 commits into from
Jan 24, 2024

Conversation

MetRonnie
Copy link
Member

@MetRonnie MetRonnie commented Jan 18, 2024

  • Fix traceback when using cylc broadcast --file with a relative filepath
  • Fix bug where everything after a # character in a broadcast string setting (e.g. the script setting) would be stripped out - edit runtime strips characters after # #5932

Check List

  • 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).
  • No dependency changes
  • Tests are included (or explain why tests are not needed).
  • CHANGES.md entry included if this is a change that can affect users
  • No docs update needed
  • If this is a bug fix, PR should be raised against the relevant ?.?.x branch.

@MetRonnie MetRonnie added the bug label Jan 18, 2024
@MetRonnie MetRonnie added this to the cylc-8.2.5 milestone Jan 18, 2024
@MetRonnie MetRonnie self-assigned this Jan 18, 2024
Everything after `#` in a setting was getting stripped out
cylc/flow/parsec/validate.py Outdated Show resolved Hide resolved
Copy link
Member

@wxtim wxtim left a comment

Choose a reason for hiding this comment

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

  • Tried it before and after - looks like it fixes both bugs.
  • Read the code. Made comments, but neither is critical.

Comment on lines 1155 to 1156
if isinstance(value, str) and '#' in value:
value = f'"{value}"'
Copy link
Member

Choose a reason for hiding this comment

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

This doesn't work if the string is already quoted e.g:

$ cylc broadcast one -n root -s 'script="sleep 30 # ja!"'
ERROR: [{'error': {'message': '(type=string) script = ""sleep 30 # ja!""', 'traceback': ['graphql.error.located_error.GraphQLLocatedError: (type=string) script = ""sleep 30 # ja!""\n']}}]

Maybe use shlex.quote which has logic to avoid surplus quoting.

Copy link
Member Author

Choose a reason for hiding this comment

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

shlex.quote messes with the quotes inside which we don't want. I've come up with a less hacky approach

Comment on lines +1159 to +1161
val = ParsecValidator._unquote(keys, value) or value
return dedent(val).strip()
Copy link
Member

Choose a reason for hiding this comment

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

Should the dedent/strip happen before the _unquote?

If not, wouldn't 'foo' end up as " 'foo' "?

Copy link
Member Author

Choose a reason for hiding this comment

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

This stripping is for the stuff inside the quotes, and this is the same as it was before this PR. I've tested

  • cylc broadcast -s 'script = "foo" '
  • cylc broadcast -s 'script = foo '

and both set script=foo

Comment on lines +1148 to +1150
@classmethod
def coerce_str(cls, value, keys) -> str:
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
@classmethod
def coerce_str(cls, value, keys) -> str:
@staticmethod
def coerce_str(value, keys) -> str:

Copy link
Member Author

Choose a reason for hiding this comment

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

This is overriding a class method from ParsecValidator

@oliver-sanders oliver-sanders merged commit f4e2853 into cylc:8.2.x Jan 24, 2024
25 checks passed
@MetRonnie MetRonnie deleted the broadcast branch January 24, 2024 11:07
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

edit runtime strips characters after #
3 participants