From a208e00ed28fbcacfcd6f0b680b9c6cf0115d82d Mon Sep 17 00:00:00 2001 From: YuviPanda Date: Sun, 28 Mar 2021 04:07:16 +0530 Subject: [PATCH 1/2] Make etcd3 & python-consul2 soft dependencies Fixes #125 --- jupyterhub_traefik_proxy/consul.py | 5 ++++- jupyterhub_traefik_proxy/etcd.py | 5 ++++- requirements.txt | 2 -- 3 files changed, 8 insertions(+), 4 deletions(-) diff --git a/jupyterhub_traefik_proxy/consul.py b/jupyterhub_traefik_proxy/consul.py index 295821dd..02ec51b3 100644 --- a/jupyterhub_traefik_proxy/consul.py +++ b/jupyterhub_traefik_proxy/consul.py @@ -25,7 +25,6 @@ import base64 import asyncio -import consul.aio import escapism from tornado.concurrent import run_on_executor from traitlets import Any, default, Unicode @@ -56,6 +55,10 @@ def _default_kv_url(self): @default("kv_client") def _default_client(self): + try: + import consul.aio + except ImportError: + raise ImportError("Please install python-consul2 package to use traefik-proxy with consul") consul_service = urlparse(self.kv_url) if self.kv_password: client = consul.aio.Consul( diff --git a/jupyterhub_traefik_proxy/etcd.py b/jupyterhub_traefik_proxy/etcd.py index 7bb84003..92ebcec3 100644 --- a/jupyterhub_traefik_proxy/etcd.py +++ b/jupyterhub_traefik_proxy/etcd.py @@ -23,7 +23,6 @@ import os from urllib.parse import urlparse -import etcd3 from tornado.concurrent import run_on_executor from traitlets import Any, default, Unicode @@ -73,6 +72,10 @@ def _default_kv_url(self): @default("kv_client") def _default_client(self): etcd_service = urlparse(self.kv_url) + try: + import etcd3 + except ImportError: + raise ImportError("Please install etcd3 package to use traefik-proxy with etcd3") if self.kv_password: return etcd3.client( host=str(etcd_service.hostname), diff --git a/requirements.txt b/requirements.txt index 1cfa126c..ccb6dc38 100644 --- a/requirements.txt +++ b/requirements.txt @@ -1,7 +1,5 @@ aiohttp escapism -etcd3 jupyterhub>=0.9 passlib -python-consul2 toml From 7b31ffa67810cc4b29d7efa8089744ca8c5794cf Mon Sep 17 00:00:00 2001 From: YuviPanda Date: Thu, 1 Apr 2021 13:30:42 +0530 Subject: [PATCH 2/2] Install etcd3 & python-consul2 in dev environments Prevents CI from failing --- dev-requirements.txt | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/dev-requirements.txt b/dev-requirements.txt index e820a967..0eae2139 100644 --- a/dev-requirements.txt +++ b/dev-requirements.txt @@ -5,3 +5,7 @@ codecov black notebook>=4.0 websockets +# etcd3 & python-consul2 are now soft dependencies +# Adding them here prevents CI from failing +etcd3 +python-consul2 \ No newline at end of file