Skip to content

Commit

Permalink
Changes after review
Browse files Browse the repository at this point in the history
  • Loading branch information
anders-kiaer committed Sep 21, 2021
1 parent af23c5b commit bfc95de
Show file tree
Hide file tree
Showing 12 changed files with 45 additions and 44 deletions.
27 changes: 12 additions & 15 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -43,8 +43,7 @@ jobs:
sudo pip install virtualenv --upgrade
python -m venv venv && . venv/bin/activate
set -eo pipefail
pip install -e .[testing,dev,celery-manager,diskcache-manager] --progress-bar off
pip install -r ./requires-ci.txt --progress-bar off
pip install -e .[ci,dev,testing,celery,diskcache] --progress-bar off
pip list | grep dash
npm i
npm run build
Expand Down Expand Up @@ -78,7 +77,7 @@ jobs:
command: |
sudo pip install --upgrade virtualenv --progress-bar off
python -m venv venv || virtualenv venv && . venv/bin/activate
pip install -e .[dev,testing] --no-cache-dir -r requires-ci.txt --progress-bar off
pip install -e .[ci,dev,testing] --no-cache-dir --progress-bar off
- save_cache:
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:
Expand Down Expand Up @@ -224,8 +223,7 @@ jobs:
command: |
. 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-ci.txt -r requires-dev.txt -r requires-testing.txt -r requires-celery-manager.txt -r requires-diskcache-manager.txt --progress-bar off
pip install --no-cache-dir --upgrade --ignore-installed dash-package/dash-package.tar.gz[ci,dev,testing,celery,diskcache] --progress-bar off
sed -i '/dash/d' requires-install.txt
pip list | grep dash
- run:
Expand Down Expand Up @@ -267,18 +265,18 @@ jobs:
path: ~/dash
- run: echo $PYTHON_VERSION > ver.txt
- restore_cache:
key: dep-{{ checksum ".circleci/config.yml" }}-{{ checksum "ver.txt" }}-{{ checksum "dev-requirements.txt" }}-{{ checksum "../../requires-ci.txt" }}
key: dep-{{ checksum ".circleci/config.yml" }}-{{ checksum "ver.txt" }}-{{ checksum "dev-requirements.txt" }}
- attach_workspace:
at: ~/dash/components/dash-core-components
- run:
name: 🐍 pip dev requirements
command: |
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 -r ../../requires-ci.txt
pip install dash-package/dash-package.tar.gz[ci,dev,testing]
pip install --progress-bar off --no-cache-dir -r dev-requirements.txt
- save_cache:
key: dep-{{ checksum ".circleci/config.yml" }}-{{ checksum "ver.txt" }}-{{ checksum "dev-requirements.txt" }}-{{ checksum "../../requires-ci.txt" }}
key: dep-{{ checksum ".circleci/config.yml" }}-{{ checksum "ver.txt" }}-{{ checksum "dev-requirements.txt" }}
paths:
- venv
- run:
Expand Down Expand Up @@ -422,8 +420,8 @@ 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 -r dev-requirements.txt -r ../../requires-ci.txt
pip install dash-package/dash-package.tar.gz[ci,dev,testing]
pip install -r dev-requirements.txt
npm ci
- run:
Expand Down Expand Up @@ -495,8 +493,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]
pip install dash-package/dash-package.tar.gz[ci,dev,testing]
- run:
name: Build
command: |
Expand Down Expand Up @@ -600,8 +597,8 @@ jobs:
name: Install requirements
command: |
. venv/bin/activate
pip install -r dev-requirements.txt -r ../../requires-ci.txt --quiet
pip install dash-package/dash-package.tar.gz[dev,testing]
pip install -r dev-requirements.txt --quiet
pip install dash-package/dash-package.tar.gz[ci,dev,testing]
- run:
name: Run eslint
Expand Down
2 changes: 1 addition & 1 deletion dash/long_callback/managers/celery_manager.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ def __init__(self, celery_app, cache_by=None, expire=None):
"""\
CeleryLongCallbackManager requires extra dependencies which can be installed doing
$ pip install "dash[celery-manager]"\n"""
$ pip install "dash[celery]"\n"""
) from missing_imports

if not isinstance(celery_app, celery.Celery):
Expand Down
20 changes: 14 additions & 6 deletions dash/long_callback/managers/diskcache_manager.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,15 @@


class DiskcacheLongCallbackManager(BaseLongCallbackManager):
def __init__(self, cache, cache_by=None, expire=None):
def __init__(self, cache=None, cache_by=None, expire=None):
"""
Long callback manager that runs callback logic in a subprocess and stores
results on disk using diskcache
:param cache:
A diskcache.Cache or diskcache.FanoutCache instance. See the diskcache
documentation for information on configuration options.
documentation for information on configuration options. If not provided,
a diskcache.Cache instance will be created with default values.
:param cache_by:
A list of zero-argument functions. When provided, caching is enabled and
the return values of these functions are combined with the callback
Expand All @@ -30,13 +31,20 @@ def __init__(self, cache, cache_by=None, expire=None):
"""\
DiskcacheLongCallbackManager requires extra dependencies which can be installed doing
$ pip install "dash[diskcache-manager]"\n"""
$ pip install "dash[diskcache]"\n"""
) from missing_imports

if not isinstance(cache, (diskcache.Cache, diskcache.FanoutCache)):
raise ValueError("First argument must be a diskcache.Cache object")
if cache is None:
self.handle = diskcache.Cache()
else:
if not isinstance(cache, (diskcache.Cache, diskcache.FanoutCache)):
raise ValueError(
"First argument must be a diskcache.Cache "
"or diskcache.FanoutCache object"
)
self.handle = cache

super().__init__(cache_by)
self.handle = cache
self.expire = expire

def terminate_job(self, job):
Expand Down
20 changes: 5 additions & 15 deletions dash/testing/plugin.py
Original file line number Diff line number Diff line change
Expand Up @@ -189,18 +189,8 @@ def dashjl(request, dashjl_server, tmpdir):

@pytest.fixture
def diskcache_manager():
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)
from dash.long_callback import ( # pylint: disable=import-outside-toplevel
DiskcacheLongCallbackManager,
)

return DiskcacheLongCallbackManager()
2 changes: 0 additions & 2 deletions requires-celery-manager.txt

This file was deleted.

3 changes: 3 additions & 0 deletions requires-celery.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
# Dependencies used by the CeleryLongCallbackManager
redis>=3.5.3
celery[redis]>=5.1.2
1 change: 1 addition & 0 deletions requires-ci.txt
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
# Dependencies used by CI on github.com/plotly/dash
black==21.6b0
dash-flow-example==0.0.5
dash-dangerously-set-inner-html
Expand Down
1 change: 1 addition & 0 deletions requires-dev.txt
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
# Dependencies used for development new Dash components
coloredlogs>=15.0.1
fire>=0.4.0
PyYAML>=5.4.1
3 changes: 0 additions & 3 deletions requires-diskcache-manager.txt

This file was deleted.

4 changes: 4 additions & 0 deletions requires-diskcache.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
# Dependencies used by the DiskcacheLongCallbackManager
diskcache>=5.2.1
multiprocess>=0.70.12
psutil>=5.8.0
1 change: 1 addition & 0 deletions requires-testing.txt
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
# Dependencies necessary for utilizing Dash provided testing utilities
beautifulsoup4>=4.8.2
cryptography<3.4;python_version<"3.7"
lxml>=4.6.2
Expand Down
5 changes: 3 additions & 2 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,10 +28,11 @@ def read_req_file(req_type):
install_requires=read_req_file("install"),
python_requires=">=3.6",
extras_require={
"ci": read_req_file("ci"),
"dev": read_req_file("dev"),
"testing": read_req_file("testing"),
"celery-manager": read_req_file("celery-manager"),
"diskcache-manager": read_req_file("diskcache-manager"),
"celery": read_req_file("celery"),
"diskcache": read_req_file("diskcache"),
},
entry_points={
"console_scripts": [
Expand Down

0 comments on commit bfc95de

Please sign in to comment.