dara-core 1.18.9__py3-none-any.whl → 1.18.10__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.
@@ -22,7 +22,6 @@ from typing import Optional, Union, cast
22
22
 
23
23
  from anyio.abc import TaskGroup
24
24
  from pandas import DataFrame
25
- from pandas.io.json._table_schema import build_table_schema
26
25
  from pydantic import (
27
26
  BaseModel,
28
27
  ConfigDict,
@@ -44,7 +43,7 @@ from dara.core.interactivity.filtering import (
44
43
  )
45
44
  from dara.core.internal.cache_store import CacheStore
46
45
  from dara.core.internal.hashing import hash_object
47
- from dara.core.internal.pandas_utils import append_index, df_convert_to_internal
46
+ from dara.core.internal.pandas_utils import append_index, df_convert_to_internal, get_schema
48
47
  from dara.core.internal.utils import call_async
49
48
  from dara.core.internal.websocket import WebsocketManager
50
49
  from dara.core.logging import eng_logger
@@ -230,7 +229,7 @@ class DataVariable(AnyDataVariable):
230
229
  store.set(
231
230
  var_entry,
232
231
  key=cls._get_schema_cache_key(var_entry.uid),
233
- value=build_table_schema(df_convert_to_internal(entry.data)),
232
+ value=get_schema(df_convert_to_internal(entry.data)),
234
233
  pin=True,
235
234
  ),
236
235
  )
@@ -23,7 +23,6 @@ from typing import Any, Callable, List, Optional, Union, cast
23
23
  from uuid import uuid4
24
24
 
25
25
  from pandas import DataFrame
26
- from pandas.io.json._table_schema import build_table_schema
27
26
  from pydantic import ConfigDict, SerializerFunctionWrapHandler, model_serializer
28
27
 
