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 platform selection bug. #4975

Merged
merged 3 commits into from
Jul 13, 2022

Conversation

wxtim
Copy link
Member

@wxtim wxtim commented Jul 8, 2022

OrderedDictWithDefaults.__getitem__ will get the default, if it exists.
OrderedDictWithDefaults.get does not get the default and was causing
the platform selection to fail quietly and select localhost.

This change closes #4979

Requirements 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).
  • Applied any dependency changes to both setup.cfg and conda-environment.yml.
  • Appropriate tests are included (unit and/or functional).
  • No change log entry required (why? e.g. invisible to users).
  • No documentation update required.

@wxtim wxtim requested review from datamel and oliver-sanders July 8, 2022 15:33
@wxtim wxtim added this to the cylc-8.0.0 milestone Jul 8, 2022
@wxtim wxtim self-assigned this Jul 8, 2022
@wxtim wxtim added the bug Something is wrong :( label Jul 8, 2022
OrderedDictWithDefaults.__getiter__ will get the default, if it exists.
OrderedDictWithDefaults.get does not get the default and was causing
the platform selection to fail quietly and select localhost.
@wxtim wxtim force-pushed the fix.not_getting_platform_from_host branch from a8fa8b6 to e0178f1 Compare July 8, 2022 15:36
tests/unit/test_platforms.py Outdated Show resolved Hide resolved
tests/unit/test_platforms.py Show resolved Hide resolved
@wxtim wxtim requested a review from oliver-sanders July 12, 2022 08:18
Copy link
Contributor

@datamel datamel left a comment

Choose a reason for hiding this comment

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

I have checked this out and verified that it performs as expected. Checked tests also pass locally. Thanks @wxtim.

@datamel datamel merged commit 9f3eb59 into cylc:master Jul 13, 2022
@MetRonnie
Copy link
Member

Why was OrdererdDictWithDefaults.get() not fixed?

@MetRonnie
Copy link
Member

Answer: because we don't want to mess up anything that already relies on the current behaviour.

Note that .get() still works after you've got past the "defaults_ barrier", i.e.

>>> a = OrderedDictWithDefaults()
>>> a.defaults_ =  OrderedDictWithDefaults([('job', OrderedDictWithDefaults([('batch sys', 'pbs')]))])
>>> a.get('job', {})
{}

doesn't work, but this does:

>>> a['job'].get('batch sys', None)
'pbs'

because at that point you're accessing the primary dict of an OrderedDictWithDefaults as opposed to its defaults

@wxtim wxtim deleted the fix.not_getting_platform_from_host branch July 19, 2022 12:24
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.

Localhost selected from old settings which ought to return a non-local platform
4 participants