Skip to content

Commit 8c193bc

Browse files
authored
Merge pull request #1745 from anders-kiaer/split_dep
Split dependencies
2 parents c650c53 + 0f2f92e commit 8c193bc

11 files changed

+140
-89
lines changed

.circleci/config.yml

+71-45
Original file line numberDiff line numberDiff line change
@@ -17,15 +17,16 @@ jobs:
1717
steps:
1818
- checkout
1919
- run: echo $PYVERSION > ver.txt
20+
- run: echo requires-*.txt > requires-all.txt
2021
- restore_cache:
21-
key: dep-{{ checksum ".circleci/config.yml" }}-{{ checksum "ver.txt" }}-{{ checksum "requires-dev.txt" }}-{{ checksum "requires-install.txt" }}-{{ checksum "requires-testing.txt" }}
22+
key: dep-{{ checksum ".circleci/config.yml" }}-{{ checksum "ver.txt" }}-{{ checksum "requires-all.txt" }}
2223
- attach_workspace:
2324
at: ~/dash
2425
- store_artifacts:
2526
path: ~/dash/dash-main
2627
destination: /tmp/dash-main
2728

28-
install-dependencies:
29+
install-dependencies-39: &install-dependencies
2930
working_directory: ~/dash
3031
docker:
3132
- image: circleci/python:3.9.2-buster-node-browsers
@@ -39,24 +40,45 @@ jobs:
3940