29
28
  from dara.core.base_definitions import (
@@ -52,7 +51,7 @@ from dara.core.interactivity.filtering import (
52
51
  )
53
52
  from dara.core.internal.cache_store import CacheStore
54
53
  from dara.core.internal.hashing import hash_object
55
- from dara.core.internal.pandas_utils import append_index, df_convert_to_internal
54
+ from dara.core.internal.pandas_utils import append_index, df_convert_to_internal, get_schema
56
55
  from dara.core.internal.tasks import MetaTask, Task, TaskManager
57
56
  from dara.core.logging import eng_logger
58
57
 
@@ -210,7 +209,7 @@ class DerivedDataVariable(AnyDataVariable, DerivedVariable):
210
209
  store.set(
211
210
  registry_entry=var_entry,
212
211
  key=cls._get_schema_cache_key(value['cache_key']),
213
- value=build_table_schema(
212
+ value=get_schema(
214
213
  df_convert_to_internal(cast(DataFrame, value['value'])),
215
214
  )
216
215
  if isinstance(value['value'], DataFrame)
@@ -65,6 +65,9 @@ def df_convert_to_internal(original_df: DataFrame) -> DataFrame:
65
65
  if any(isinstance(c, str) and c.startswith('__col__') for c in df.columns):
66
66
  return df
67
67
 
68
+ # Append index to match the way we process the original DataFrame
69
+ df = cast(DataFrame, append_index(df))
70
+
68
71
  # Handle hierarchical columns: [(A, B), (A, C)] -> ['A_B', 'A_C']
69
72
  if isinstance(df.columns, MultiIndex):
70
73
  df.columns = ['_'.join(col).strip() if col[0] != INDEX else INDEX for col in df.columns.values]
@@ -90,4 +93,19 @@ def df_convert_to_internal(original_df: DataFrame) -> DataFrame:
90
93
 
91
94
 
92
95
  def df_to_json(df: DataFrame) -> str:
93
- return df_convert_to_internal(df).to_json(orient='records') or ''
96
+ return df_convert_to_internal(df).to_json(orient='records', date_unit='ns') or ''
97
+
98
+
99
+ def get_schema(df: DataFrame):
100
+ from pandas.io.json._table_schema import build_table_schema
101
+
102
+ raw_schema = build_table_schema(df)
103
+
104
+ for field_data in cast(list, raw_schema['fields']):
105
+ if field_data.get('type') == 'datetime':
106
+ # for datetime fields we need to know the resolution, so we get the actual e.g. `datetime64[ns]` string
107
+ column_name = field_data.get('name')
108
+ dtype_str = str(df[column_name].dtype)
109
+ field_data['type'] = dtype_str
110
+
111
+ return raw_schema
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: dara-core
3
- Version: 1.18.9
3
+ Version: 1.18.10
4
4
  Summary: Dara Framework Core
5
5
  Home-page: https://dara.causalens.com/
6
6
  License: Apache-2.0
@@ -21,10 +21,10 @@ Requires-Dist: cachetools (>=5.0.0,<6.0.0)
21
21
  Requires-Dist: certifi (>=2024.7.4)
22
22
  Requires-Dist: click (==8.1.3)
23
23
  Requires-Dist: colorama (>=0.4.6,<0.5.0)
24
- Requires-Dist: create-dara-app (==1.18.9)
24
+ Requires-Dist: create-dara-app (==1.18.10)
25
25
  Requires-Dist: croniter (>=1.0.15,<3.0.0)
26
26
  Requires-Dist: cryptography (>=42.0.4)
27
- Requires-Dist: dara-components (==1.18.9) ; extra == "all"
27
+ Requires-Dist: dara-components (==1.18.10) ; extra == "all"
28
28
  Requires-Dist: exceptiongroup (>=1.1.3,<2.0.0)
29
29
  Requires-Dist: fastapi (>=0.115.0,<0.116.0)
30
30
  Requires-Dist: fastapi_vite_dara (==0.4.0)
@@ -55,7 +55,7 @@ Description-Content-Type: text/markdown
55
55
 
56
56
  # Dara Application Framework
57
57
 
58
- <img src="https://github.com/causalens/dara/blob/v1.18.9/img/dara_light.svg?raw=true">
58
+ <img src="https://github.com/causalens/dara/blob/v1.18.10/img/dara_light.svg?raw=true">
59
59
 
60
60
  ![Master tests](https://github.com/causalens/dara/actions/workflows/tests.yml/badge.svg?branch=master)
61
61
  [![License](https://img.shields.io/badge/License-Apache_2.0-blue.svg)](https://www.apache.org/licenses/LICENSE-2.0)
@@ -100,7 +100,7 @@ source .venv/bin/activate
100
100
  dara start
101
101
  ```
102
102
 
103
- ![Dara App](https://github.com/causalens/dara/blob/v1.18.9/img/components_gallery.png?raw=true)
103
+ ![Dara App](https://github.com/causalens/dara/blob/v1.18.10/img/components_gallery.png?raw=true)
104
104
 
105
105
  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:
106
106
 
@@ -117,9 +117,9 @@ Explore some of our favorite apps - a great way of getting started and getting t
117
117
 
118
118
  | Dara App | Description |
119
119
  | -------------------------------------------------------------------------------------------------------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
120
- | ![Large Language Model](https://github.com/causalens/dara/blob/v1.18.9/img/llm.png?raw=true) | Demonstrates how to use incorporate a LLM chat box into your decision app to understand model insights |
121
- | ![Plot Interactivity](https://github.com/causalens/dara/blob/v1.18.9/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 |
122
- | ![Graph Editor](https://github.com/causalens/dara/blob/v1.18.9/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
+ | ![Large Language Model](https://github.com/causalens/dara/blob/v1.18.10/img/llm.png?raw=true) | Demonstrates how to use incorporate a LLM chat box into your decision app to understand model insights |
121
+ | ![Plot Interactivity](https://github.com/causalens/dara/blob/v1.18.10/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 |
122
+ | ![Graph Editor](https://github.com/causalens/dara/blob/v1.18.10/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. |
123
123
 
124
124
  Check out our [App Gallery](https://dara.causalens.com/gallery) for more inspiration!
125
125
 
@@ -146,9 +146,9 @@ And the supporting UI packages and tools.
146
146
  - `ui-utils` - miscellaneous utility functions
147
147
  - `ui-widgets` - widget components
148
148
 
149
- More information on the repository structure can be found in the [CONTRIBUTING.md](https://github.com/causalens/dara/blob/v1.18.9/CONTRIBUTING.md) file.
149
+ More information on the repository structure can be found in the [CONTRIBUTING.md](https://github.com/causalens/dara/blob/v1.18.10/CONTRIBUTING.md) file.
150
150
 
151
151
  ## License
152
152
 
153
- Dara is open-source and licensed under the [Apache 2.0 License](https://github.com/causalens/dara/blob/v1.18.9/LICENSE).
153
+ Dara is open-source and licensed under the [Apache 2.0 License](https://github.com/causalens/dara/blob/v1.18.10/LICENSE).
154
154
 
@@ -19,8 +19,8 @@ dara/core/interactivity/actions.py,sha256=7CwHN2gmdzffQzggsWqWW7ppNfdJ0MGSChZiVP
19
19
  dara/core/interactivity/any_data_variable.py,sha256=BftnTPSDjOAqxTz_p4L0n5ngk8dvDip8nu9RZeBDI-c,5323
20
20
  dara/core/interactivity/any_variable.py,sha256=8r9AIu6kBBFYsnTlYprEH8pxUM8RYXs0B2Hr09TrAuw,13678
21
21
  dara/core/interactivity/condition.py,sha256=69tdxgLqNbU-AlwHTWFdp-hvxGDugNnb_McDrz0mDtE,1575
22
- dara/core/interactivity/data_variable.py,sha256=VM1QSU1LBfzp-kOt80v6c4jKtTRwLko8R3UcoXDOuR0,11833
23
- dara/core/interactivity/derived_data_variable.py,sha256=XYAp3o6rAmGzrLBdrxvlgDSjqE7mzLcmxeiq6eQmCMA,15435
22
+ dara/core/interactivity/data_variable.py,sha256=qnk6RNY2f4QkLsy5D-Eq-NF6rySmRDsTWie-yLBCdAk,11777
23
+ dara/core/interactivity/derived_data_variable.py,sha256=liPA_zr7R2dJUaeAFHvopSxxdia0zO_MRULbPKstWyg,15379
24
24
  dara/core/interactivity/derived_variable.py,sha256=fU0IE6u8mLJyozYl2s0jmxjwPmU0J_Z7vO7KMsYkCTg,24262
25
25
  dara/core/interactivity/filtering.py,sha256=Lce3YnBcC8T-DaLimH06zNcLun2iLm6dVTZerTJRrpA,9022
26
26
  dara/core/interactivity/loop_variable.py,sha256=EqZX3bMCwKmI2Yu4pQ7TJG9hf3PY2AlAIBLxEzHFbTw,2998
@@ -45,7 +45,7 @@ dara/core/internal/execute_action.py,sha256=V5JmAkh-PoXHCNr0xcTtdw4UMOeY6VEOVvW_
45
45
  dara/core/internal/hashing.py,sha256=Iz3FyiroHc_bC8AEtSUFFAIHh6j4Bq_EvxLqInIkAUM,1124
46
46
  dara/core/internal/import_discovery.py,sha256=oyBZayWhfZma4bg-8bamnS4QO1Oba9geGtez_BHut38,8128
47
47
  dara/core/internal/normalization.py,sha256=NDrj3QyqxSLL6sVgATYFehLAJp8IXSBul0h8kG2McAM,6265
48
- dara/core/internal/pandas_utils.py,sha256=SQ6IzsphfSUYheOJSA-zzITRO8zVwVcjfQvsfxpIdr4,2953
48
+ dara/core/internal/pandas_utils.py,sha256=V_cQp1IARrqMJJ0n9r3qFQ8KrKlAgZmpPrbmzlKpQP0,3609
49
49
  dara/core/internal/pool/__init__.py,sha256=pBbXE5GR3abVC9Lg3i0QxfdmsrBDMJUYAYb0SiAEBkk,657
50
50
  dara/core/internal/pool/channel.py,sha256=TbyIE-PnfzzsQYhl3INOs5UIHHbF_h9bMFne5FjbWlQ,4948
51
51
  dara/core/internal/pool/definitions.py,sha256=ICw_Krf-ziVGkzKl4qvvIgKC0Z06bvUehELH5-VMjV0,4645
@@ -107,8 +107,8 @@ dara/core/visual/themes/__init__.py,sha256=aM4mgoIYo2neBSw5FRzswsht7PUKjLthiHLmF
107
107
  dara/core/visual/themes/dark.py,sha256=UQGDooOc8ric73eHs9E0ltYP4UCrwqQ3QxqN_fb4PwY,1942
108
108
  dara/core/visual/themes/definitions.py,sha256=nS_gQvOzCt5hTmj74d0_siq_9QWuj6wNuir4VCHy0Dk,2779
109
109
  dara/core/visual/themes/light.py,sha256=-Tviq8oEwGbdFULoDOqPuHO0UpAZGsBy8qFi0kAGolQ,1944
110
- dara_core-1.18.9.dist-info/LICENSE,sha256=r9u1w2RvpLMV6YjuXHIKXRBKzia3fx_roPwboGcLqCc,10944
111
- dara_core-1.18.9.dist-info/METADATA,sha256=Ur1nLewgg5uJ4VoDjG_TPK_5tCivB06wAHJ_w0wXf1M,7540
112
- dara_core-1.18.9.dist-info/WHEEL,sha256=sP946D7jFCHeNz5Iq4fL4Lu-PrWrFsgfLXbbkciIZwg,88
113
- dara_core-1.18.9.dist-info/entry_points.txt,sha256=H__D5sNIGuPIhVam0DChNL-To5k8Y7nY7TAFz9Mz6cc,139
114
- dara_core-1.18.9.dist-info/RECORD,,
110
+ dara_core-1.18.10.dist-info/LICENSE,sha256=r9u1w2RvpLMV6YjuXHIKXRBKzia3fx_roPwboGcLqCc,10944
111
+ dara_core-1.18.10.dist-info/METADATA,sha256=3tXEH5e1C_BNR-Qm044hrTJe0IL2jGWbeFNUZ56vV1A,7550
112
+ dara_core-1.18.10.dist-info/WHEEL,sha256=sP946D7jFCHeNz5Iq4fL4Lu-PrWrFsgfLXbbkciIZwg,88
113
+ dara_core-1.18.10.dist-info/entry_points.txt,sha256=H__D5sNIGuPIhVam0DChNL-To5k8Y7nY7TAFz9Mz6cc,139
114
+ dara_core-1.18.10.dist-info/RECORD,,