dara-core 1.16.1__py3-none-any.whl → 1.16.2__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.
@@ -21,6 +21,7 @@ from contextlib import contextmanager
21
21
  from contextvars import ContextVar
22
22
  from typing import Any, Callable, Generic, List, Optional, TypeVar
23
23
 
24
+ from fastapi.encoders import jsonable_encoder
24
25
  from pydantic import (
25
26
  ConfigDict,
26
27
  SerializerFunctionWrapHandler,
@@ -108,14 +109,10 @@ class Variable(NonDataVariable, Generic[VariableType]):
108
109
  This ensures that users can define a serializer with config.add_encoder and it will be used
109
110
  when serializing the Variable.default.
110
111
  """
111
- from dara.core.internal.encoder_registry import encoder_registry
112
-
113
- default_type = type(default)
112
+ from dara.core.internal.encoder_registry import get_jsonable_encoder
114
113
 
115
114
  try:
116
- for encoder_type, encoder in encoder_registry.items():
117
- if default_type is encoder_type or _is_subclass_safe(default_type, encoder_type):
118
- return encoder['serialize'](default)
115
+ return jsonable_encoder(default, custom_encoder=get_jsonable_encoder())
119
116
  except Exception as e:
120
117
  dev_logger.error(
121
118
  f'Error serializing default value of Variable {self.uid}, falling back to default serialization',
@@ -19,6 +19,7 @@ from inspect import Parameter, isclass
19
19
  from typing import (
20
20
  Any,
21
21
  Callable,
22
+ Dict,
22
23
  MutableMapping,
23
24
  Optional,
24
25
  Type,
@@ -196,6 +197,7 @@ encoder_registry: MutableMapping[Type[Any], Encoder] = {
196
197
  try:
197
198
  # technically you can use dara core without this package
198
199
  from cai_causal_graph import CausalGraph, Skeleton
200
+ from cai_causal_graph.graph_components import Node
199
201
  except ImportError:
200
202
  # If the import fails, we don't need to register the encoders for these types
201
203
  pass
@@ -204,10 +206,18 @@ else:
204
206
  {
205
207
  CausalGraph: Encoder(serialize=lambda x: x.to_dict(), deserialize=lambda x: CausalGraph.from_dict(x)),
206
208
  Skeleton: Encoder(serialize=lambda x: x.to_dict(), deserialize=lambda x: Skeleton.from_dict(x)),
209
+ Node: Encoder(serialize=lambda x: x.to_dict(), deserialize=lambda x: Node.from_dict(x)),
207
210
  }
208
211
  )
209
212
 
210
213
 
214
+ def get_jsonable_encoder() -> Dict[Type[Any], Callable[..., Any]]:
215
+ """
216
+ Get the encoder registry as a dict of {type: serialize} pairs
217
+ """
218
+ return {k: v['serialize'] for k, v in encoder_registry.items()}
219
+
220
+
211
221
  def deserialize(value: Any, typ: Optional[Type]):
212
222
  """
213
223
  Deserialize a value into a given type.
@@ -45,7 +45,7 @@ class Settings(BaseSettings):
45
45
  sso_jwt_algo: str = 'ES256'
46
46
  sso_verify_audience: bool = False
47
47
  sso_extra_audience: Optional[List[str]] = None
48
- model_config = SettingsConfigDict(env_file='.env')
48
+ model_config = SettingsConfigDict(env_file='.env', extra='allow')
49
49
 
50
50
 
51
51
  def generate_env_content():
@@ -14,6 +14,12 @@ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14
14
  See the License for the specific language governing permissions and
15
15
  limitations under the License.
16
16
  """
17
+
18
+ from typing import Optional # needed for model_rebuild
19
+
20
+ from pydantic import BaseModel
21
+
22
+ from dara.core.interactivity import Variable # needed for model_rebuild
17
23
  from dara.core.visual.components.dynamic_component import (
18
24
  DynamicComponent,
19
25
  DynamicComponentDef,
@@ -53,3 +59,12 @@ __all__ = [
53
59
  'RowFallbackDef',
54
60
  'Fallback',
55
61
  ]
62
+
63
+ for symbol in list(globals().values()) + [Fallback.Default, Fallback.Row]:
64
+ try:
65
+ if issubclass(symbol, BaseModel) and symbol is not BaseModel:
66
+ symbol.model_rebuild()
67
+ except Exception as e:
68
+ from dara.core.logging import dev_logger
69
+
70
+ dev_logger.warning(f'Error rebuilding model "{symbol}": {e}')
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: dara-core
3
- Version: 1.16.1
3
+ Version: 1.16.2
4
4
  Summary: Dara Framework Core
5
5
  Home-page: https://dara.causalens.com/
6
6
  License: Apache-2.0
@@ -20,10 +20,10 @@ Requires-Dist: async-asgi-testclient (>=1.4.11,<2.0.0)
20
20
  Requires-Dist: certifi (>=2024.7.4)
21
21
  Requires-Dist: click (==8.1.3)
22
22
  Requires-Dist: colorama (>=0.4.6,<0.5.0)
23
- Requires-Dist: create-dara-app (==1.16.1)
23
+ Requires-Dist: create-dara-app (==1.16.2)
24
24
  Requires-Dist: croniter (>=1.0.15,<3.0.0)
25
25
  Requires-Dist: cryptography (>=42.0.4)
26
- Requires-Dist: dara-components (==1.16.1) ; extra == "all"
26
+ Requires-Dist: dara-components (==1.16.2) ; extra == "all"
27
27
  Requires-Dist: exceptiongroup (>=1.1.3,<2.0.0)
28
28
  Requires-Dist: fastapi (==0.109.0)
29
29
  Requires-Dist: fastapi_vite_dara (==0.4.0)
@@ -52,7 +52,7 @@ Description-Content-Type: text/markdown
52
52
 
53
53
  # Dara Application Framework
54
54
 
55
- <img src="https://github.com/causalens/dara/blob/v1.16.1/img/dara_light.svg?raw=true">
55
+ <img src="https://github.com/causalens/dara/blob/v1.16.2/img/dara_light.svg?raw=true">
56
56
 
57
57
  ![Master tests](https://github.com/causalens/dara/actions/workflows/tests.yml/badge.svg?branch=master)
58
58
  [![License](https://img.shields.io/badge/License-Apache_2.0-blue.svg)](https://www.apache.org/licenses/LICENSE-2.0)
@@ -97,7 +97,7 @@ source .venv/bin/activate
97
97
  dara start
98
98
  ```
99
99
 
100
- ![Dara App](https://github.com/causalens/dara/blob/v1.16.1/img/components_gallery.png?raw=true)
100
+ ![Dara App](https://github.com/causalens/dara/blob/v1.16.2/img/components_gallery.png?raw=true)
101
101
 
102
102
  Note: `pip` installation uses [PEP 660](https://peps.python.org/pep-0660/) `pyproject.toml`-based editable installs which require `pip >= 21.3` and `setuptools >= 64.0.0`. You can upgrade both with:
103
103
 
@@ -114,9 +114,9 @@ Explore some of our favorite apps - a great way of getting started and getting t
114
114
 
115
115
  | Dara App | Description |
116
116
  | -------------------------------------------------------------------------------------------------------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
117
- | ![Large Language Model](https://github.com/causalens/dara/blob/v1.16.1/img/llm.png?raw=true) | Demonstrates how to use incorporate a LLM chat box into your decision app to understand model insights |
118
- | ![Plot Interactivity](https://github.com/causalens/dara/blob/v1.16.1/img/plot_interactivity.png?raw=true) | Demonstrates how to enable the user to interact with plots, trigger actions based on clicks, mouse movements and other interactions with `Bokeh` or `Plotly` plots |
119
- | ![Graph Editor](https://github.com/causalens/dara/blob/v1.16.1/img/graph_viewer.png?raw=true) | Demonstrates how to use the `CausalGraphViewer` component to display your graphs or networks, customising the displayed information through colors and tooltips, and updating the page based on user interaction. |
117
+ | ![Large Language Model](https://github.com/causalens/dara/blob/v1.16.2/img/llm.png?raw=true) | Demonstrates how to use incorporate a LLM chat box into your decision app to understand model insights |
118
+ | ![Plot Interactivity](https://github.com/causalens/dara/blob/v1.16.2/img/plot_interactivity.png?raw=true) | Demonstrates how to enable the user to interact with plots, trigger actions based on clicks, mouse movements and other interactions with `Bokeh` or `Plotly` plots |
119
+ | ![Graph Editor](https://github.com/causalens/dara/blob/v1.16.2/img/graph_viewer.png?raw=true) | Demonstrates how to use the `CausalGraphViewer` component to display your graphs or networks, customising the displayed information through colors and tooltips, and updating the page based on user interaction. |
120
120
 
121
121
  Check out our [App Gallery](https://dara.causalens.com/gallery) for more inspiration!
122
122
 
@@ -143,9 +143,9 @@ And the supporting UI packages and tools.
143
143
  - `ui-utils` - miscellaneous utility functions
144
144
  - `ui-widgets` - widget components
145
145
 
146
- More information on the repository structure can be found in the [CONTRIBUTING.md](https://github.com/causalens/dara/blob/v1.16.1/CONTRIBUTING.md) file.
146
+ More information on the repository structure can be found in the [CONTRIBUTING.md](https://github.com/causalens/dara/blob/v1.16.2/CONTRIBUTING.md) file.
147
147
 
148
148
  ## License
149
149
 
150
- Dara is open-source and licensed under the [Apache 2.0 License](https://github.com/causalens/dara/blob/v1.16.1/LICENSE).
150
+ Dara is open-source and licensed under the [Apache 2.0 License](https://github.com/causalens/dara/blob/v1.16.2/LICENSE).
151
151
 
@@ -24,7 +24,7 @@ dara/core/interactivity/derived_data_variable.py,sha256=u2HOts5rtmzK3D1K383YfYYQ
24
24
  dara/core/interactivity/derived_variable.py,sha256=eJXZ6OJgMdi_LJHvEeO-eRNmunONME2_ANu_5WyRPEU,21728
25
25
  dara/core/interactivity/filtering.py,sha256=BZsWsQvXPhn6WUoAFpAtgN6hXlGDudPbi4h97Qao2ic,9197
26
26
  dara/core/interactivity/non_data_variable.py,sha256=ewPaNaTpMixR5YCVY1pjmyHgeC53K0CsjQxMusbJsiw,1147
27
- dara/core/interactivity/plain_variable.py,sha256=CRDvHgWK2tZQSb8uxK-uIPtvsG1YOcQ5decKXYddeLg,9658
27
+ dara/core/interactivity/plain_variable.py,sha256=RWqD-RO-2RoGxqNQcItBTNrgMB2ssnG2Zc-Omn-H0Yk,9532
28
28
  dara/core/interactivity/url_variable.py,sha256=1ZPFHO3gq7ZuATHt4S9x5ijmk4GBVlUv5KJN6DkM49w,4357
29
29
  dara/core/internal/__init__.py,sha256=QN0wbG9HPQ_vXh8BO8DnBXeYLIENVTNtRmYzZf1lx7c,577
30
30
  dara/core/internal/cache_store/__init__.py,sha256=7JCmQwNIMzfyLZGnsk0BbT1EdDFO_PRZz86E9ATcC6c,139
@@ -38,7 +38,7 @@ dara/core/internal/custom_response.py,sha256=aSPonh8AdRjioTk1MaPwdaJHkO4R4aG_osG
38
38
  dara/core/internal/dependency_resolution.py,sha256=y0CUop-RNNhwZLbafeqjhNEiTY549mLvDyNMTfvEl2Q,5456
39
39
  dara/core/internal/devtools.py,sha256=YmJdYKEqfxrpXFYAM5sJ2wUtUhfvaCMbb9PuDcqFdt4,2441
40
40
  dara/core/internal/download.py,sha256=2_fNIWDsV9f0BptTQRhBuIFXOO4th9pcYaIB7lsPcJU,3183
41
- dara/core/internal/encoder_registry.py,sha256=Jfi1p6qm3xNPH4IoCfOWribqCYHsEU9d7BuV0kVcBWs,10890
41
+ dara/core/internal/encoder_registry.py,sha256=oxsk1liCkN2Oqp4a8EyUxZ5JxIyXly-_UnliAnAhvng,11275
42
42
  dara/core/internal/execute_action.py,sha256=4lcU4ElyMlaybIv5oDlahsncJA4PM-6hLOKbtEpHPRI,7021
43
43
  dara/core/internal/hashing.py,sha256=bKskv9n7s83uYVRxva77EC9exMbMZudmWsrsTPmg8W8,1139
44
44
  dara/core/internal/import_discovery.py,sha256=rh9RS-NCkux_dShIe-XXjX2LiJQN8WiJ5cltrb0YlUE,7853
@@ -56,7 +56,7 @@ dara/core/internal/registry.py,sha256=ONCDusqaL0q59Py_r8-fFVN3vbkkDf5TXzNvbB9SrG
56
56
  dara/core/internal/registry_lookup.py,sha256=8snHu2wUUsngXjHyHh6eZqL_WwonTTQB6-WBX-R_WZg,2238
57
57
  dara/core/internal/routing.py,sha256=-t6EXkQWlri4jcSLRvUce9PCGH4MN3wma2VVOzcBfyI,22918
58
58
  dara/core/internal/scheduler.py,sha256=tKpyN_yhtEepfqfkNTfFep055dl-Lq1_Itte6FTkH9o,12978
59
- dara/core/internal/settings.py,sha256=JWLPP_BrxVPeOKUDEoeWGYAz68hTzD_7h0QBuAwQZfw,3908
59
+ dara/core/internal/settings.py,sha256=ViEni6lVXvbP6Ofb0VoTaWXkI0XajmD-LBpqz1LzwpA,3923
60
60
  dara/core/internal/store.py,sha256=kLRDuYEFwqpJMS0CmL5jGmETs645Xcug4jlelJqk5w4,7706
61
61
  dara/core/internal/tasks.py,sha256=oCfmOMm3pVH0-dvZzJv4nspCRWc_u-J3J7lmNI_ys5E,24763
62
62
  dara/core/internal/utils.py,sha256=b1YYkn8qHl6-GY6cCm2MS1NXRS9j_rElYCKMZOxJgrY,8232
@@ -84,7 +84,7 @@ dara/core/persistence.py,sha256=RaGiGQE3oIzEH7kHC1ZXji2VJa0aP0ewMjt1wRWYWjI,1063
84
84
  dara/core/umd/dara.core.umd.js,sha256=dJIDEmWOw_J6bmktPc4M9LxtKT5MEmkTWd8YeLxihA8,4869323
85
85
  dara/core/umd/style.css,sha256=YQtQ4veiSktnyONl0CU1iU1kKfcQhreH4iASi1MP7Ak,4095007
86
86
  dara/core/visual/__init__.py,sha256=QN0wbG9HPQ_vXh8BO8DnBXeYLIENVTNtRmYzZf1lx7c,577
87
- dara/core/visual/components/__init__.py,sha256=mlmlTKelYVZoyEKGLLO-_HgLwI4uEpVwHVZajpXfSZk,1726
87
+ dara/core/visual/components/__init__.py,sha256=lDbRsrbiWlyrI7DKpLmfuQkwqf-7l4w4UKzF3hkj7Fk,2226
88
88
  dara/core/visual/components/dynamic_component.py,sha256=w7rxrM9ZTNvkHymkAto_s9UKg7EE8VrlpL9QdRe4sgY,692
89
89
  dara/core/visual/components/fallback.py,sha256=9bhDbyGrWjdSuMX_8eSggkicSjgIa8mP75y9oFNIXK8,3303
90
90
  dara/core/visual/components/invalid_component.py,sha256=Q6O9rAwVUNZXjEmliAKLfWf2lsyYK5JhgQvMM6jVco8,901
@@ -104,8 +104,8 @@ dara/core/visual/themes/__init__.py,sha256=aM4mgoIYo2neBSw5FRzswsht7PUKjLthiHLmF
104
104
  dara/core/visual/themes/dark.py,sha256=UQGDooOc8ric73eHs9E0ltYP4UCrwqQ3QxqN_fb4PwY,1942
105
105
  dara/core/visual/themes/definitions.py,sha256=nS_gQvOzCt5hTmj74d0_siq_9QWuj6wNuir4VCHy0Dk,2779
106
106
  dara/core/visual/themes/light.py,sha256=-Tviq8oEwGbdFULoDOqPuHO0UpAZGsBy8qFi0kAGolQ,1944
107
- dara_core-1.16.1.dist-info/LICENSE,sha256=r9u1w2RvpLMV6YjuXHIKXRBKzia3fx_roPwboGcLqCc,10944
108
- dara_core-1.16.1.dist-info/METADATA,sha256=zfnjgw-hLmoDtW7Lq-sTkoKbzxAcOevL2Ea295jwu9E,7439
109
- dara_core-1.16.1.dist-info/WHEEL,sha256=sP946D7jFCHeNz5Iq4fL4Lu-PrWrFsgfLXbbkciIZwg,88
110
- dara_core-1.16.1.dist-info/entry_points.txt,sha256=H__D5sNIGuPIhVam0DChNL-To5k8Y7nY7TAFz9Mz6cc,139
111
- dara_core-1.16.1.dist-info/RECORD,,
107
+ dara_core-1.16.2.dist-info/LICENSE,sha256=r9u1w2RvpLMV6YjuXHIKXRBKzia3fx_roPwboGcLqCc,10944
108
+ dara_core-1.16.2.dist-info/METADATA,sha256=rrrdzdl-JbMz_ZIT0eiuadBvwo62nEolcJzR610KL-4,7439
109
+ dara_core-1.16.2.dist-info/WHEEL,sha256=sP946D7jFCHeNz5Iq4fL4Lu-PrWrFsgfLXbbkciIZwg,88
110
+ dara_core-1.16.2.dist-info/entry_points.txt,sha256=H__D5sNIGuPIhVam0DChNL-To5k8Y7nY7TAFz9Mz6cc,139
111
+ dara_core-1.16.2.dist-info/RECORD,,