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

Unify get-config #4099

Merged
merged 13 commits into from
Mar 24, 2021
Merged

Unify get-config #4099

merged 13 commits into from
Mar 24, 2021

Conversation

MetRonnie
Copy link
Member

@MetRonnie MetRonnie commented Feb 25, 2021

These changes close #4009

  • Unify the get-suite-config and get-site-config commands as config
  • Remove --python option
  • Remove --mark-up option
  • Remove --run-mode option
  • Remove --suite-owner option
  • Remove --tasks and --all-tasks options
  • Remove --print-run-dir option
  • Add --print-hierarchy option

Requirements check-list

  • Probably a good idea to wait for cylc pause #4076 to be merged first
  • 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).
  • Appropriate tests are included (unit and/or functional).
  • Already covered by existing tests.
  • Appropriate change log entry included.
  • (master branch) I have opened a documentation PR at Unify get-config cylc-doc#223.
  • No dependency changes.

@MetRonnie MetRonnie added this to the cylc-8.0.0 milestone Feb 25, 2021
@MetRonnie MetRonnie self-assigned this Feb 25, 2021
@MetRonnie MetRonnie modified the milestones: cylc-8.0.0, cylc-8.0b1 Mar 4, 2021
@MetRonnie MetRonnie marked this pull request as ready for review March 22, 2021 17:50
Copy link
Member

@oliver-sanders oliver-sanders left a comment

Choose a reason for hiding this comment

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

Great, can't wait to have this on master.

Comment on lines 128 to 130
# Note: default handle=sys.stdout, but explicitly setting this interferes
# with pytest capsys:
# https://github.com/pytest-dev/pytest/issues/1132#issuecomment-147506107
Copy link
Member

Choose a reason for hiding this comment

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

I think it's just the default kwarg value that is messing with pytest, could do this:

Suggested change
# Note: default handle=sys.stdout, but explicitly setting this interferes
# with pytest capsys:
# https://github.com/pytest-dev/pytest/issues/1132#issuecomment-147506107
if not handle:
handle = sys.stdout

Copy link
Member Author

Choose a reason for hiding this comment

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

Unfortunately not, in the issue linked in the comment, it says that redefinition of sys.stdout is the problem

Copy link
Member

Choose a reason for hiding this comment

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

This works for me:

import sys


def whatever(handle=None):
    if not handle:
        handle = sys.stdout
    handle.write('hello world')


def test_whatever(capsys):
    whatever()
    assert capsys.readouterr().out == 'hello world'

Copy link
Member Author

Choose a reason for hiding this comment

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

Oh, the same test fails for a different reason in that case. The capsys replacement for sys.stdout is not an instance of StringIO, but doesn't have an attribute .mode, which causes an exception at this point

if not isinstance(handle, StringIO) and 'b' in handle.mode:
msg = msg.encode()

Could instead do?

if hasattr(handle, 'mode') and 'b' in handle.mode:
    msg = msg.encode()

@MetRonnie MetRonnie requested a review from kinow March 24, 2021 10:45
@MetRonnie
Copy link
Member Author

Note: if this doesn't get merged in time for 8.0b0, will need to edit the changelog

Copy link
Member

@kinow kinow left a comment

Choose a reason for hiding this comment

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

Looks good to me 👍

Copy link
Member

@oliver-sanders oliver-sanders left a comment

Choose a reason for hiding this comment

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

Great.

@oliver-sanders oliver-sanders modified the milestones: cylc-8.0b1, cylc-8.0b0 Mar 24, 2021
@oliver-sanders oliver-sanders merged commit af9a32a into cylc:master Mar 24, 2021
@oliver-sanders oliver-sanders mentioned this pull request Mar 24, 2021
7 tasks
@MetRonnie MetRonnie deleted the unify-get-config branch March 25, 2021 09:53
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.

get-config: unify commands
3 participants