Skip to content

Commit

Permalink
Decrease verbosity of conda-docker
Browse files Browse the repository at this point in the history
  • Loading branch information
costrouc committed Aug 3, 2022
1 parent 839653f commit 6161679
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 6 deletions.
7 changes: 6 additions & 1 deletion conda_docker/cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ def cli(args):
sys.exit(1)

args = parser.parse_args(args)
init_logging()
init_logging(args.debug)
args.func(args)


Expand Down Expand Up @@ -55,6 +55,11 @@ def init_subcommand_build(subparser):
parser.add_argument(
"-o", "--output", type=str, help="filename for docker image", required=True
)
parser.add_argument(
"--debug",
action="store_true",
help="Enable debug logging",
)
parser.add_argument(
"-s",
"--solver",
Expand Down
12 changes: 9 additions & 3 deletions conda_docker/conda.py
Original file line number Diff line number Diff line change
Expand Up @@ -301,9 +301,9 @@ def fetch_precs(download_dir, precs):
os.path.isfile(package_tarball_full_path)
and md5_files([package_tarball_full_path]) == prec.md5
):
LOGGER.info(f"already have: {prec.fn}")
LOGGER.debug(f"already have: {prec.fn}")
else:
LOGGER.info(f"fetching: {prec.fn}")
LOGGER.debug(f"fetching: {prec.fn}")
download(prec.url, os.path.join(download_dir, prec.fn))

if not os.path.isdir(extracted_package_dir):
Expand Down Expand Up @@ -465,7 +465,9 @@ def chroot_install(
"--prefix",
host_conda_opt,
"--extract-conda-pkgs",
]
],
stdout=subprocess.DEVNULL,
stderr=subprocess.DEVNULL,
)
# now install packages in chroot
env = dict(os.environ)
Expand All @@ -492,6 +494,8 @@ def chroot_install(
],
env=env,
cwd=host_conda_opt,
stdout=subprocess.DEVNULL,
stderr=subprocess.DEVNULL,
)

# clean up hard links
Expand Down Expand Up @@ -593,6 +597,8 @@ def add_conda_layers(
else:
raise ValueError(f"layering strategy not recognized: {layering_strategy}")

LOGGER.info(f"docker image {image.name}:{image.tag} has {len(image.layers)} layers")


def build_docker_environment(
base_image,
Expand Down
4 changes: 2 additions & 2 deletions conda_docker/logging.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import logging


def init_logging(level=logging.INFO):
logging.basicConfig(level=level)
def init_logging(debug: bool = False):
logging.basicConfig(level=logging.DEBUG if debug else logging.INFO)

0 comments on commit 6161679

Please sign in to comment.