From 594b61003f731df80ca1f754d58ef3bb68787996 Mon Sep 17 00:00:00 2001 From: Min RK Date: Thu, 23 Mar 2023 12:30:35 +0100 Subject: [PATCH] add some logging to conda setup --- tljh/conda.py | 13 ++++++++++++- tljh/installer.py | 5 ++++- 2 files changed, 16 insertions(+), 2 deletions(-) diff --git a/tljh/conda.py b/tljh/conda.py index 7aa864a..6f1f9ce 100644 --- a/tljh/conda.py +++ b/tljh/conda.py @@ -6,8 +6,12 @@ import subprocess import json import hashlib import contextlib +import logging import tempfile +import time + import requests + from tljh import utils from tljh.utils import parse_version as V @@ -78,12 +82,19 @@ def download_miniconda_installer(installer_url, sha256sum): of given version, verifies the sha256sum & provides path to it to the `with` block to run. """ + logger = logging.getLogger("tljh") + logger.info(f"Downloading conda installer {installer_url}") with tempfile.NamedTemporaryFile("wb", suffix=".sh") as f: - f.write(requests.get(installer_url).content) + tic = time.perf_counter() + r = requests.get(installer_url) + r.raise_for_status() + f.write(r.content) # Remain in the NamedTemporaryFile context, but flush changes, see: # https://docs.python.org/3/library/os.html#os.fsync f.flush() os.fsync(f.fileno()) + t = time.perf_counter() - tic + logger.info(f"Downloaded conda installer {installer_url} in {t:.1f}s") if sha256_file(f.name) != sha256sum: raise Exception("sha256sum hash mismatch! Downloaded file corrupted") diff --git a/tljh/installer.py b/tljh/installer.py index 52f956c..df94592 100644 --- a/tljh/installer.py +++ b/tljh/installer.py @@ -212,6 +212,9 @@ def ensure_user_environment(user_requirements_txt_file): have_versions = conda.get_mamba_versions(USER_ENV_PREFIX) have_conda_version = have_versions.get("conda") if have_conda_version: + logger.info( + f"Found prefix at {USER_ENV_PREFIX}, with conda/mamba({have_versions})" + ) for check_version, conda_mamba_version in conda_upgrade_versions.items(): if V(have_conda_version) >= V(check_version): found_conda = True @@ -238,7 +241,7 @@ def ensure_user_environment(user_requirements_txt_file): [ # Conda's latest version is on conda much more so than on PyPI. "conda==" + conda_version, - "mamba==" + MAMBAFORGE_MAMBA_VERSION, + "mamba==" + mamba_version, ], )