From e0f2c7a676692d1cbdbdf3c64009378b4e385b3c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marc-Andre=CC=81=20Rivet?= Date: Mon, 4 Nov 2019 10:24:54 -0500 Subject: [PATCH 1/6] - plugin`+` fix - DashPy `+` fix - additional test for version-pre+meta case --- @plotly/webpack-dash-dynamic-import/src/index.js | 2 +- dash/fingerprint.py | 2 +- tests/unit/test_fingerprint.py | 10 ++++++++-- 3 files changed, 10 insertions(+), 4 deletions(-) diff --git a/@plotly/webpack-dash-dynamic-import/src/index.js b/@plotly/webpack-dash-dynamic-import/src/index.js index b02a7edc70..90c8fe23b0 100644 --- a/@plotly/webpack-dash-dynamic-import/src/index.js +++ b/@plotly/webpack-dash-dynamic-import/src/index.js @@ -5,7 +5,7 @@ function getFingerprint() { const packageJson = JSON.parse(package); const timestamp = Math.round(Date.now() / 1000); - const version = packageJson.version.replace(/[.]/g, '_'); + const version = packageJson.version.replace(/[.]/g, '_').replace(/[+]/g, '__'); return `"v${version}m${timestamp}"`; } diff --git a/dash/fingerprint.py b/dash/fingerprint.py index b9c23d3034..e2ed2d0cf0 100644 --- a/dash/fingerprint.py +++ b/dash/fingerprint.py @@ -9,7 +9,7 @@ def build_fingerprint(path, version, hash_value): return "{}.v{}m{}.{}".format( "/".join(path_parts[:-1] + [filename]), - str(version).replace(".", "_"), + str(version).replace(".", "_").replace("+", "__"), hash_value, extension, ) diff --git a/tests/unit/test_fingerprint.py b/tests/unit/test_fingerprint.py index 36de80ddcc..9a5e878a02 100644 --- a/tests/unit/test_fingerprint.py +++ b/tests/unit/test_fingerprint.py @@ -17,6 +17,12 @@ "version": "1.1.1-alpha.1", "hash": "1234567890abcdef", }, + { + "path": "react@16.8.6.min.js", + "fingerprint": "react@16.v1_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", + "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", + "hash": "1234567890abcdefABCDEF", + }, {"path": "dash.plotly.js", "fingerprint": "dash.v1m1.plotly.js"}, {"path": "dash.plotly.j_s", "fingerprint": "dash.v1m1.plotly.j_s"}, {"path": "dash.plotly.css", "fingerprint": "dash.v1m1.plotly.css"}, @@ -110,8 +116,8 @@ def test_fingerprint(): (original_path, has_fingerprint) = check_fingerprint(fingerprint) # The inverse operation returns that the fingerprint was valid # and the original path - assert has_fingerprint - assert original_path == resource.get("path") + assert has_fingerprint, original_path + assert original_path == resource.get("path"), original_path for resource in valid_fingerprints: (_, has_fingerprint) = check_fingerprint(resource) From 85c70143b7651de64c422373fdc2cba3419ec53a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marc-Andre=CC=81=20Rivet?= Date: Mon, 4 Nov 2019 10:34:36 -0500 Subject: [PATCH 2/6] revert test change --- tests/unit/test_fingerprint.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/tests/unit/test_fingerprint.py b/tests/unit/test_fingerprint.py index 9a5e878a02..24a5332236 100644 --- a/tests/unit/test_fingerprint.py +++ b/tests/unit/test_fingerprint.py @@ -116,8 +116,8 @@ def test_fingerprint(): (original_path, has_fingerprint) = check_fingerprint(fingerprint) # The inverse operation returns that the fingerprint was valid # and the original path - assert has_fingerprint, original_path - assert original_path == resource.get("path"), original_path + assert has_fingerprint + assert original_path == resource.get("path") for resource in valid_fingerprints: (_, has_fingerprint) = check_fingerprint(resource) From d435215adc112446cb58b27582a2ed7c003fbe51 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marc-Andre=CC=81=20Rivet?= Date: Mon, 4 Nov 2019 10:39:42 -0500 Subject: [PATCH 3/6] changelog --- CHANGELOG.md | 1 + 1 file changed, 1 insertion(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index b0698b3a3f..74b013f080 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -4,6 +4,7 @@ This project adheres to [Semantic Versioning](http://semver.org/). ## Unreleased ### Fixed +- [#999](https://github.com/plotly/dash/pull/999) Fix fingerprint for component suites with `metadata` in version - [#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. ## [1.5.1] - 2019-10-29 From 02012908e31a26f12c13420a533a4218ac7d3b65 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marc-Andre=CC=81=20Rivet?= Date: Mon, 4 Nov 2019 11:10:43 -0500 Subject: [PATCH 4/6] changelog --- CHANGELOG.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 74b013f080..b28ab05f95 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -4,7 +4,7 @@ This project adheres to [Semantic Versioning](http://semver.org/). ## Unreleased ### Fixed -- [#999](https://github.com/plotly/dash/pull/999) Fix fingerprint for component suites with `metadata` in version +- [#999](https://github.com/plotly/dash/pull/999) Fix fingerprint for component suites with `metadata` in version. - [#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. ## [1.5.1] - 2019-10-29 From 5c80e958444ff1a83dcc9bee7b11a8402930dc67 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marc-Andre=CC=81=20Rivet?= Date: Mon, 4 Nov 2019 11:33:49 -0500 Subject: [PATCH 5/6] eager loading in tests --- tests/integration/devtools/test_props_check.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/integration/devtools/test_props_check.py b/tests/integration/devtools/test_props_check.py index 95d81349ac..b9d7155660 100644 --- a/tests/integration/devtools/test_props_check.py +++ b/tests/integration/devtools/test_props_check.py @@ -216,7 +216,7 @@ def test_dvpc001_prop_check_errors_with_path(dash_duo): - app = dash.Dash(__name__) + app = dash.Dash(__name__, eager_loading=True) app.layout = html.Div([html.Div(id="content"), dcc.Location(id="location")]) From d6ef3dc807f66dc0e570f8f6d7265813b8a1ef37 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marc-Andre=CC=81=20Rivet?= Date: Mon, 4 Nov 2019 12:01:30 -0500 Subject: [PATCH 6/6] :cyclone: generalize version check --- @plotly/webpack-dash-dynamic-import/src/index.js | 2 +- dash/fingerprint.py | 4 ++-- tests/unit/test_fingerprint.py | 2 +- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/@plotly/webpack-dash-dynamic-import/src/index.js b/@plotly/webpack-dash-dynamic-import/src/index.js index 90c8fe23b0..6071c0a97b 100644 --- a/@plotly/webpack-dash-dynamic-import/src/index.js +++ b/@plotly/webpack-dash-dynamic-import/src/index.js @@ -5,7 +5,7 @@ function getFingerprint() { const packageJson = JSON.parse(package); const timestamp = Math.round(Date.now() / 1000); - const version = packageJson.version.replace(/[.]/g, '_').replace(/[+]/g, '__'); + const version = packageJson.version.replace(/[^\w-]/g, '_'); return `"v${version}m${timestamp}"`; } diff --git a/dash/fingerprint.py b/dash/fingerprint.py index e2ed2d0cf0..78df1d4917 100644 --- a/dash/fingerprint.py +++ b/dash/fingerprint.py @@ -1,7 +1,7 @@ import re cache_regex = re.compile(r"^v[\w-]+m[0-9a-fA-F]+$") - +version_clean = re.compile(r"[^\w-]") def build_fingerprint(path, version, hash_value): path_parts = path.split("/") @@ -9,7 +9,7 @@ def build_fingerprint(path, version, hash_value): return "{}.v{}m{}.{}".format( "/".join(path_parts[:-1] + [filename]), - str(version).replace(".", "_").replace("+", "__"), + re.sub(version_clean, "_", str(version)), hash_value, extension, ) diff --git a/tests/unit/test_fingerprint.py b/tests/unit/test_fingerprint.py index 24a5332236..97037e7bb5 100644 --- a/tests/unit/test_fingerprint.py +++ b/tests/unit/test_fingerprint.py @@ -19,7 +19,7 @@ }, { "path": "react@16.8.6.min.js", - "fingerprint": "react@16.v1_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", + "fingerprint": "react@16.v1_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", "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", "hash": "1234567890abcdefABCDEF", },