From 1ae5a20a29cfe3f6c31aed43b9e75b7425cf0a20 Mon Sep 17 00:00:00 2001 From: YuviPanda Date: Sun, 8 Dec 2024 00:22:51 -0800 Subject: [PATCH] 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}")