Skip to content

Commit 041ab38

Browse files
author
Marc-André Rivet
committed
Merge remote-tracking branch 'origin/dev'
2 parents 6150ec5 + 6c29dd0 commit 041ab38

File tree

9 files changed

+63
-17
lines changed

9 files changed

+63
-17
lines changed

@plotly/webpack-dash-dynamic-import/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@plotly/webpack-dash-dynamic-import",
3-
"version": "1.1.1",
3+
"version": "1.1.2",
44
"description": "Webpack Plugin for Dynamic Import in Dash",
55
"repository": {
66
"type": "git",

@plotly/webpack-dash-dynamic-import/src/index.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ function getFingerprint() {
55
const packageJson = JSON.parse(package);
66

77
const timestamp = Math.round(Date.now() / 1000);
8-
const version = packageJson.version.replace(/[.]/g, '_');
8+
const version = packageJson.version.replace(/[^\w-]/g, '_');
99

1010
return `"v${version}m${timestamp}"`;
1111
}

CHANGELOG.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,11 @@
22
All notable changes to `dash` will be documented in this file.
33
This project adheres to [Semantic Versioning](http://semver.org/).
44

5+
## [1.6.0] - 2019-11-04
6+
### Fixed
7+
- [#999](https://github.com/plotly/dash/pull/999) Fix fingerprint for component suites with `metadata` in version.
8+
- [#983](https://github.com/plotly/dash/pull/983) Fix the assets loading issues when dashR application runner is handling with an app defined by string chunk.
9+
510
## [1.5.1] - 2019-10-29
611
### Fixed
712
- [#987](https://github.com/plotly/dash/pull/987) Fix cache string handling for component suites with nested folders in their packages.

dash/fingerprint.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,15 @@
11
import re
22

33
cache_regex = re.compile(r"^v[\w-]+m[0-9a-fA-F]+$")
4-
4+
version_clean = re.compile(r"[^\w-]")
55

66
def build_fingerprint(path, version, hash_value):
77
path_parts = path.split("/")
88
filename, extension = path_parts[-1].split(".", 1)
99

1010
return "{}.v{}m{}.{}".format(
1111
"/".join(path_parts[:-1] + [filename]),
12-
str(version).replace(".", "_"),
12+
re.sub(version_clean, "_", str(version)),
1313
hash_value,
1414
extension,
1515
)

dash/testing/application_runners.py

Lines changed: 45 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
import uuid
66
import shlex
77
import threading
8+
import shutil
89
import subprocess
910
import logging
1011
import inspect
@@ -61,6 +62,7 @@ def __init__(self, keep_open, stop_timeout):
6162
self.started = None
6263
self.keep_open = keep_open
6364
self.stop_timeout = stop_timeout
65+
self._tmp_app_path = None
6466

6567
def start(self, *args, **kwargs):
6668
raise NotImplementedError # pragma: no cover
@@ -103,6 +105,10 @@ def url(self):
103105
def is_windows(self):
104106
return sys.platform == "win32"
105107

108+
@property
109+
def tmp_app_path(self):
110+
return self._tmp_app_path
111+
106112

107113
class ThreadedRunner(BaseDashRunner):
108114
"""Runs a dash application in a thread.
@@ -261,13 +267,18 @@ def start(self, app, start_timeout=2, cwd=None):
261267
cwd = os.path.dirname(app)
262268
logger.info("RRunner inferred cwd from app path: %s", cwd)
263269
else:
264-
path = (
265-
"/tmp/app_{}.R".format(uuid.uuid4().hex)
266-
if not self.is_windows
267-
else os.path.join(
268-
(os.getenv("TEMP"), "app_{}.R".format(uuid.uuid4().hex))
269-
)
270+
self._tmp_app_path = os.path.join(
271+
"/tmp" if not self.is_windows else os.getenv("TEMP"),
272+
uuid.uuid4().hex,
270273
)
274+
try:
275+
os.mkdir(self.tmp_app_path)
276+
except OSError:
277+
logger.exception(
278+
"cannot make temporary folder %s", self.tmp_app_path
279+
)
280+
path = os.path.join(self.tmp_app_path, "app.R")
281+
271282
logger.info("RRunner start => app is R code chunk")
272283
logger.info("make a temporary R file for execution => %s", path)
273284
logger.debug("content of the dashR app")
@@ -283,11 +294,11 @@ def start(self, app, start_timeout=2, cwd=None):
283294
for entry in inspect.stack():
284295
if "/dash/testing/" not in entry[1].replace("\\", "/"):
285296
cwd = os.path.dirname(os.path.realpath(entry[1]))
297+
logger.warning("get cwd from inspect => %s", cwd)
286298
break
287299
if cwd:
288300
logger.info(
289-
"RRunner inferred cwd from the Python call stack: %s",
290-
cwd
301+
"RRunner inferred cwd from the Python call stack: %s", cwd
291302
)
292303
else:
293304
logger.warning(
@@ -297,16 +308,40 @@ def start(self, app, start_timeout=2, cwd=None):
297308
"dashr.run_server(app, cwd=os.path.dirname(__file__))"
298309
)
299310

311+
# try copying all valid sub folders (i.e. assets) in cwd to tmp
312+
# note that the R assets folder name can be any valid folder name
313+
assets = [
314+
os.path.join(cwd, _)
315+
for _ in os.listdir(cwd)
316+
if not _.startswith("__")
317+
and os.path.isdir(os.path.join(cwd, _))
318+
]
319+
320+
for asset in assets:
321+
target = os.path.join(
322+
self.tmp_app_path, os.path.basename(asset)
323+
)
324+
if os.path.exists(target):
325+
logger.debug("delete existing target %s", target)
326+
shutil.rmtree(target)
327+
logger.debug("copying %s => %s", asset, self.tmp_app_path)
328+
shutil.copytree(asset, target)
329+
logger.debug("copied with %s", os.listdir(target))
330+
300331
logger.info("Run dashR app with Rscript => %s", app)
332+
301333
args = shlex.split(
302-
"Rscript {}".format(os.path.realpath(app)),
334+
"Rscript -e 'source(\"{}\")'".format(os.path.realpath(app)),
303335
posix=not self.is_windows,
304336
)
305337
logger.debug("start dash process with %s", args)
306338

307339
try:
308340
self.proc = subprocess.Popen(
309-
args, stdout=subprocess.PIPE, stderr=subprocess.PIPE, cwd=cwd
341+
args,
342+
stdout=subprocess.PIPE,
343+
stderr=subprocess.PIPE,
344+
cwd=self.tmp_app_path if self.tmp_app_path else cwd,
310345
)
311346
# wait until server is able to answer http request
312347
wait.until(

dash/version.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
__version__ = '1.5.1'
1+
__version__ = '1.6.0'

requires-install.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ Flask>=1.0.2
22
flask-compress
33
plotly
44
dash_renderer==1.2.0
5-
dash-core-components==1.4.0
5+
dash-core-components==1.5.0
66
dash-html-components==1.0.1
77
dash-table==4.5.0
88
future

tests/integration/devtools/test_props_check.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -216,7 +216,7 @@
216216

217217

218218
def test_dvpc001_prop_check_errors_with_path(dash_duo):
219-
app = dash.Dash(__name__)
219+
app = dash.Dash(__name__, eager_loading=True)
220220

221221
app.layout = html.Div([html.Div(id="content"), dcc.Location(id="location")])
222222

tests/unit/test_fingerprint.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,12 @@
1717
"version": "1.1.1-alpha.1",
1818
"hash": "1234567890abcdef",
1919
},
20+
{
21+
"path": "[email protected]",
22+
"fingerprint": "[email protected]_1_1-alpha_x_y_y_X_Y_Z_1_2_3_metadata_xx_yy_zz_XX_YY_ZZ_11_22_33_mmm1234567890abcdefABCDEF.8.6.min.js",
23+
"version": "1.1.1-alpha.x.y.y.X.Y.Z.1.2.3+metadata.xx.yy.zz.XX.YY.ZZ.11.22.33.mm",
24+
"hash": "1234567890abcdefABCDEF",
25+
},
2026
{"path": "dash.plotly.js", "fingerprint": "dash.v1m1.plotly.js"},
2127
{"path": "dash.plotly.j_s", "fingerprint": "dash.v1m1.plotly.j_s"},
2228
{"path": "dash.plotly.css", "fingerprint": "dash.v1m1.plotly.css"},

0 commit comments

Comments
 (0)