diff --git a/tagging/utils/docker_runner.py b/tagging/utils/docker_runner.py index 371f525b..47c3ceca 100644 --- a/tagging/utils/docker_runner.py +++ b/tagging/utils/docker_runner.py @@ -22,11 +22,10 @@ class DockerRunner: 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} self.container = self.docker_client.containers.run( - image=self.image_name, - command=self.command, - detach=True, + image=self.image_name, command=self.command, **default_kwargs ) LOGGER.info(f"Container {self.container.name} created") return self.container @@ -48,6 +47,6 @@ class DockerRunner: 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}") assert exec_result.exit_code == 0, f"Command: `{cmd}` failed" return output diff --git a/tests/conftest.py b/tests/conftest.py index 44d2b6a3..d102ffeb 100644 --- a/tests/conftest.py +++ b/tests/conftest.py @@ -29,7 +29,7 @@ def http_client() -> requests.Session: def docker_client() -> docker.DockerClient: """Docker client configured based on the host environment""" client = docker.from_env() - LOGGER.info(f"Docker client created: {client.version()}") + LOGGER.debug(f"Docker client created: {client.version()}") return client diff --git a/tests/pytest.ini b/tests/pytest.ini index 49f609a8..11eec270 100644 --- a/tests/pytest.ini +++ b/tests/pytest.ini @@ -1,7 +1,7 @@ [pytest] addopts = -ra --color=yes log_cli = 1 -log_cli_level = DEBUG +log_cli_level = INFO log_cli_format = %(asctime)s [%(levelname)8s] %(message)s (%(filename)s:%(lineno)s) log_cli_date_format=%Y-%m-%d %H:%M:%S markers = diff --git a/tests/utils/conda_package_helper.py b/tests/utils/conda_package_helper.py index 92a72397..e2f2b740 100644 --- a/tests/utils/conda_package_helper.py +++ b/tests/utils/conda_package_helper.py @@ -41,8 +41,6 @@ class CondaPackageHelper: def __init__(self, container: TrackedContainer): self.container = container - - LOGGER.info(f"Starting container {self.container.image_name} ...") self.container.run_detached(command=["bash", "-c", "sleep infinity"]) self.requested: dict[str, set[str]] | None = None @@ -101,7 +99,7 @@ class CondaPackageHelper: ) # 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") ) return self.available diff --git a/tests/utils/tracked_container.py b/tests/utils/tracked_container.py index d9ca627a..d87f4d36 100644 --- a/tests/utils/tracked_container.py +++ b/tests/utils/tracked_container.py @@ -44,12 +44,15 @@ class TrackedContainer: Keyword arguments to pass to docker.DockerClient.containers.run extending and/or overriding key/value pairs passed to the constructor """ - LOGGER.info(f"Running {self.image_name} with args {kwargs} ...") + LOGGER.info( + f"Creating a container for the image: {self.image_name} with args: {kwargs} ..." + ) default_kwargs = {"detach": True, "tty": True} final_kwargs = default_kwargs | kwargs self.container = self.docker_client.containers.run( self.image_name, **final_kwargs ) + LOGGER.info(f"Container {self.container.name} created") def get_logs(self) -> str: assert self.container is not None @@ -65,13 +68,14 @@ class TrackedContainer: def exec_cmd(self, cmd: str, **kwargs: Any) -> str: assert self.container is not None container = self.container + LOGGER.info(f"Running cmd: `{cmd}` on container: {container.name}") default_kwargs = {"tty": True} final_kwargs = default_kwargs | kwargs exec_result = container.exec_run(cmd, **final_kwargs) output = exec_result.output.decode().rstrip() assert isinstance(output, str) - LOGGER.info(f"Command output: {output}") + LOGGER.debug(f"Command output: {output}") assert exec_result.exit_code == 0, f"Command: `{cmd}` failed" return output @@ -109,7 +113,7 @@ class TrackedContainer: def remove(self) -> None: """Kills and removes the tracked docker container.""" if self.container is None: - LOGGER.info("No container to remove") + LOGGER.debug("No container to remove") else: LOGGER.info(f"Removing container {self.container.name} ...") self.container.remove(force=True)