From 025277d5a6a622e194c11147defb0329f169cfba Mon Sep 17 00:00:00 2001 From: YuviPanda Date: Sun, 8 Dec 2024 00:22:51 -0800 Subject: [PATCH 1/3] Use self.log.warning instead of warnings.warn warnings.warn sidesteps all the json logging bits we do, and repo2docker will produce non-json output that binderhub then struggles to consume. --- repo2docker/app.py | 2 +- repo2docker/buildpacks/conda/__init__.py | 2 +- repo2docker/utils.py | 3 +-- 3 files changed, 3 insertions(+), 4 deletions(-) diff --git a/repo2docker/app.py b/repo2docker/app.py index 71171405d..5feba05a6 100755 --- a/repo2docker/app.py +++ b/repo2docker/app.py @@ -267,7 +267,7 @@ def _platform_default(self): """ p = get_platform() if p == "linux/arm64": - warnings.warn( + self.log.warning( "Building for linux/arm64 is experimental. " "To use the recommended platform set --Repo2Docker.platform=linux/amd64. " "To silence this warning set --Repo2Docker.platform=linux/arm64." diff --git a/repo2docker/buildpacks/conda/__init__.py b/repo2docker/buildpacks/conda/__init__.py index 2a3e694df..a9c6670ec 100644 --- a/repo2docker/buildpacks/conda/__init__.py +++ b/repo2docker/buildpacks/conda/__init__.py @@ -355,7 +355,7 @@ def uses_r(self): @property def py2(self): """Am I building a Python 2 kernel environment?""" - warnings.warn( + self.log.warning( "CondaBuildPack.py2 is deprecated in 2023.2. Use CondaBuildPack.separate_kernel_env.", DeprecationWarning, stacklevel=2, diff --git a/repo2docker/utils.py b/repo2docker/utils.py index 9c2769e1d..443db97e2 100644 --- a/repo2docker/utils.py +++ b/repo2docker/utils.py @@ -543,5 +543,4 @@ def get_platform(): # OSX reports arm64 return "linux/arm64" else: - warnings.warn(f"Unexpected platform '{m}', defaulting to linux/amd64") - return "linux/amd64" + raise ValueError("Unsupported platform {m}") From 29ee4c314eae002f1e49cfa5106244fee9a26a14 Mon Sep 17 00:00:00 2001 From: YuviPanda Date: Fri, 20 Dec 2024 17:20:24 -0800 Subject: [PATCH 2/3] Re-add warnings usage in one place This actually seems appropriate --- repo2docker/utils.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/repo2docker/utils.py b/repo2docker/utils.py index 443db97e2..9c2769e1d 100644 --- a/repo2docker/utils.py +++ b/repo2docker/utils.py @@ -543,4 +543,5 @@ def get_platform(): # OSX reports arm64 return "linux/arm64" else: - raise ValueError("Unsupported platform {m}") + warnings.warn(f"Unexpected platform '{m}', defaulting to linux/amd64") + return "linux/amd64" From 9d5084a2fe8f3a0419b430ce61f65c9e995fe187 Mon Sep 17 00:00:00 2001 From: YuviPanda Date: Sat, 21 Dec 2024 10:52:55 -0800 Subject: [PATCH 3/3] Remove unused imports --- repo2docker/app.py | 1 - repo2docker/buildpacks/conda/__init__.py | 1 - 2 files changed, 2 deletions(-) diff --git a/repo2docker/app.py b/repo2docker/app.py index 5feba05a6..a2a9a92d6 100755 --- a/repo2docker/app.py +++ b/repo2docker/app.py @@ -16,7 +16,6 @@ import sys import tempfile import time -import warnings from urllib.parse import urlparse import entrypoints diff --git a/repo2docker/buildpacks/conda/__init__.py b/repo2docker/buildpacks/conda/__init__.py index a9c6670ec..57f5d2abe 100644 --- a/repo2docker/buildpacks/conda/__init__.py +++ b/repo2docker/buildpacks/conda/__init__.py @@ -2,7 +2,6 @@ import os import re -import warnings from collections.abc import Mapping from functools import lru_cache