dara-core 1.20.3__py3-none-any.whl → 1.21.1__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- dara/core/__init__.py +8 -42
- dara/core/configuration.py +33 -4
- dara/core/defaults.py +7 -0
- dara/core/definitions.py +22 -35
- dara/core/interactivity/actions.py +29 -28
- dara/core/interactivity/plain_variable.py +6 -2
- dara/core/interactivity/switch_variable.py +2 -2
- dara/core/internal/execute_action.py +75 -6
- dara/core/internal/routing.py +526 -354
- dara/core/internal/tasks.py +1 -1
- dara/core/jinja/index.html +97 -1
- dara/core/jinja/index_autojs.html +116 -10
- dara/core/js_tooling/js_utils.py +35 -14
- dara/core/main.py +137 -89
- dara/core/persistence.py +6 -2
- dara/core/router/__init__.py +5 -0
- dara/core/router/compat.py +77 -0
- dara/core/router/components.py +143 -0
- dara/core/router/dependency_graph.py +62 -0
- dara/core/router/router.py +887 -0
- dara/core/umd/{dara.core.umd.js → dara.core.umd.cjs} +62588 -46966
- dara/core/umd/style.css +52 -9
- dara/core/visual/components/__init__.py +16 -11
- dara/core/visual/components/menu.py +4 -0
- dara/core/visual/components/menu_link.py +1 -0
- dara/core/visual/components/powered_by_causalens.py +9 -0
- dara/core/visual/components/sidebar_frame.py +1 -0
- dara/core/visual/dynamic_component.py +1 -1
- {dara_core-1.20.3.dist-info → dara_core-1.21.1.dist-info}/METADATA +10 -10
- {dara_core-1.20.3.dist-info → dara_core-1.21.1.dist-info}/RECORD +33 -26
- {dara_core-1.20.3.dist-info → dara_core-1.21.1.dist-info}/LICENSE +0 -0
- {dara_core-1.20.3.dist-info → dara_core-1.21.1.dist-info}/WHEEL +0 -0
- {dara_core-1.20.3.dist-info → dara_core-1.21.1.dist-info}/entry_points.txt +0 -0
dara/core/internal/tasks.py
CHANGED
|
@@ -526,7 +526,7 @@ class TaskManager:
|
|
|
526
526
|
"""
|
|
527
527
|
# the result is not deleted, the results are kept in an LRU cache
|
|
528
528
|
# which will clean up older entries
|
|
529
|
-
return await self.store.get(TaskResultEntry, key=task_id)
|
|
529
|
+
return await self.store.get(TaskResultEntry, key=task_id, raise_for_missing=True)
|
|
530
530
|
|
|
531
531
|
async def set_result(self, task_id: str, value: Any):
|
|
532
532
|
"""
|
dara/core/jinja/index.html
CHANGED
|
@@ -6,6 +6,98 @@
|
|
|
6
6
|
<meta name="viewport" content="width=device-width, initial-scale=1" />
|
|
7
7
|
<link id="favicon" rel="icon" type="image/x-icon" href="{{ static_url }}/favicon.ico" />
|
|
8
8
|
|
|
9
|
+
<!-- inline style block to show a spinner before js & css loads -->
|
|
10
|
+
<style>
|
|
11
|
+
body {
|
|
12
|
+
min-height: 100vh;
|
|
13
|
+
margin: 0;
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
html, body, #dara_root {
|
|
17
|
+
display: flex;
|
|
18
|
+
height: 100%;
|
|
19
|
+
width: 100%;
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
.dara-dots-center {
|
|
23
|
+
flex: 1;
|
|
24
|
+
display: flex;
|
|
25
|
+
align-items: center;
|
|
26
|
+
justify-content: center;
|
|
27
|
+
|
|
28
|
+
width: 100%;
|
|
29
|
+
height: 100%;
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
.dara-dots {
|
|
33
|
+
position: relative;
|
|
34
|
+
|
|
35
|
+
width: 10px;
|
|
36
|
+
height: 10px;
|
|
37
|
+
|
|
38
|
+
color: #8D9199;
|
|
39
|
+
|
|
40
|
+
background-color: #8D9199;
|
|
41
|
+
border-radius: 5px;
|
|
42
|
+
|
|
43
|
+
animation: dara-dots-flashing 1s infinite linear alternate;
|
|
44
|
+
animation-delay: 0.5s;
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
.dara-dots::before,
|
|
48
|
+
.dara-dots::after {
|
|
49
|
+
content: '';
|
|
50
|
+
position: absolute;
|
|
51
|
+
top: 0;
|
|
52
|
+
display: inline-block;
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
.dara-dots::before {
|
|
56
|
+
left: -15px;
|
|
57
|
+
|
|
58
|
+
width: 10px;
|
|
59
|
+
height: 10px;
|
|
60
|
+
|
|
61
|
+
color: #8D9199;
|
|
62
|
+
|
|
63
|
+
background-color: #8D9199;
|
|
64
|
+
border-radius: 5px;
|
|
65
|
+
|
|
66
|
+
animation: dara-dots-flashing 1s infinite alternate;
|
|
67
|
+
animation-delay: 0s;
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
.dara-dots::after {
|
|
71
|
+
left: 15px;
|
|
72
|
+
|
|
73
|
+
width: 10px;
|
|
74
|
+
height: 10px;
|
|
75
|
+
|
|
76
|
+
color: #8D9199;
|
|
77
|
+
|
|
78
|
+
background-color: #8D9199;
|
|
79
|
+
border-radius: 5px;
|
|
80
|
+
|
|
81
|
+
animation: dara-dots-flashing 1s infinite alternate;
|
|
82
|
+
animation-delay: 1s;
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
@keyframes dara-dots-flashing {
|
|
86
|
+
0% {
|
|
87
|
+
background-color: #8D9199;
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
50%,
|
|
91
|
+
100% {
|
|
92
|
+
background-color: #C3C6CF;
|
|
93
|
+
}
|
|
94
|
+
}
|
|
95
|
+
</style>
|
|
96
|
+
|
|
97
|
+
<script id="__DARA_DATA__" type="application/json">
|
|
98
|
+
{{ dara_data|safe }}
|
|
99
|
+
</script>
|
|
100
|
+
|
|
9
101
|
<script>
|
|
10
102
|
window.dara = {
|
|
11
103
|
base_url: "{{ base_url }}",
|
|
@@ -29,6 +121,10 @@
|
|
|
29
121
|
</head>
|
|
30
122
|
|
|
31
123
|
<body>
|
|
32
|
-
<div id="dara_root"
|
|
124
|
+
<div id="dara_root">
|
|
125
|
+
<div class="dara-dots-center">
|
|
126
|
+
<div class="dara-dots"></div>
|
|
127
|
+
</div>
|
|
128
|
+
</div>
|
|
33
129
|
</body>
|
|
34
130
|
</html>
|
|
@@ -5,27 +5,133 @@
|
|
|
5
5
|
<title>decisionApp</title>
|
|
6
6
|
<meta name="viewport" content="width=device-width, initial-scale=1" />
|
|
7
7
|
|
|
8
|
+
<!-- inline style block to show a spinner before js & css loads -->
|
|
9
|
+
<style>
|
|
10
|
+
body {
|
|
11
|
+
min-height: 100vh;
|
|
12
|
+
margin: 0;
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
html, body, #dara_root {
|
|
16
|
+
display: flex;
|
|
17
|
+
height: 100%;
|
|
18
|
+
width: 100%;
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
.dara-dots-center {
|
|
22
|
+
flex: 1;
|
|
23
|
+
display: flex;
|
|
24
|
+
align-items: center;
|
|
25
|
+
justify-content: center;
|
|
26
|
+
|
|
27
|
+
width: 100%;
|
|
28
|
+
height: 100%;
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
.dara-dots {
|
|
32
|
+
position: relative;
|
|
33
|
+
|
|
34
|
+
width: 10px;
|
|
35
|
+
height: 10px;
|
|
36
|
+
|
|
37
|
+
color: #8D9199;
|
|
38
|
+
|
|
39
|
+
background-color: #8D9199;
|
|
40
|
+
border-radius: 5px;
|
|
41
|
+
|
|
42
|
+
animation: dara-dots-flashing 1s infinite linear alternate;
|
|
43
|
+
animation-delay: 0.5s;
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
.dara-dots::before,
|
|
47
|
+
.dara-dots::after {
|
|
48
|
+
content: '';
|
|
49
|
+
position: absolute;
|
|
50
|
+
top: 0;
|
|
51
|
+
display: inline-block;
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
.dara-dots::before {
|
|
55
|
+
left: -15px;
|
|
56
|
+
|
|
57
|
+
width: 10px;
|
|
58
|
+
height: 10px;
|
|
59
|
+
|
|
60
|
+
color: #8D9199;
|
|
61
|
+
|
|
62
|
+
background-color: #8D9199;
|
|
63
|
+
border-radius: 5px;
|
|
64
|
+
|
|
65
|
+
animation: dara-dots-flashing 1s infinite alternate;
|
|
66
|
+
animation-delay: 0s;
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
.dara-dots::after {
|
|
70
|
+
left: 15px;
|
|
71
|
+
|
|
72
|
+
width: 10px;
|
|
73
|
+
height: 10px;
|
|
74
|
+
|
|
75
|
+
color: #8D9199;
|
|
76
|
+
|
|
77
|
+
background-color: #8D9199;
|
|
78
|
+
border-radius: 5px;
|
|
79
|
+
|
|
80
|
+
animation: dara-dots-flashing 1s infinite alternate;
|
|
81
|
+
animation-delay: 1s;
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
@keyframes dara-dots-flashing {
|
|
85
|
+
0% {
|
|
86
|
+
background-color: #8D9199;
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
50%,
|
|
90
|
+
100% {
|
|
91
|
+
background-color: #C3C6CF;
|
|
92
|
+
}
|
|
93
|
+
}
|
|
94
|
+
</style>
|
|
95
|
+
|
|
96
|
+
<script id="__DARA_DATA__" type="application/json">
|
|
97
|
+
{{ dara_data|safe }}
|
|
98
|
+
</script>
|
|
99
|
+
|
|
100
|
+
|
|
101
|
+
<script>
|
|
102
|
+
window.dara = {
|
|
103
|
+
base_url: "{{ base_url }}",
|
|
104
|
+
// static_url can be relative or absolute depending on how the backend is configured.
|
|
105
|
+
static_url: "{{ static_url }}",
|
|
106
|
+
};
|
|
107
|
+
|
|
108
|
+
// Setup the javascript hook for getting the current value.
|
|
109
|
+
window.__toDaraUrl = (filename) => `${window.dara.static_url}${filename}`;
|
|
110
|
+
</script>
|
|
111
|
+
|
|
112
|
+
</head>
|
|
113
|
+
|
|
114
|
+
<body>
|
|
115
|
+
<div id="dara_root">
|
|
116
|
+
<div class="dara-dots-center">
|
|
117
|
+
<div class="dara-dots"></div>
|
|
118
|
+
</div>
|
|
119
|
+
</div>
|
|
120
|
+
|
|
121
|
+
<!-- scripts are here to let body start showing up before the js loads -->
|
|
122
|
+
|
|
8
123
|
<!-- jQuery is required for i.e. bokeh; due to bundling issues it needs to be included as UMD -->
|
|
9
124
|
<script
|
|
10
125
|
src="https://code.jquery.com/jquery-3.6.1.slim.min.js"
|
|
11
126
|
integrity="sha256-w8CvhFs7iHNVUtnSP0YKEg00p9Ih13rlL9zGqvLdePA="
|
|
12
127
|
crossorigin="anonymous"
|
|
13
128
|
></script>
|
|
14
|
-
|
|
15
|
-
<script>
|
|
16
|
-
window.dara = {base_url: "$$baseUrl$$"};
|
|
17
|
-
</script>
|
|
18
|
-
|
|
19
129
|
<!-- React/styled-components are included as UMD as they are not bundled inside each module -->
|
|
20
130
|
<script crossorigin src="https://unpkg.com/react@18.2.0/umd/react.development.js"></script>
|
|
21
131
|
<script crossorigin src="https://unpkg.com/react-dom@18.2.0/umd/react-dom.development.js"></script>
|
|
22
132
|
<script crossorigin src="https://unpkg.com/react-is@18.2.0/umd/react-is.development.js"></script>
|
|
23
133
|
<script crossorigin src="https://unpkg.com/styled-components@5.3.1/dist/styled-components.min.js"></script>
|
|
24
134
|
<script crossorigin src="https://unpkg.com/@tanstack/react-query@4/build/umd/index.development.js"></script>
|
|
25
|
-
|
|
26
|
-
</head>
|
|
27
|
-
|
|
28
|
-
<body>
|
|
29
|
-
<div id="dara_root"></div>
|
|
135
|
+
{{ assets | safe }}
|
|
30
136
|
</body>
|
|
31
137
|
</html>
|
dara/core/js_tooling/js_utils.py
CHANGED
|
@@ -383,17 +383,24 @@ def _copytree(src: str, dst: str):
|
|
|
383
383
|
shutil.copy2(from_file, to_file)
|
|
384
384
|
|
|
385
385
|
|
|
386
|
-
def
|
|
386
|
+
def _get_py_version(package_name: str) -> str:
|
|
387
387
|
"""
|
|
388
|
-
|
|
389
|
-
|
|
390
|
-
:param package_name: the name of the package
|
|
388
|
+
Get the python version for a given package name
|
|
391
389
|
"""
|
|
392
390
|
# For dara.* packages, replace . with -
|
|
393
391
|
if package_name.startswith('dara.'):
|
|
394
392
|
package_name = package_name.replace('.', '-')
|
|
395
393
|
|
|
396
|
-
|
|
394
|
+
return version(package_name)
|
|
395
|
+
|
|
396
|
+
|
|
397
|
+
def _py_version_to_js(package_name: str) -> str:
|
|
398
|
+
"""
|
|
399
|
+
Parse a python version string into a JS compatible version string
|
|
400
|
+
|
|
401
|
+
:param package_name: the name of the package
|
|
402
|
+
"""
|
|
403
|
+
raw_version = _get_py_version(package_name)
|
|
397
404
|
parsed_version = Version(raw_version)
|
|
398
405
|
|
|
399
406
|
if parsed_version.is_postrelease:
|
|
@@ -594,7 +601,7 @@ def prepare_autojs_assets(build_cache: BuildCache):
|
|
|
594
601
|
"""
|
|
595
602
|
# copy over dara.core js/css into static dir
|
|
596
603
|
core_path = os.path.dirname(_get_module_file('dara.core'))
|
|
597
|
-
core_js_path = os.path.join(core_path, 'umd', 'dara.core.umd.
|
|
604
|
+
core_js_path = os.path.join(core_path, 'umd', 'dara.core.umd.cjs')
|
|
598
605
|
core_css_path = os.path.join(core_path, 'umd', 'style.css')
|
|
599
606
|
statics = os.path.join(pathlib.Path(__file__).parent.absolute(), 'statics')
|
|
600
607
|
|
|
@@ -619,27 +626,31 @@ def prepare_autojs_assets(build_cache: BuildCache):
|
|
|
619
626
|
module_path = os.path.dirname(_get_module_file(module_name))
|
|
620
627
|
|
|
621
628
|
# Build paths to the JS and CSS assets for the given module
|
|
622
|
-
# Note: this assumes assets structure of module/umd folder with the module.umd.js and style.css file
|
|
629
|
+
# Note: this assumes assets structure of module/umd folder with the module.umd.(c)js and style.css file
|
|
623
630
|
js_asset_path = os.path.join(module_path, 'umd', f'{module_name}.umd.js')
|
|
631
|
+
cjs_asset_path = os.path.join(module_path, 'umd', f'{module_name}.umd.cjs')
|
|
624
632
|
css_asset_path = os.path.join(module_path, 'umd', 'style.css')
|
|
625
633
|
|
|
626
634
|
# copy over the JSS/CSS from python package into dist/umd so they are available under /static
|
|
627
635
|
if os.path.exists(js_asset_path):
|
|
628
636
|
shutil.copy(js_asset_path, os.path.join(build_cache.static_files_dir, f'{module_name}.umd.js'))
|
|
637
|
+
elif os.path.exists(cjs_asset_path):
|
|
638
|
+
shutil.copy(cjs_asset_path, os.path.join(build_cache.static_files_dir, f'{module_name}.umd.js'))
|
|
629
639
|
|
|
630
640
|
if os.path.exists(css_asset_path):
|
|
631
641
|
shutil.copy(css_asset_path, os.path.join(build_cache.static_files_dir, f'{module_name}.css'))
|
|
632
642
|
|
|
633
643
|
|
|
634
|
-
def build_autojs_template(
|
|
644
|
+
def build_autojs_template(build_cache: BuildCache, config: Configuration) -> Dict[str, Any]:
|
|
635
645
|
"""
|
|
636
|
-
Build the autojs html template by
|
|
646
|
+
Build the autojs html template by preparing context data with required tags based on packages loaded
|
|
637
647
|
and including the startup script
|
|
638
648
|
|
|
639
649
|
:param html_template: html template to fill out
|
|
640
650
|
:param build_cache: build cache
|
|
641
651
|
:param config: app configuration
|
|
642
652
|
"""
|
|
653
|
+
|
|
643
654
|
settings = get_settings()
|
|
644
655
|
entry_template = os.path.join(pathlib.Path(__file__).parent.absolute(), 'templates/_entry_autojs.template.tsx')
|
|
645
656
|
with open(entry_template, encoding='utf-8') as f:
|
|
@@ -656,10 +667,12 @@ def build_autojs_template(html_template: str, build_cache: BuildCache, config: C
|
|
|
656
667
|
'$$extraJs$$', config.template_extra_js + '\n' + settings.dara_template_extra_js
|
|
657
668
|
)
|
|
658
669
|
|
|
670
|
+
core_version = _get_py_version('dara.core')
|
|
671
|
+
|
|
659
672
|
package_tags: Dict[str, List[str]] = {
|
|
660
673
|
'dara.core': [
|
|
661
|
-
f'<script crossorigin src="{settings.dara_base_url}/static/dara.core.umd.js"></script>',
|
|
662
|
-
f'<link rel="stylesheet" href="{settings.dara_base_url}/static/dara.core.css"></link>',
|
|
674
|
+
f'<script crossorigin src="{settings.dara_base_url}/static/dara.core.umd.js?v={core_version}"></script>',
|
|
675
|
+
f'<link rel="stylesheet" href="{settings.dara_base_url}/static/dara.core.css?v={core_version}"></link>',
|
|
663
676
|
]
|
|
664
677
|
}
|
|
665
678
|
|
|
@@ -667,15 +680,20 @@ def build_autojs_template(html_template: str, build_cache: BuildCache, config: C
|
|
|
667
680
|
|
|
668
681
|
for module_name in py_modules:
|
|
669
682
|
module_tags = []
|
|
683
|
+
version = _get_py_version(module_name)
|
|
670
684
|
|
|
671
685
|
# Include tag for JS if file exists
|
|
672
686
|
if os.path.exists(os.path.join(config.static_files_dir, f'{module_name}.umd.js')):
|
|
673
|
-
js_tag =
|
|
687
|
+
js_tag = (
|
|
688
|
+
f'<script crossorigin src="{settings.dara_base_url}/static/{module_name}.umd.js?v={version}"></script>'
|
|
689
|
+
)
|
|
674
690
|
module_tags.append(js_tag)
|
|
675
691
|
|
|
676
692
|
# Include tag for CSS if file exists
|
|
677
693
|
if os.path.exists(os.path.join(config.static_files_dir, f'{module_name}.css')):
|
|
678
|
-
css_tag =
|
|
694
|
+
css_tag = (
|
|
695
|
+
f'<link rel="stylesheet" href="{settings.dara_base_url}/static/{module_name}.css?v={version}"></link>'
|
|
696
|
+
)
|
|
679
697
|
module_tags.append(css_tag)
|
|
680
698
|
|
|
681
699
|
package_tags[module_name] = module_tags
|
|
@@ -693,4 +711,7 @@ def build_autojs_template(html_template: str, build_cache: BuildCache, config: C
|
|
|
693
711
|
f'<link id="favicon" rel="icon" type="image/x-icon" href="{settings.dara_base_url}/static/favicon.ico"></link>'
|
|
694
712
|
)
|
|
695
713
|
|
|
696
|
-
return
|
|
714
|
+
return {
|
|
715
|
+
'assets': '\n'.join(tags),
|
|
716
|
+
'base_url': settings.dara_base_url,
|
|
717
|
+
}
|