Skip to content

Improve logs around running docker #2261

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

Merged
merged 1 commit into from
Mar 23, 2025
Merged

Conversation

mathbunnyru
Copy link
Member

Describe your changes

Issue ticket if applicable

Checklist (especially for first-time contributors)

  • I have performed a self-review of my code
  • If it is a core feature, I have added thorough tests
  • I will try not to use force-push to make the review process easier for reviewers
  • I have updated the documentation for significant changes

@@ -22,11 +22,10 @@ def __init__(
self.docker_client: docker.DockerClient = docker_client

def __enter__(self) -> Container:
LOGGER.info(f"Creating container for image {self.image_name} ...")
LOGGER.info(f"Creating a container for the image: {self.image_name} ...")
default_kwargs = {"detach": True, "tty": True}
Copy link
Member Author

Choose a reason for hiding this comment

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

This class is more-or-less like TrackedContainer, so let's have same options here

@@ -48,6 +47,6 @@ def exec_cmd(container: Container, cmd: str) -> str:
exec_result = container.exec_run(cmd)
output = exec_result.output.decode().rstrip()
assert isinstance(output, str)
LOGGER.info(f"Command output: {output}")
LOGGER.debug(f"Command output: {output}")
Copy link
Member Author

Choose a reason for hiding this comment

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

Sometimes the output is huge, and in most cases it is not useful

@@ -1,7 +1,7 @@
[pytest]
addopts = -ra --color=yes
log_cli = 1
log_cli_level = DEBUG
log_cli_level = INFO
Copy link
Member Author

Choose a reason for hiding this comment

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

One can always use DEBUG if needed

@@ -41,8 +41,6 @@ class CondaPackageHelper:

def __init__(self, container: TrackedContainer):
self.container = container

LOGGER.info(f"Starting container {self.container.image_name} ...")
Copy link
Member Author

@mathbunnyru mathbunnyru Mar 23, 2025

Choose a reason for hiding this comment

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

self.container.run_detached is going to log the same thing

@@ -101,7 +99,7 @@ def available_packages(self) -> dict[str, set[str]]:
)
# Keeping command line output since `mamba search --outdated --json` is way too long ...
self.available = CondaPackageHelper._extract_available(
self.container.exec_cmd("mamba search --outdated --quiet")
self.container.exec_cmd("conda search --outdated --quiet")
Copy link
Member Author

Choose a reason for hiding this comment

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

mamba search --outdated --quiet doesn't work at all :(

@mathbunnyru mathbunnyru merged commit bc3baf8 into jupyter:main Mar 23, 2025
96 checks passed
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.

1 participant