From bb7ad85b9adbee07d60a0d4cab0a839a2d742f5c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Anders=20Fredrik=20Ki=C3=A6r?= <31612826+anders-kiaer@users.noreply.github.com> Date: Sat, 4 Sep 2021 13:18:31 +0200 Subject: [PATCH] Split dependencies --- .circleci/config.yml | 25 +++++++++++-------- dash/long_callback/managers/celery_manager.py | 16 +++++++++--- .../managers/diskcache_manager.py | 9 ++----- dash/testing/plugin.py | 16 +++++++++--- requires-celery-manager.txt | 2 ++ requires-ci.txt | 13 ++++++++++ requires-dev.txt | 16 +++--------- requires-diskcache-manager.txt | 3 +++ requires-testing.txt | 16 +++--------- setup.py | 2 ++ 10 files changed, 67 insertions(+), 51 deletions(-) create mode 100644 requires-celery-manager.txt create mode 100644 requires-ci.txt create mode 100644 requires-diskcache-manager.txt diff --git a/.circleci/config.yml b/.circleci/config.yml index 3d93deb313..a70d80f20e 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -43,7 +43,9 @@ jobs: sudo pip install virtualenv --upgrade python -m venv venv && . venv/bin/activate set -eo pipefail - pip install -e .[testing,dev] --progress-bar off && pip list | grep dash + pip install -e .[testing,dev,celery-manager,diskcache-manager] --progress-bar off + pip install -r ./requires-ci.txt --progress-bar off + pip list | grep dash npm i npm run build python setup.py sdist @@ -70,15 +72,15 @@ jobs: - checkout - run: echo $PYVERSION > ver.txt - restore_cache: - key: dep-{{ checksum ".circleci/config.yml" }}-{{ checksum "ver.txt" }}-{{ checksum "requires-dev.txt" }}-{{ checksum "requires-install.txt" }}-{{ checksum "requires-testing.txt" }} + key: dep-{{ checksum ".circleci/config.yml" }}-{{ checksum "ver.txt" }}-{{ checksum "requires-ci.txt" }}-{{ checksum "requires-dev.txt" }}-{{ checksum "requires-install.txt" }}-{{ checksum "requires-testing.txt" }} - run: name: ️️🏗️ pip dev requirements command: | sudo pip install --upgrade virtualenv --progress-bar off python -m venv venv || virtualenv venv && . venv/bin/activate - pip install -e . --no-cache-dir -r requires-install.txt -r requires-dev.txt -r requires-testing.txt --progress-bar off + pip install -e .[dev,testing] --no-cache-dir -r requires-ci.txt --progress-bar off - save_cache: - key: dep-{{ checksum ".circleci/config.yml" }}-{{ checksum "ver.txt" }}-{{ checksum "requires-dev.txt" }}-{{ checksum "requires-install.txt" }}-{{ checksum "requires-testing.txt" }} + key: dep-{{ checksum ".circleci/config.yml" }}-{{ checksum "ver.txt" }}-{{ checksum "requires-ci.txt" }}-{{ checksum "requires-dev.txt" }}-{{ checksum "requires-install.txt" }}-{{ checksum "requires-testing.txt" }} paths: - venv - run: @@ -214,7 +216,7 @@ jobs: - checkout - run: echo $PYVERSION > ver.txt - restore_cache: - key: dep-{{ checksum ".circleci/config.yml" }}-{{ checksum "ver.txt" }}-{{ checksum "requires-dev.txt" }}-{{ checksum "requires-install.txt" }}-{{ checksum "requires-testing.txt" }} + key: dep-{{ checksum ".circleci/config.yml" }}-{{ checksum "ver.txt" }}-{{ checksum "requires-ci.txt" }}-{{ checksum "requires-dev.txt" }} - attach_workspace: at: ~/dash - run: @@ -223,7 +225,7 @@ jobs: . venv/bin/activate npm install --production pip install --no-cache-dir --upgrade --ignore-installed dash-package/dash-package.tar.gz --progress-bar off - pip install -r requires-install.txt -r requires-dev.txt -r requires-testing.txt --progress-bar off + pip install -r requires-install.txt -r requires-ci.txt -r requires-dev.txt -r requires-testing.txt -r requires-celery-manager.txt -r requires-diskcache-manager.txt --progress-bar off sed -i '/dash/d' requires-install.txt pip list | grep dash - run: @@ -265,7 +267,7 @@ jobs: path: ~/dash - run: echo $PYTHON_VERSION > ver.txt - restore_cache: - key: dep-{{ checksum ".circleci/config.yml" }}-{{ checksum "ver.txt" }}-{{ checksum "dev-requirements.txt" }} + key: dep-{{ checksum ".circleci/config.yml" }}-{{ checksum "ver.txt" }}-{{ checksum "dev-requirements.txt" }}-{{ checksum "../../requires-ci.txt" }} - attach_workspace: at: ~/dash/components/dash-core-components - run: @@ -274,9 +276,9 @@ jobs: sudo pip install virtualenv --upgrade python -m venv venv || virtualenv venv && . venv/bin/activate pip install dash-package/dash-package.tar.gz[dev,testing] - pip install --progress-bar off --no-cache-dir -r dev-requirements.txt + pip install --progress-bar off --no-cache-dir -r dev-requirements.txt -r ../../requires-ci.txt - save_cache: - key: dep-{{ checksum ".circleci/config.yml" }}-{{ checksum "ver.txt" }}-{{ checksum "dev-requirements.txt" }} + key: dep-{{ checksum ".circleci/config.yml" }}-{{ checksum "ver.txt" }}-{{ checksum "dev-requirements.txt" }}-{{ checksum "../../requires-ci.txt" }} paths: - venv - run: @@ -421,7 +423,7 @@ jobs: python -m venv venv || virtualenv venv . venv/bin/activate pip install dash-package/dash-package.tar.gz[dev,testing] - pip install -r dev-requirements.txt + pip install -r dev-requirements.txt -r ../../requires-ci.txt npm ci - run: @@ -493,6 +495,7 @@ jobs: . venv/bin/activate pip install -r dev-requirements.txt --quiet pip install -r python-requirements.txt --quiet + pip install -r ../../requires-ci.txt pip install dash-package/dash-package.tar.gz[dev,testing] - run: name: Build @@ -597,7 +600,7 @@ jobs: name: Install requirements command: | . venv/bin/activate - pip install -r dev-requirements.txt --quiet + pip install -r dev-requirements.txt -r ../../requires-ci.txt --quiet pip install dash-package/dash-package.tar.gz[dev,testing] - run: diff --git a/dash/long_callback/managers/celery_manager.py b/dash/long_callback/managers/celery_manager.py index 176bc2d646..d01e163228 100644 --- a/dash/long_callback/managers/celery_manager.py +++ b/dash/long_callback/managers/celery_manager.py @@ -25,10 +25,18 @@ def __init__(self, celery_app, cache_by=None, expire=None): for ``expire`` seconds. If not provided, the lifetime of cache entries is determined by the default behavior of the celery result backend. """ - import celery # pylint: disable=import-outside-toplevel,import-error - from celery.backends.base import ( # pylint: disable=import-outside-toplevel,import-error - DisabledBackend, - ) + try: + import celery # pylint: disable=import-outside-toplevel,import-error + from celery.backends.base import ( # pylint: disable=import-outside-toplevel,import-error + DisabledBackend, + ) + except ImportError as missing_imports: + raise ImportError( + """\ +CeleryLongCallbackManager requires extra dependencies which can be installed doing + + $ pip install "dash[celery-manager]"\n""" + ) from missing_imports if not isinstance(celery_app, celery.Celery): raise ValueError("First argument must be a celery.Celery object") diff --git a/dash/long_callback/managers/diskcache_manager.py b/dash/long_callback/managers/diskcache_manager.py index 9127fef447..2cc1d7b51c 100644 --- a/dash/long_callback/managers/diskcache_manager.py +++ b/dash/long_callback/managers/diskcache_manager.py @@ -28,14 +28,9 @@ def __init__(self, cache, cache_by=None, expire=None): except ImportError as missing_imports: raise ImportError( """\ -DiskcacheLongCallbackManager requires the multiprocess, diskcache, and psutil packages -which can be installed using pip... +DiskcacheLongCallbackManager requires extra dependencies which can be installed doing - $ pip install multiprocess diskcache psutil - -or conda. - - $ conda install -c conda-forge multiprocess diskcache psutil\n""" + $ pip install "dash[diskcache-manager]"\n""" ) from missing_imports if not isinstance(cache, (diskcache.Cache, diskcache.FanoutCache)): diff --git a/dash/testing/plugin.py b/dash/testing/plugin.py index ce61805b32..b9b02623ba 100644 --- a/dash/testing/plugin.py +++ b/dash/testing/plugin.py @@ -189,10 +189,18 @@ def dashjl(request, dashjl_server, tmpdir): @pytest.fixture def diskcache_manager(): - from dash.long_callback import ( # pylint: disable=import-outside-toplevel - DiskcacheLongCallbackManager, - ) - import diskcache # pylint: disable=import-outside-toplevel + try: + from dash.long_callback import ( # pylint: disable=import-outside-toplevel + DiskcacheLongCallbackManager, + ) + import diskcache # pylint: disable=import-outside-toplevel + except ImportError as missing_imports: + raise ImportError( + """\ +DiskcacheLongCallbackManager requires extra dependencies which can be installed doing + +$ pip install "dash[diskcache-manager]"\n""" + ) from missing_imports cache = diskcache.Cache() return DiskcacheLongCallbackManager(cache) diff --git a/requires-celery-manager.txt b/requires-celery-manager.txt new file mode 100644 index 0000000000..63851f1d52 --- /dev/null +++ b/requires-celery-manager.txt @@ -0,0 +1,2 @@ +redis>=3.5.3 +celery[redis]>=5.1.2 diff --git a/requires-ci.txt b/requires-ci.txt new file mode 100644 index 0000000000..c2a64c8700 --- /dev/null +++ b/requires-ci.txt @@ -0,0 +1,13 @@ +black==21.6b0 +dash-flow-example==0.0.5 +dash-dangerously-set-inner-html +flake8==3.9.2 +flaky==3.7.0 +flask-talisman==0.8.1 +isort==4.3.21;python_version<"3.7" +mock==4.0.3 +orjson==3.3.1;python_version<"3.7" +orjson==3.6.1;python_version>="3.7" +pylint==2.10.2 +pytest-mock==3.2.0 +pytest-sugar==0.9.4 \ No newline at end of file diff --git a/requires-dev.txt b/requires-dev.txt index 3773ced3c1..4cd2da5f25 100644 --- a/requires-dev.txt +++ b/requires-dev.txt @@ -1,13 +1,3 @@ -dash_flow_example==0.0.5 -dash-dangerously-set-inner-html -isort==4.3.21;python_version<"3.7" -mock==4.0.3 -flake8==3.9.2 -PyYAML==5.4.1 -pylint==2.10.2 -black==21.6b0 -fire==0.4.0 -coloredlogs==15.0.1 -flask-talisman==0.8.1 -orjson==3.3.1;python_version<"3.7" -orjson==3.6.1;python_version>="3.7" +coloredlogs>=15.0.1 +fire>=0.4.0 +PyYAML>=5.4.1 diff --git a/requires-diskcache-manager.txt b/requires-diskcache-manager.txt new file mode 100644 index 0000000000..457dd37270 --- /dev/null +++ b/requires-diskcache-manager.txt @@ -0,0 +1,3 @@ +diskcache>=5.2.1 +multiprocess>=0.70.12 +psutil>=5.8.0 diff --git a/requires-testing.txt b/requires-testing.txt index c347a404e9..65c7c5d6ad 100644 --- a/requires-testing.txt +++ b/requires-testing.txt @@ -1,16 +1,8 @@ -pytest>=6.0.2 -pytest-sugar>=0.9.4 -pytest-mock>=3.2.0 +beautifulsoup4>=4.8.2 +cryptography<3.4;python_version<"3.7" lxml>=4.6.2 -selenium>=3.141.0 percy>=2.0.2 -cryptography<3.4;python_version<"3.7" +pytest>=6.0.2 requests[security]>=2.21.0 -beautifulsoup4>=4.8.2 +selenium>=3.141.0 waitress>=1.4.4 -diskcache>=5.2.1 -multiprocess>=0.70.12 -redis>=3.5.3 -psutil>=5.8.0 -celery[redis]>=5.1.2 -flaky>=3.7.0 diff --git a/setup.py b/setup.py index 0757273c49..c824262a30 100644 --- a/setup.py +++ b/setup.py @@ -30,6 +30,8 @@ def read_req_file(req_type): extras_require={ "dev": read_req_file("dev"), "testing": read_req_file("testing"), + "celery-manager": read_req_file("celery-manager"), + "diskcache-manager": read_req_file("diskcache-manager"), }, entry_points={ "console_scripts": [