4041
steps:
4142
- checkout
43+
- run: echo $PYVERSION > ver.txt
44+
- run: echo requires-*.txt > requires-all.txt
45+
- restore_cache:
46+
key: dep-{{ checksum ".circleci/config.yml" }}-{{ checksum "ver.txt" }}-{{ checksum "requires-all.txt" }}
4247
- run:
4348
name: 🏁 Build Component Packages & Update Dependencies/Artifacts
4449
command: |
4550
python -m venv venv && . venv/bin/activate
4651
pip install --upgrade pip wheel
4752
set -eo pipefail
48-
pip install -e .[testing,dev] --progress-bar off && pip list | grep dash
53+
pip install -e .[ci,dev,testing,celery,diskcache] --progress-bar off
54+
pip list | grep dash
4955
npm i
5056
npm run build
5157
python setup.py sdist
5258
mkdir dash-package && cp dist/*.tar.gz dash-package/dash-package.tar.gz
5359
ls -la dash-package
5460
no_output_timeout: 30m
61+
- save_cache:
62+
key: dep-{{ checksum ".circleci/config.yml" }}-{{ checksum "ver.txt" }}-{{ checksum "requires-all.txt" }}
63+
paths:
64+
- venv
5565
- persist_to_workspace:
5666
root: ~/dash
5767
paths:
5868
- dash-package
5969

70+
install-dependencies-36:
71+
<<: *install-dependencies
72+
docker:
73+
- image: circleci/python:3.6.13-stretch-node-browsers
74+
auth:
75+
username: dashautomation
76+
password: $DASH_PAT_DOCKERHUB
77+
environment:
78+
PYLINTRC: .pylintrc
79+
PYVERSION: python36
80+
PERCY_ENABLE: 0
81+
6082
lint-unit-39: &lint-unit
6183
working_directory: ~/dash
6284
docker:
@@ -72,18 +94,15 @@ jobs:
7294
steps:
7395
- checkout
7496
- run: echo $PYVERSION > ver.txt
97+
- run: echo requires-*.txt > requires-all.txt
7598
- restore_cache:
76-
key: dep-{{ checksum ".circleci/config.yml" }}-{{ checksum "ver.txt" }}-{{ checksum "requires-dev.txt" }}-{{ checksum "requires-install.txt" }}-{{ checksum "requires-testing.txt" }}
99+
key: dep-{{ checksum ".circleci/config.yml" }}-{{ checksum "ver.txt" }}-{{ checksum "requires-all.txt" }}
77100
- run:
78101
name: ️️🏗️ pip dev requirements
79102
command: |
80103
python -m venv venv && . venv/bin/activate
81104
pip install --upgrade pip wheel
82-
pip install -e . --no-cache-dir -r requires-install.txt -r requires-dev.txt -r requires-testing.txt --progress-bar off
83-
- save_cache:
84-
key: dep-{{ checksum ".circleci/config.yml" }}-{{ checksum "ver.txt" }}-{{ checksum "requires-dev.txt" }}-{{ checksum "requires-install.txt" }}-{{ checksum "requires-testing.txt" }}
85-
paths:
86-
- venv
105+
pip install -e .[ci,dev,testing] --no-cache-dir --progress-bar off
87106
- run:
88107
name: 🌸 Python & JS Lint
89108
command: |
@@ -146,18 +165,17 @@ jobs:
146165
steps:
147166
- checkout
148167
- run: echo $PYVERSION > ver.txt
168+
- run: echo requires-*.txt > requires-all.txt
149169
- restore_cache:
150-
key: dep-{{ checksum ".circleci/config.yml" }}-{{ checksum "ver.txt" }}-{{ checksum "requires-dev.txt" }}-{{ checksum "requires-install.txt" }}-{{ checksum "requires-testing.txt" }}
170+
key: dep-{{ checksum ".circleci/config.yml" }}-{{ checksum "ver.txt" }}-{{ checksum "requires-all.txt" }}
151171
- attach_workspace:
152172
at: ~/dash
153173
- run:
154174
name: ️️🏗️ Install packages
155175
command: |
156176
. venv/bin/activate
157177
npm install --production
158-
pip install --no-cache-dir --upgrade --ignore-installed dash-package/dash-package.tar.gz --progress-bar off
159-
pip install -r requires-install.txt -r requires-dev.txt -r requires-testing.txt --progress-bar off
160-
sed -i '/dash/d' requires-install.txt
178+
pip install --no-cache-dir --upgrade --ignore-installed dash-package/dash-package.tar.gz[ci,dev,testing,celery,diskcache] --progress-bar off
161179
pip list | grep dash
162180
- run:
163181
name: 🧪 Run Integration Tests
@@ -198,20 +216,21 @@ jobs:
198216
steps:
199217
- checkout:
200218
path: ~/dash
201-
- run: echo $PYTHON_VERSION > ver.txt
219+
- run: echo $PYVERSION > ver.txt
220+
- run: echo requires-*.txt > requires-all.txt
202221
- restore_cache:
203-
key: dep-{{ checksum ".circleci/config.yml" }}-{{ checksum "ver.txt" }}-{{ checksum "dev-requirements.txt" }}
222+
key: dep-{{ checksum ".circleci/config.yml" }}-{{ checksum "ver.txt" }}-{{ checksum "requires-all.txt" }}-{{ checksum "dev-requirements.txt" }}
204223
- attach_workspace:
205224
at: ~/dash/components/dash-core-components
206225
- run:
207226
name: 🐍 pip dev requirements
208227
command: |
209228
python -m venv venv && . venv/bin/activate
210229
pip install --upgrade pip wheel
211-
pip install dash-package/dash-package.tar.gz[dev,testing]
230+
pip install dash-package/dash-package.tar.gz[ci,dev,testing]
212231
pip install --progress-bar off --no-cache-dir -r dev-requirements.txt
213232
- save_cache:
214-
key: dep-{{ checksum ".circleci/config.yml" }}-{{ checksum "ver.txt" }}-{{ checksum "dev-requirements.txt" }}
233+
key: dep-{{ checksum ".circleci/config.yml" }}-{{ checksum "ver.txt" }}-{{ checksum "requires-all.txt" }}-{{ checksum "dev-requirements.txt" }}
215234
paths:
216235
- venv
217236
- run:
@@ -247,19 +266,16 @@ jobs:
247266
- checkout:
248267
path: ~/dash
249268
- run: echo $PYTHON_VERSION > ver.txt
269+
- run: echo requires-*.txt > requires-all.txt
250270
- restore_cache:
251-
key: dep-{{ checksum ".circleci/config.yml" }}-{{ checksum "ver.txt" }}-{{ checksum "dev-requirements.txt" }}
271+
key: dep-{{ checksum ".circleci/config.yml" }}-{{ checksum "ver.txt" }}-{{ checksum "requires-all.txt" }}-{{ checksum "dev-requirements.txt" }}
252272
- run:
253273
name: 🐍 pip dev requirements
254274
command: |
255275
python -m venv venv && . venv/bin/activate
256276
pip install --upgrade pip wheel
257277
set -eo pipefail
258278
pip install --progress-bar off --no-cache-dir -r dev-requirements.txt
259-
- save_cache:
260-
key: dep-{{ checksum ".circleci/config.yml" }}-{{ checksum "ver.txt" }}-{{ checksum "dev-requirements.txt" }}
261-
paths:
262-
- venv
263279
- attach_workspace:
264280
at: ~/dash/components/dash-core-components
265281
- run:
@@ -268,7 +284,11 @@ jobs:
268284
. venv/bin/activate
269285
set -eo pipefail
270286
# build main dash & renderer
271-
pip install dash-package/dash-package.tar.gz[dev,testing]
287+
pip install dash-package/dash-package.tar.gz[ci,dev,testing]
288+
- save_cache:
289+
key: dep-{{ checksum ".circleci/config.yml" }}-{{ checksum "ver.txt" }}-{{ checksum "requires-all.txt" }}-{{ checksum "dev-requirements.txt" }}
290+
paths:
291+
- venv
272292

273293
dcc-build-dash-36:
274294
<<: *dcc-build-dash
@@ -297,8 +317,9 @@ jobs:
297317
- checkout:
298318
path: ~/dash
299319
- run: echo $PYTHON_VERSION > ver.txt
320+
- run: echo requires-*.txt > requires-all.txt
300321
- restore_cache:
301-
key: dep-{{ checksum ".circleci/config.yml" }}-{{ checksum "ver.txt" }}-{{ checksum "dev-requirements.txt" }}
322+
key: dep-{{ checksum ".circleci/config.yml" }}-{{ checksum "ver.txt" }}-{{ checksum "requires-all.txt" }}-{{ checksum "dev-requirements.txt" }}
302323
- attach_workspace:
303324
at: ~/dash/components/dash-core-components
304325
- run:
@@ -307,7 +328,7 @@ jobs:
307328
. venv/bin/activate && rm -rf dash_core_components && ls -la
308329
pip install --upgrade pip wheel
309330
set -eo pipefail
310-
pip install dash-package/dash-package.tar.gz[dev,testing]
331+
pip install dash-package/dash-package.tar.gz[ci,dev,testing]
311332
pip list | grep dash | xargs pip show
312333
echo $(python -V 2>&1) | grep 3.
313334
TESTFILES=$(circleci tests glob "tests/integration/**/test_*.py" | circleci tests split --split-by=timings)
@@ -355,7 +376,7 @@ jobs:
355376
python -m venv venv
356377
. venv/bin/activate
357378
pip install --upgrade pip wheel
358-
pip install dash-package/dash-package.tar.gz[dev,testing]
379+
pip install dash-package/dash-package.tar.gz[ci,dev,testing]
359380
pip install -r dev-requirements.txt
360381
npm ci
361382
@@ -427,7 +448,7 @@ jobs:
427448
. venv/bin/activate
428449
pip install -r dev-requirements.txt --quiet
429450
pip install -r python-requirements.txt --quiet
430-
pip install dash-package/dash-package.tar.gz[dev,testing]
451+
pip install dash-package/dash-package.tar.gz[ci,dev,testing]
431452
- run:
432453
name: Build
433454
command: |
@@ -473,7 +494,7 @@ jobs:
473494
python -m venv venv
474495
. venv/bin/activate
475496
pip install -r dev-requirements.txt --quiet
476-
pip install dash-package/dash-package.tar.gz[dev,testing]
497+
pip install dash-package/dash-package.tar.gz[ci,dev,testing]
477498
- run:
478499
name: Run tests
479500
command: |
@@ -536,7 +557,7 @@ jobs:
536557
command: |
537558
. venv/bin/activate
538559
pip install -r dev-requirements.txt --quiet
539-
pip install dash-package/dash-package.tar.gz[dev,testing]
560+
pip install dash-package/dash-package.tar.gz[ci,dev,testing]
540561
541562
- run:
542563
name: Run eslint
@@ -549,59 +570,64 @@ workflows:
549570
version: 2
550571
tests:
551572
jobs:
552-
- install-dependencies
573+
- install-dependencies-39
574+
- install-dependencies-36
553575

