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

SNOW-986249-console-output-tools: cli_console for intermediate output #659

Merged
merged 21 commits into from
Feb 7, 2024

Conversation

sfc-gh-mraba
Copy link
Contributor

@sfc-gh-mraba sfc-gh-mraba commented Jan 16, 2024

SNOW-986249

Pre-review checklist

  • I've confirmed that instructions included in README.md are still correct after my changes in the codebase.
  • I've added or updated automated unit tests to verify correctness of my new code.
  • I've added or updated integration tests to verify correctness of my new code.
  • I've confirmed that my changes are working by executing CLI's commands manually.
  • I've confirmed that my changes are up-to-date with the target branch.
  • I've described my changes in the release notes.
  • I've described my changes in the section below.

Changes description

  • snowflake.cli.api.output package introduces snow_cli object for displaying console intermediate output
  • two methods phase and step provide displaying output to console
  • step method for displaying messages to users
  • warning method for displaying important messages to users
  • phase method for grouping messages in distinctive way

@sfc-gh-mraba sfc-gh-mraba force-pushed the SNOW-986249-console-output-tools branch 3 times, most recently from 275a283 to f36855c Compare January 18, 2024 15:59
@sfc-gh-mraba sfc-gh-mraba self-assigned this Jan 18, 2024
@sfc-gh-mraba sfc-gh-mraba force-pushed the SNOW-986249-console-output-tools branch 2 times, most recently from 975b465 to 790c90e Compare January 19, 2024 12:44
@sfc-gh-mraba sfc-gh-mraba changed the title SNOW-986249-console-output-tools: [wip] phase and step functions for … SNOW-986249-console-output-tools: cli_console for intermediate output Jan 19, 2024
@sfc-gh-mraba sfc-gh-mraba marked this pull request as ready for review January 19, 2024 13:50
@sfc-gh-mraba sfc-gh-mraba marked this pull request as draft January 19, 2024 14:03
@sfc-gh-mraba sfc-gh-mraba marked this pull request as ready for review January 19, 2024 14:48
@sfc-gh-mraba sfc-gh-mraba force-pushed the SNOW-986249-console-output-tools branch from 813710e to a3b98b3 Compare January 22, 2024 08:12
Copy link
Contributor

@sfc-gh-bdufour sfc-gh-bdufour left a comment

Choose a reason for hiding this comment

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

Good to see this feature implemented, it will greatly improve the usability of NADE tools.

src/snowflake/cli/api/console/console.py Outdated Show resolved Hide resolved
src/snowflake/cli/api/console/console.py Show resolved Hide resolved
@sfc-gh-mraba sfc-gh-mraba force-pushed the SNOW-986249-console-output-tools branch from a3b98b3 to e52a5e9 Compare January 23, 2024 07:41
@sfc-gh-mraba sfc-gh-mraba force-pushed the SNOW-986249-console-output-tools branch 4 times, most recently from 928ece5 to 055efbd Compare January 25, 2024 09:05
CONTRIBUTING.md Outdated Show resolved Hide resolved
@sfc-gh-mraba sfc-gh-mraba force-pushed the SNOW-986249-console-output-tools branch 4 times, most recently from 3a0eb87 to c768626 Compare January 30, 2024 08:31
@sfc-gh-mraba sfc-gh-mraba force-pushed the SNOW-986249-console-output-tools branch from 35641a8 to 00b2ca4 Compare February 6, 2024 11:19
@sfc-gh-mraba sfc-gh-mraba enabled auto-merge (squash) February 6, 2024 11:25
Copy link
Contributor

@sfc-gh-bdufour sfc-gh-bdufour left a comment

Choose a reason for hiding this comment

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

API looks good, minor comments about docs & tests

src/snowflake/cli/api/console/abc.py Outdated Show resolved Hide resolved
src/snowflake/cli/api/console/abc.py Outdated Show resolved Hide resolved
src/snowflake/cli/api/console/abc.py Outdated Show resolved Hide resolved
src/snowflake/cli/api/console/console.py Outdated Show resolved Hide resolved
src/snowflake/cli/api/console/console.py Outdated Show resolved Hide resolved
def test_step_indented_in_phase(cli_console, capsys):
with cli_console.phase("42"):
cli_console.step("73")
assert_output_matches("42\n 73\n", capsys)
Copy link
Contributor

Choose a reason for hiding this comment

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

nit: for readability, I'd probably modify the helper so that it accepts individual lines instead. For simple examples it's not too bad, but more complex ones are tricky to read quickly.

Copy link
Contributor Author

@sfc-gh-mraba sfc-gh-mraba Feb 6, 2024

Choose a reason for hiding this comment

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

IMO more complex ones should be handled with syrupy snapshots.

@sfc-gh-mraba sfc-gh-mraba force-pushed the SNOW-986249-console-output-tools branch from 6a63c1d to f574219 Compare February 7, 2024 07:32
Comment on lines +188 to +193
with cc.phase("Long sequence of actions"):
cc.step("Phased step 1")
cc.step("Phased step 2")
if something_important:
cc.warning("It's important")
cc.step("Final step")
Copy link
Contributor

Choose a reason for hiding this comment

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

Let's add business logic to this example to show how it should relate with steps and phases. WDYT?

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'll submit update in separate PR 👍

Copy link
Contributor

@sfc-gh-turbaszek sfc-gh-turbaszek left a comment

Choose a reason for hiding this comment

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

LGTM! One small comment

@sfc-gh-mraba sfc-gh-mraba merged commit b89b7fc into main Feb 7, 2024
17 checks passed
@sfc-gh-mraba sfc-gh-mraba deleted the SNOW-986249-console-output-tools branch February 7, 2024 08:19
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.

4 participants