dara-core 1.14.8__py3-none-any.whl → 1.14.9__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.
@@ -14,6 +14,7 @@ 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
+
17
18
  import asyncio
18
19
  import inspect
19
20
  import math
@@ -26,7 +27,7 @@ import anyio
26
27
  from anyio import Event, create_memory_object_stream, create_task_group
27
28
  from anyio.streams.memory import MemoryObjectReceiveStream, MemoryObjectSendStream
28
29
  from exceptiongroup import catch
29
- from fastapi import HTTPException, Query
30
+ from fastapi import Query, WebSocketException
30
31
  from fastapi.encoders import jsonable_encoder
31
32
  from jwt import DecodeError
32
33
  from pydantic import BaseModel, Field, parse_obj_as
@@ -80,6 +81,7 @@ class CustomClientMessage(BaseModel):
80
81
 
81
82
  ClientMessage = Union[DaraClientMessage, CustomClientMessage]
82
83
 
84
+
83
85
  # Server message types
84
86
  class ServerMessagePayload(BaseModel):
85
87
  rchan: Optional[str] = Field(default=None, alias='__rchan')
@@ -117,7 +119,7 @@ class DaraServerMessage(BaseModel):
117
119
  """
118
120
 
119
121
  type: Literal['message'] = Field(default='message', const=True)
120
- message: ServerMessagePayload # exact messages expected by frontend are defined in js/api/websocket.tsx
122
+ message: ServerMessagePayload # exact messages expected by frontend are defined in js/api/websocket.tsx
121
123
 
122
124
 
123
125
  class CustomServerMessage(BaseModel):
@@ -204,7 +206,10 @@ class WebSocketHandler:
204
206
  existing_messages.append(message.message)
205
207
  else:
206
208
  existing_messages = [message.message]
207
- self.pending_responses[message_id] = (event, existing_messages)
209
+ self.pending_responses[message_id] = (
210
+ event,
211
+ existing_messages,
212
+ )
208
213
 
209
214
  # If all chunks have been received, set the event to notify the waiting coroutine
210
215
  if len(existing_messages) == message.chunk_count:
@@ -235,7 +240,9 @@ class WebSocketHandler:
235
240
  await self.send_message(
236
241
  CustomServerMessage(
237
242
  message=CustomServerMessagePayload(
238
- kind=kind, data=response, __response_for=message.message.rchan
243
+ kind=kind,
244
+ data=response,
245
+ __response_for=message.message.rchan,
239
246
  )
240
247
  )
241
248
  )
@@ -249,7 +256,9 @@ class WebSocketHandler:
249
256
  return self.send_message(
250
257
  CustomServerMessage(
251
258
  message=CustomServerMessagePayload(
252
- kind=kind, data=response, __response_for=message.message.rchan
259
+ kind=kind,
260
+ data=response,
261
+ __response_for=message.message.rchan,
253
262
  )
254
263
  )
255
264
  )
@@ -405,7 +414,7 @@ async def ws_handler(websocket: WebSocket, token: Optional[str] = Query(default=
405
414
  :param token: The authentication token
406
415
  """
407
416
  if token is None:
408
- raise HTTPException(403, 'Token missing from websocket connection query parameter')
417
+ raise WebSocketException(code=403, reason='Token missing from websocket connection query parameter')
409
418
 
410
419
  from dara.core.auth.definitions import ID_TOKEN, SESSION_ID, USER, UserData