554576
- build-windows-39
555577

556-
- lint-unit-39
557-
- lint-unit-36
578+
- lint-unit-39:
579+
requires:
580+
- install-dependencies-39
581+
- lint-unit-36:
582+
requires:
583+
- install-dependencies-36
558584

559585
- test-39:
560586
requires:
561-
- install-dependencies
587+
- install-dependencies-39
562588
- test-36:
563589
requires:
564-
- install-dependencies
590+
- install-dependencies-36
565591

566592
- dcc-lint-unit-39:
567593
requires:
568-
- install-dependencies
594+
- install-dependencies-39
569595
- dcc-lint-unit-36:
570596
requires:
571-
- install-dependencies
597+
- install-dependencies-36
572598

573599
- dcc-build-dash-39:
574600
requires:
575-
- install-dependencies
601+
- install-dependencies-39
576602
- dcc-test-39:
577603
requires:
578-
- install-dependencies
604+
- install-dependencies-39
579605
- dcc-build-dash-39
580606
- dcc-build-dash-36:
581607
requires:
582-
- install-dependencies
608+
- install-dependencies-36
583609
- dcc-test-36:
584610
requires:
585-
- install-dependencies
611+
- install-dependencies-36
586612
- dcc-build-dash-36
587613

588614
- html-python-39:
589615
requires:
590-
- install-dependencies
616+
- install-dependencies-39
591617
- html-python-36:
592618
requires:
593-
- install-dependencies
619+
- install-dependencies-36
594620

