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

Control astro dev Output with --verbosity Flag #1770

Merged
merged 12 commits into from
Jan 16, 2025

Conversation

schnie
Copy link
Member

@schnie schnie commented Dec 19, 2024

Description

This PR cleans up the output on the astro dev start/stop/kill/restart commands. Today these commands output a lot of information that is mostly meaningless or unhelpful, distracting from the experience. A new user whose just downloaded the CLI should be focused on getting something running in Airflow, not thinking about containers and docker, etc yet.

In this PR, we've suppressed the Image Build and Compose output for standard usage without any additional flags. This provides a nice, clean output with information about what's happening, but not every single detail. We're re-using the spinner we introduced recently for the runtime initialization messaging.

If users are interested in the full output, we've moved it behind the --verbosity (debug|trace) flag. For example, if you are troubleshooting something deep in the stack for some reason astro dev start --verbosity debug will show the output, just as it did before this change.

If the build phase encounters an error, which is probably a somewhat common occurrence in the wild, the stdout and stderr streams will be printed out, along with the error message.

🎟 Issue(s)

Related to https://github.com/astronomer/astro/issues/26133

🧪 Functional Testing

List the functional testing steps to confirm this feature or fix.

📸 Screenshots

Default experience

Screenshot 2024-12-20 at 2 11 46 PM

--verbosity debug|trace experience

Screenshot 2024-12-20 at 2 12 00 PM

Error on Build Default Experience

Screenshot 2024-12-20 at 2 22 59 PM

📋 Checklist

  • Rebased from the main (or release if patching) branch (before testing)
  • Ran make test before taking out of draft
  • Ran make lint before taking out of draft
  • Added/updated applicable tests
  • Tested against Astro-API (if necessary).
  • Tested against Houston-API and Astronomer (if necessary).
  • Communicated to/tagged owners of respective clients potentially impacted by these changes.
  • Updated any related documentation

@schnie schnie force-pushed the feature/minimize-default-dev-output branch 4 times, most recently from dd00790 to bd1590d Compare December 20, 2024 04:25
@schnie schnie force-pushed the feature/minimize-default-dev-output branch from bd1590d to 4896922 Compare December 20, 2024 16:11
@schnie schnie force-pushed the feature/minimize-default-dev-output branch from b295a68 to 6fa7960 Compare December 20, 2024 18:47
Comment on lines -197 to -212
// Get project containers
psInfo, err := d.composeService.Ps(context.Background(), d.projectName, api.PsOptions{
All: true,
})
if err != nil {
return errors.Wrap(err, composeCreateErrMsg)
}
if len(psInfo) > 0 {
// Ensure project is not already running
for i := range psInfo {
if checkServiceState(psInfo[i].State, dockerStateUp) {
return errors.New("cannot start, project already running")
}
}
}

Copy link
Member Author

Choose a reason for hiding this comment

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

It doesn't seem necessary to throw an error if the project is already started. Let's just make sure the image is updated and started, then re-print the status info.

@schnie schnie changed the title Hides most build and start output behind verbosity level Minimize astro dev Output with --verbosity Flag Dec 20, 2024
@schnie schnie changed the title Minimize astro dev Output with --verbosity Flag Control astro dev Output with --verbosity Flag Dec 20, 2024
@schnie schnie force-pushed the feature/minimize-default-dev-output branch from ca69f47 to 9e815ff Compare December 20, 2024 19:18
@schnie schnie force-pushed the feature/minimize-default-dev-output branch from 9e815ff to 0250f96 Compare December 20, 2024 19:43
@schnie schnie marked this pull request as ready for review January 12, 2025 17:48
@schnie schnie requested a review from pritt20 January 12, 2025 17:49
Copy link
Contributor

@jeremybeard jeremybeard left a comment

Choose a reason for hiding this comment

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

Very nice UX improvement! Approving ahead of some small comments.

@@ -279,6 +291,8 @@ func (d *DockerCompose) Start(imageName, settingsFile, composeFile, buildSecretS
return err
}

spinner.StopWithCheckmark(s, "Project has been started")
Copy link
Contributor

Choose a reason for hiding this comment

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

Happy to defer to others with more technical prose expertise but "has been" feels a bit redundant to me, would have expected just "Project started", and similarly for others below. I'd call this a nitpick but it becomes a prominent part of the CLI output now we're hiding so much low-level cruft.

}

func (d *DockerImage) Pytest(pytestFile, airflowHome, envFile, testHomeDirectory string, pytestArgs []string, htmlReport bool, buildConfig airflowTypes.ImageBuildConfig) (string, error) {
// Determine if we should output to terminal or buffer.
output := logger.GetLevel() >= logrus.DebugLevel
Copy link
Contributor

Choose a reason for hiding this comment

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

We could add logger.IsLevelEnabled to pkg/logger and just call that from the if statements?


registryAuthSuccessMsg = "\nSuccessfully authenticated to Astronomer"
registryAuthSuccessMsg = "Successfully authenticated to Astronomer"
Copy link
Contributor

Choose a reason for hiding this comment

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

Thanks for cleaning up these confusing "\n... lines!

Copy link
Contributor

@pritt20 pritt20 left a comment

Choose a reason for hiding this comment

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

Thanks for these changes @schnie !! 🚀

Comment on lines 63 to 65
func IsLevelEnabled() bool {
return GetLevel() >= logrus.DebugLevel
}
Copy link
Member Author

Choose a reason for hiding this comment

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

@pritt20 what do you think about making the level a parameter here, so we could use it elsewhere to check the level? Maybe we'd want to rename to IsLevelAbove() or something. It just wasn't clear to me what this function name would be doing without a parameter passed to it. Or we could just name this function like IsAboveDebugLevel() and leave as-is. Curious what you think.

Copy link
Contributor

Choose a reason for hiding this comment

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

Thanks @schnie !

I think it makes sense to convert this function to be more generic by accepting level as parameter. This would make this function flexible and more reusable across board.

I've made the required changes now.

Copy link
Contributor

Choose a reason for hiding this comment

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

Can we just pass it on to the logrus IsLevelEnabled?

Copy link
Contributor

Choose a reason for hiding this comment

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

Thanks for pointing out @jeremybeard ! I've made the above changes.

@pritt20 pritt20 merged commit a2a4c12 into main Jan 16, 2025
5 checks passed
@pritt20 pritt20 deleted the feature/minimize-default-dev-output branch January 16, 2025 17:03
neel-astro pushed a commit that referenced this pull request Jan 21, 2025
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