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

Improve readability of host/platform eval code #53

Merged
merged 2 commits into from
Apr 13, 2023

Conversation

MetRonnie
Copy link

@MetRonnie MetRonnie commented Mar 17, 2023

cylc#5343

Not added any tests yet

# remove at:
# Cylc8.x
if not command:
if not eval_str:
return 'localhost'

# Host selection command: $(command) or `command`
Copy link
Owner

@wxtim wxtim Mar 20, 2023

Choose a reason for hiding this comment

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

This docstring needs changing - it's no longer just the host, and if it's the platform the pattern shouldn't match `command` .

Because of the way you've generalized the function I'd be happy just deleting it.

return command
return os.path.expandvars(eval_str)

# BACK COMPAT: references to "host"
Copy link
Owner

Choose a reason for hiding this comment

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

Make this part of the eval_host docstring.

Suggest noting that when we remove the back compat layer we re-merge eval_platform and _subshell_eval, else there will be a non purposeful layer of abstraction?

Copy link
Author

Choose a reason for hiding this comment

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

Make this part of the eval_host docstring.

I think it's fine to leave as a comment? It doesn't tell developers how to use the function which is what docstring is primarily for.

Suggest noting that when we remove the back compat layer we re-merge eval_platform and _subshell_eval, else there will be a non purposeful layer of abstraction?

I think that should be fairly self-evident when the time comes

@wxtim
Copy link
Owner

wxtim commented Mar 20, 2023

  • Looks nicely unit testable 👍🏼 !
  • Should contain a note to remove abstraction layer when we stop supporting host.

@wxtim wxtim force-pushed the fix_localhost_platform_matching branch from 9df1a9f to 83484ef Compare March 20, 2023 08:33
@MetRonnie
Copy link
Author

@oliver-sanders can you have a quick look at this as part of cylc#5343?

@oliver-sanders
Copy link

Looks the same.

@MetRonnie
Copy link
Author

Looks the same.

Does that mean it's good to go (with tests added) or it's not any more readable?

@wxtim
Copy link
Owner

wxtim commented Apr 11, 2023

Looks the same.

@oliver-sanders - Do you mean it's Good to merge IYO

@MetRonnie
Copy link
Author

Looks the same.

Does that mean it's good to go (with tests added) or it's not any more readable?

Answer was both!

@wxtim Let me know if you want me to add tests else feel free to undraft + merge

@wxtim wxtim marked this pull request as ready for review April 13, 2023 08:25
@wxtim wxtim merged commit ccdd6cf into wxtim:fix_localhost_platform_matching Apr 13, 2023
@wxtim
Copy link
Owner

wxtim commented Apr 13, 2023

cylc#5462

@MetRonnie MetRonnie deleted the subshell-eval branch April 13, 2023 11:28
wxtim added a commit that referenced this pull request Apr 17, 2023
…gex_remote_tidy_fail

* upstream/8.1.x:
  Update cylc/flow/scripts/message.py
  Upload coverage to Codecov in separate job (cylc#5459)
  upgrade cylc message internal help with details of severity levels
  Update tests/functional/platforms/10-do-not-host-check-platforms.t
  Fix flake8-comprehensions C419 Don't use any([i for i in iterable]) use any(i for i in iterable). It's more efficient because we don't have to expand the entire thing.
  Improve readability of host/platform eval code (#53)
  small changlog error fix
  update comment on localhost check and add test for case localhost4.localhost42
  undo mistake
  clarification of nomenclature
  Avoid running host check on platform names - this doesn't make any sense.
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.

3 participants