411
420
  from dara.core.internal.registries import (
@@ -420,10 +429,10 @@ async def ws_handler(websocket: WebSocket, token: Optional[str] = Query(default=
420
429
 
421
430
  try:
422
431
  token_content: TokenData = decode_token(token)
423
- except DecodeError:
424
- raise HTTPException(status_code=403, detail='Invalid or expired token')
432
+ except DecodeError as err:
433
+ raise WebSocketException(code=403, reason='Invalid or expired token') from err
425
434
  except AuthError as err:
426
- raise HTTPException(status_code=403, detail=err.detail)
435
+ raise WebSocketException(code=403, reason=str(err.detail)) from err
427
436
 
428
437
  # Register once accepted - map session id to the channel so subsequent requests can identify the client
429
438
  if websocket_registry.has(token_content.session_id):
@@ -56448,6 +56448,7 @@ You must set sticky: 'left' | 'right' for the '${bugWithUnderColumnsSticky.Heade
56448
56448
  }
56449
56449
  initialize(isReconnect = false) {
56450
56450
  const url = new URL(__privateGet(this, _socketUrl));
56451
+ this.token = store.getValueSync(getTokenKey());
56451
56452
  url.searchParams.set("token", this.token);
56452
56453
  const socket = new WebSocket(url);
56453
56454
  __privateSet(this, _pingInterval, setInterval(() => {
@@ -56591,6 +56592,7 @@ You must set sticky: 'left' | 'right' for the '${bugWithUnderColumnsSticky.Heade
56591
56592
  }
56592
56593
  }
56593
56594
  updateToken(newToken) {
56595
+ this.token = newToken;
56594
56596
  if (this.socket.readyState === WebSocket.OPEN) {
56595
56597
  this.socket.send(
56596
56598
  JSON.stringify({
@@ -56598,7 +56600,6 @@ You must set sticky: 'left' | 'right' for the '${bugWithUnderColumnsSticky.Heade
56598
56600
  type: "token_update"
56599
56601
  })
56600
56602
  );
56601
- this.token = newToken;
56602
56603
  }
56603
56604
  }
56604
56605
  sendCustomMessage(kind, data, awaitResponse = false) {
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: dara-core
3
- Version: 1.14.8
3
+ Version: 1.14.9
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.14.8)
23
+ Requires-Dist: create-dara-app (==1.14.9)
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.14.8) ; extra == "all"
26
+ Requires-Dist: dara-components (==1.14.9) ; 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.3.1.0)
@@ -51,7 +51,7 @@ Description-Content-Type: text/markdown
51
51
 
52
52
  # Dara Application Framework
53
53
 
54
- <img src="https://github.com/causalens/dara/blob/v1.14.8/img/dara_light.svg?raw=true">
54
+ <img src="https://github.com/causalens/dara/blob/v1.14.9/img/dara_light.svg?raw=true">
55
55
 
56
56
  ![Master tests](https://github.com/causalens/dara/actions/workflows/tests.yml/badge.svg?branch=master)
57
57
  [![License](https://img.shields.io/badge/License-Apache_2.0-blue.svg)](https://www.apache.org/licenses/LICENSE-2.0)
@@ -96,7 +96,7 @@ source .venv/bin/activate
96
96
  dara start
97
97
  ```
98
98
 
99
- ![Dara App](https://github.com/causalens/dara/blob/v1.14.8/img/components_gallery.png?raw=true)
99
+ ![Dara App](https://github.com/causalens/dara/blob/v1.14.9/img/components_gallery.png?raw=true)
100
100
 
101
101
  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:
102
102
 
@@ -113,9 +113,9 @@ Explore some of our favorite apps - a great way of getting started and getting t
113
113
 
114
114
  | Dara App | Description |
115
115
  | -------------------------------------------------------------------------------------------------------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
116
- | ![Large Language Model](https://github.com/causalens/dara/blob/v1.14.8/img/llm.png?raw=true) | Demonstrates how to use incorporate a LLM chat box into your decision app to understand model insights |
117
- | ![Plot Interactivity](https://github.com/causalens/dara/blob/v1.14.8/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 |
118
- | ![Graph Editor](https://github.com/causalens/dara/blob/v1.14.8/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. |
116
+ | ![Large Language Model](https://github.com/causalens/dara/blob/v1.14.9/img/llm.png?raw=true) | Demonstrates how to use incorporate a LLM chat box into your decision app to understand model insights |
117
+ | ![Plot Interactivity](https://github.com/causalens/dara/blob/v1.14.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 |
118
+ | ![Graph Editor](https://github.com/causalens/dara/blob/v1.14.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. |
119
119
 
120
120
  Check out our [App Gallery](https://dara.causalens.com/gallery) for more inspiration!
121
121
 
@@ -142,9 +142,9 @@ And the supporting UI packages and tools.
142
142
  - `ui-utils` - miscellaneous utility functions
143
143
  - `ui-widgets` - widget components
144
144
 
145
- More information on the repository structure can be found in the [CONTRIBUTING.md](https://github.com/causalens/dara/blob/v1.14.8/CONTRIBUTING.md) file.
145
+ More information on the repository structure can be found in the [CONTRIBUTING.md](https://github.com/causalens/dara/blob/v1.14.9/CONTRIBUTING.md) file.
146
146
 
147
147
  ## License
148
148
 
149
- Dara is open-source and licensed under the [Apache 2.0 License](https://github.com/causalens/dara/blob/v1.14.8/LICENSE).
149
+ Dara is open-source and licensed under the [Apache 2.0 License](https://github.com/causalens/dara/blob/v1.14.9/LICENSE).
150
150
 
@@ -60,7 +60,7 @@ dara/core/internal/settings.py,sha256=wAWxl-HXjq7PW3twe_CrR-UuMRw9VBudC3eRmevZAh
60
60
  dara/core/internal/store.py,sha256=qVyU7JfC3zE2vYC2mfjmvECWMlFS9b-nMF1k-alg4Y8,7756
61
61
  dara/core/internal/tasks.py,sha256=XK-GTIyge8RBYAfzNs3rmLYVNSKIarCzPdqRSVGg-4M,24728
62
62
  dara/core/internal/utils.py,sha256=b1YYkn8qHl6-GY6cCm2MS1NXRS9j_rElYCKMZOxJgrY,8232
63
- dara/core/internal/websocket.py,sha256=KlEzIofyXWX8Axe4-mUILH1PO6hnK7webmYfDeCkvxc,20642
63
+ dara/core/internal/websocket.py,sha256=pbG-4yAalufy24LUZRiqCC5zONEjqPM98djz6ZfYCLk,20940
64
64
  dara/core/jinja/index.html,sha256=iykqiRh3H_HkcjHJeeSRXRu45nZ2y1sZX5FLdPRhlQY,726
65
65
  dara/core/jinja/index_autojs.html,sha256=MRF5J0vNfzZQm9kPEeLl23sbr08fVSRd_PAUD6Fkc_0,1253
66
66
  dara/core/js_tooling/custom_js_scaffold/index.tsx,sha256=FEzSV5o5Nyzxw6eXvGLi7BkEBkXf3brV34_7ATLnY7o,68
@@ -81,7 +81,7 @@ dara/core/metrics/cache.py,sha256=ybofUhZO0TCHeyhB_AtldWk1QTmTKh7GucTXpOkeTFA,25
81
81
  dara/core/metrics/runtime.py,sha256=YP-6Dz0GeI9_Yr7bUk_-OqShyFySGH_AKpDO126l6es,1833
82
82
  dara/core/metrics/utils.py,sha256=rYlBinxFc7VehFT5cTNXLk8gC74UEj7ZGq6vLgIDpSg,2247
83
83
  dara/core/persistence.py,sha256=TO94rPAN7jxZKVCC5YA4eE7GGDoNlCPe-BkkItV2VUE,10379
84
- dara/core/umd/dara.core.umd.js,sha256=W3h6YomUxrDAGy-mTKuZHYwnHobad-y6F9BGk6j21Z0,4878770
84
+ dara/core/umd/dara.core.umd.js,sha256=l6rZUKQV-E-EwfoZRsbdtrlDdJsvd4RnvA_bhoGGZK4,4878822
85
85
  dara/core/umd/style.css,sha256=YQtQ4veiSktnyONl0CU1iU1kKfcQhreH4iASi1MP7Ak,4095007
86
86
  dara/core/visual/__init__.py,sha256=QN0wbG9HPQ_vXh8BO8DnBXeYLIENVTNtRmYzZf1lx7c,577
87
87
  dara/core/visual/components/__init__.py,sha256=O-Em_glGdZNO0LLl2RWmJSrQiXKxliXg_PuhVXGT81I,1811
@@ -105,8 +105,8 @@ dara/core/visual/themes/__init__.py,sha256=aM4mgoIYo2neBSw5FRzswsht7PUKjLthiHLmF
105
105
  dara/core/visual/themes/dark.py,sha256=UQGDooOc8ric73eHs9E0ltYP4UCrwqQ3QxqN_fb4PwY,1942
106
106
  dara/core/visual/themes/definitions.py,sha256=m3oN0txs65MZepqjj7AKMMxybf2aq5fTjcTwJmHqEbk,2744
107
107
  dara/core/visual/themes/light.py,sha256=-Tviq8oEwGbdFULoDOqPuHO0UpAZGsBy8qFi0kAGolQ,1944
108
- dara_core-1.14.8.dist-info/LICENSE,sha256=r9u1w2RvpLMV6YjuXHIKXRBKzia3fx_roPwboGcLqCc,10944
109
- dara_core-1.14.8.dist-info/METADATA,sha256=IoGUbYGqrQv4nGac61-oSeG8yo9qDrbj8dx8P-Vx27k,7390
110
- dara_core-1.14.8.dist-info/WHEEL,sha256=sP946D7jFCHeNz5Iq4fL4Lu-PrWrFsgfLXbbkciIZwg,88
111
- dara_core-1.14.8.dist-info/entry_points.txt,sha256=H__D5sNIGuPIhVam0DChNL-To5k8Y7nY7TAFz9Mz6cc,139
112
- dara_core-1.14.8.dist-info/RECORD,,
108
+ dara_core-1.14.9.dist-info/LICENSE,sha256=r9u1w2RvpLMV6YjuXHIKXRBKzia3fx_roPwboGcLqCc,10944
109
+ dara_core-1.14.9.dist-info/METADATA,sha256=oZS9KyXTmBBH1Vantb_p6XR1Hp0lZBaxw8CCtr7-saQ,7390
110
+ dara_core-1.14.9.dist-info/WHEEL,sha256=sP946D7jFCHeNz5Iq4fL4Lu-PrWrFsgfLXbbkciIZwg,88
111
+ dara_core-1.14.9.dist-info/entry_points.txt,sha256=H__D5sNIGuPIhVam0DChNL-To5k8Y7nY7TAFz9Mz6cc,139
112
+ dara_core-1.14.9.dist-info/RECORD,,