595621
- table-node:
596622
requires:
597-
- install-dependencies
623+
- install-dependencies-39
598624
- table-unit-test:
599625
requires:
600-
- install-dependencies
626+
- install-dependencies-39
601627
- table-visual-test
602628
- table-server-test:
603629
requires:
604-
- install-dependencies
630+
- install-dependencies-39
605631

606632
- percy/finalize_all:
607633
requires:

CHANGELOG.md

+8
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,14 @@ This project adheres to [Semantic Versioning](https://semver.org/).
44

55
## [Unreleased]
66

7+
- [#1745](https://github.com/plotly/dash/pull/1745):
8+
Improve our `extras_require`: there are now five options here, each with a well-defined role:
9+
- `dash[dev]`: for developing and building dash components.
10+
- `dash[testing]`: for using the `pytest` plugins in the `dash.testing` module
11+
- `dash[diskcache]`: required if you use `DiskcacheLongCallbackManager`
12+
- `dash[celery]`: required if you use `CeleryLongCallbackManager`
13+
- `dash[ci]`: mainly for internal use, these are additional requirements for the Dash CI tests, exposed for other component libraries to use a matching configuration.
14+
715
- [#1779](https://github.com/plotly/dash/pull/1779):
816
- Clean up our handling of serialization problems, including fixing `orjson` for Python 3.6
917
- Added the ability for `dash.testing` `percy_snapshot` methods to choose widths to generate.

dash/long_callback/managers/celery_manager.py

+12-4
Original file line numberDiff line numberDiff line change
@@ -25,10 +25,18 @@ def __init__(self, celery_app, cache_by=None, expire=None):
2525
for ``expire`` seconds. If not provided, the lifetime of cache entries
2626
is determined by the default behavior of the celery result backend.
2727
"""
28-
import celery # pylint: disable=import-outside-toplevel,import-error
29-
from celery.backends.base import ( # pylint: disable=import-outside-toplevel,import-error
30-
DisabledBackend,
31-
)
28+
try:
29+
import celery # pylint: disable=import-outside-toplevel,import-error
30+
from celery.backends.base import ( # pylint: disable=import-outside-toplevel,import-error
31+
DisabledBackend,
32+
)
33+
except ImportError as missing_imports:
34+
raise ImportError(
35+
"""\
36+
CeleryLongCallbackManager requires extra dependencies which can be installed doing
37+
38+
$ pip install "dash[celery]"\n"""
39+
) from missing_imports
3240

3341
if not isinstance(celery_app, celery.Celery):
3442
raise ValueError("First argument must be a celery.Celery object")

dash/long_callback/managers/diskcache_manager.py

+15-12
Original file line numberDiff line numberDiff line change
@@ -4,14 +4,15 @@
44

55

66
class DiskcacheLongCallbackManager(BaseLongCallbackManager):
7-
def __init__(self, cache, cache_by=None, expire=None):
7+
def __init__(self, cache=None, cache_by=None, expire=None):
88
"""
99
Long callback manager that runs callback logic in a subprocess and stores
1010
results on disk using diskcache
1111
1212
:param cache:
1313
A diskcache.Cache or diskcache.FanoutCache instance. See the diskcache
14-
documentation for information on configuration options.
14+
documentation for information on configuration options. If not provided,
15+
a diskcache.Cache instance will be created with default values.
1516
:param cache_by:
1617
A list of zero-argument functions. When provided, caching is enabled and
1718
the return values of these functions are combined with the callback
@@ -28,20 +29,22 @@ def __init__(self, cache, cache_by=None, expire=None):
2829
except ImportError as missing_imports:
2930
raise ImportError(
3031
"""\
31-
DiskcacheLongCallbackManager requires the multiprocess, diskcache, and psutil packages
32-
which can be installed using pip...
32+
DiskcacheLongCallbackManager requires extra dependencies which can be installed doing
3333
34-
$ pip install multiprocess diskcache psutil
35-
36-
or conda.
37-
38-
$ conda install -c conda-forge multiprocess diskcache psutil\n"""
34+
$ pip install "dash[diskcache]"\n"""
3935
) from missing_imports
4036

41-
if not isinstance(cache, (diskcache.Cache, diskcache.FanoutCache)):
42-
raise ValueError("First argument must be a diskcache.Cache object")
37+
if cache is None:
38+
self.handle = diskcache.Cache()
39+
else:
40+
if not isinstance(cache, (diskcache.Cache, diskcache.FanoutCache)):
41+
raise ValueError(
42+
"First argument must be a diskcache.Cache "
43+
"or diskcache.FanoutCache object"
44+
)
45+
self.handle = cache
46+
4347
super().__init__(cache_by)
44-
self.handle = cache
4548
self.expire = expire
4649

4750
def terminate_job(self, job):

0 commit comments

Comments
 (0)