dara-core 1.14.0a3__py3-none-any.whl → 1.14.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.
dara/core/auth/routes.py CHANGED
@@ -19,15 +19,7 @@ from inspect import iscoroutinefunction
19
19
  from typing import Union, cast
20
20
 
21
21
  import jwt
22
- from fastapi import (
23
- APIRouter,
24
- BackgroundTasks,
25
- Cookie,
26
- Depends,
27
- HTTPException,
28
- Request,
29
- Response,
30
- )
22
+ from fastapi import APIRouter, Cookie, Depends, HTTPException, Request, Response
31
23
  from fastapi.security import HTTPAuthorizationCredentials, HTTPBearer
32
24
 
33
25
  from dara.core.auth.base import BaseAuthConfig
@@ -116,7 +108,6 @@ async def _revoke_session(response: Response, credentials: HTTPAuthorizationCred
116
108
  @auth_router.post('/refresh-token')
117
109
  async def handle_refresh_token(
118
110
  response: Response,
119
- background_tasks: BackgroundTasks,
120
111
  dara_refresh_token: Union[str, None] = Cookie(default=None),
121
112
  credentials: HTTPAuthorizationCredentials = Depends(HTTPBearer()),
122
113
  ):
dara/core/auth/utils.py CHANGED
@@ -186,13 +186,13 @@ Shared token refresh cache instance
186
186
 
187
187
 
188
188
  async def cached_refresh_token(
189
- func: Callable[[TokenData, str], Tuple[str, str]], old_token_data: TokenData, refresh_token: str
189
+ do_refresh_token: Callable[[TokenData, str], Tuple[str, str]], old_token_data: TokenData, refresh_token: str
190
190
  ):
191
191
  """
192
192
  A utility to run a token refresh method with caching to prevent multiple concurrent refreshes
193
193
  and short-term caching to reduce unnecessary refreshes from multiple tabs/windows.
194
194
 
195
- :param func: The function to run to refresh the token
195
+ :param do_refresh_token: The function to perform the token refresh
196
196
  :param old_token_data: The old token data
197
197
  :param refresh_token: The refresh token to use
198
198
  """
@@ -213,7 +213,7 @@ async def cached_refresh_token(
213
213
  return cached_result
214
214
 
215
215
  # Run the refresh function
216
- result = await to_thread.run_sync(func, old_token_data, refresh_token)
216
+ result = await to_thread.run_sync(do_refresh_token, old_token_data, refresh_token)
217
217
 
218
218
  # update cache
219
219
  token_refresh_cache.set_cached_value(cache_key, result)
@@ -495,7 +495,7 @@ async def ws_handler(websocket: WebSocket, token: Optional[str] = Query(default=
495
495
  # Heartbeat to keep connection alive
496
496
  if data['type'] == 'ping':
497
497
  await websocket.send_json({'type': 'pong', 'message': None})
498
- if data['type'] == 'token_update':
498
+ elif data['type'] == 'token_update':
499
499
  try:
500
500
  # update Auth context vars for the WS connection
501
501
  update_context(decode_token(data['message']))
@@ -55047,10 +55047,10 @@ You must set sticky: 'left' | 'right' for the '${bugWithUnderColumnsSticky.Heade
55047
55047
  return JSON.stringify(serializable);
55048
55048
  }
55049
55049
  }
55050
- async function request(url, options, extras) {
55050
+ async function request(url, ...options) {
55051
55051
  var _a, _b;
55052
55052
  const sessionToken = await store.getValue(getTokenKey());
55053
- const mergedOptions = extras ? { ...options, ...extras } : options;
55053
+ const mergedOptions = options.reduce((acc, opt) => ({ ...acc, ...opt }), {});
55054
55054
  const { headers, ...other } = mergedOptions;
55055
55055
  const headersInterface = new Headers(headers);
55056
55056
  if (!headersInterface.has("Accept")) {
@@ -55073,7 +55073,6 @@ You must set sticky: 'left' | 'right' for the '${bugWithUnderColumnsSticky.Heade
55073
55073
  const refreshedToken = await store.replaceValue(getTokenKey(), async () => {
55074
55074
  const refreshResponse = await fetch(`${baseUrl}/api/auth/refresh-token`, {
55075
55075
  headers: headersInterface,
55076
- ...other,
55077
55076
  method: "POST"
55078
55077
  });
55079
55078
  if (refreshResponse.ok) {
@@ -58095,7 +58094,7 @@ You must set sticky: 'left' | 'right' for the '${bugWithUnderColumnsSticky.Heade
58095
58094
  }
58096
58095
  return resolver(getOrRegisterPlainVariable(variable, client, taskContext, extras));
58097
58096
  }
58098
- function tokenSubscribe(cb) {
58097
+ function onTokenChange(cb) {
58099
58098
  return store.subscribe(getTokenKey(), cb);
58100
58099
  }
58101
58100
  function getSessionToken() {
@@ -58105,7 +58104,7 @@ You must set sticky: 'left' | 'right' for the '${bugWithUnderColumnsSticky.Heade
58105
58104
  store.setValue(getTokenKey(), token);
58106
58105
  }
58107
58106
  function useSessionToken() {
58108
- return React__namespace.useSyncExternalStore(tokenSubscribe, getSessionToken);
58107
+ return React__namespace.useSyncExternalStore(onTokenChange, getSessionToken);
58109
58108
  }
58110
58109
  const STORE_EXTRAS_MAP = /* @__PURE__ */ new Map();
58111
58110
  function BackendStoreSync({ children }) {
@@ -60391,7 +60390,6 @@ Inferred class string: "${iconClasses}."`
60391
60390
  function TemplateRoot() {
60392
60391
  var _a, _b, _c;
60393
60392
  const token = useSessionToken();
60394
- const [previousToken, setPreviousToken] = React.useState(token);
60395
60393
  const { data: config2 } = useConfig();
60396
60394
  const { data: template, isLoading: templateLoading } = useTemplate(config2 == null ? void 0 : config2.template);
60397
60395
  const { data: actions, isLoading: actionsLoading } = useActions();
@@ -60399,11 +60397,15 @@ Inferred class string: "${iconClasses}."`
60399
60397
  const [wsClient, setWsClient] = React.useState();
60400
60398
  React.useEffect(() => {
60401
60399
  cleanSessionCache(token);
60402
- if (token !== previousToken) {
60403
- wsClient.updateToken(token);
60404
- setPreviousToken(token);
60400
+ }, [token]);
60401
+ React.useEffect(() => {
60402
+ if (!wsClient) {
60403
+ return;
60405
60404
  }
60406
- }, [token, previousToken]);
60405
+ return onTokenChange((newToken) => {
60406
+ wsClient.updateToken(newToken);
60407
+ });
60408
+ }, [wsClient]);
60407
60409
  React.useEffect(() => {
60408
60410
  if (config2 == null ? void 0 : config2.title) {
60409
60411
  document.title = config2.title;
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: dara-core
3
- Version: 1.14.0a3
3
+ Version: 1.14.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.14.0-alpha.3)
23
+ Requires-Dist: create-dara-app (==1.14.2)
24
24
  Requires-Dist: croniter (>=1.0.15,<2.0.0)
25
25
  Requires-Dist: cryptography (>=42.0.4)
26
- Requires-Dist: dara-components (==1.14.0-alpha.3) ; extra == "all"
26
+ Requires-Dist: dara-components (==1.14.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 (==0.3.1)
@@ -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.0-alpha.3/img/dara_light.svg?raw=true">
54
+ <img src="https://github.com/causalens/dara/blob/v1.14.2/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.0-alpha.3/img/components_gallery.png?raw=true)
99
+ ![Dara App](https://github.com/causalens/dara/blob/v1.14.2/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.0-alpha.3/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.0-alpha.3/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.0-alpha.3/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.2/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.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 |
118
+ | ![Graph Editor](https://github.com/causalens/dara/blob/v1.14.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. |
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.0-alpha.3/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.2/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.0-alpha.3/LICENSE).
149
+ Dara is open-source and licensed under the [Apache 2.0 License](https://github.com/causalens/dara/blob/v1.14.2/LICENSE).
150
150
 
@@ -4,8 +4,8 @@ dara/core/auth/__init__.py,sha256=H0bJoXff5wIRZmHvvQ3y9p5SXA9lM8OuLCGceYGqfb0,85
4
4
  dara/core/auth/base.py,sha256=jZNuCMoBHQcxWeLpTUzcxdbkbWUJ42jbtKgnnrwvNVA,3201
5
5
  dara/core/auth/basic.py,sha256=IMkoC1OeeRmnmjIqPHpybs8zSdbLlNKYLRvj08ajirg,4692
6
6
  dara/core/auth/definitions.py,sha256=fx-VCsElP9X97gM0Eql-4lFpLa0UryokmGZhQQat2NU,3511
7
- dara/core/auth/routes.py,sha256=k5y9G-mBDNM3sYX3rk1p1khZPKBD97rPdrs8PV2LSJs,7269
8
- dara/core/auth/utils.py,sha256=KRLKTd3bGxChGREBEzPVarmwxIwb8SB0JazBtUTDTc4,7277
7
+ dara/core/auth/routes.py,sha256=1gOe1Z2Vv5MtpW5uvUYvyYWTJ_BDoLRllji1Plk4nss,7180
8
+ dara/core/auth/utils.py,sha256=_iyS_FExxlYZVDvnHJO5uhFpOW-g8YlhBH9zz8oPsPE,7314
9
9
  dara/core/base_definitions.py,sha256=r_W_qk6_VvvskbPEPjTF6xUh3o_lkNBWMFhN1Pic8Ks,14868
10
10
  dara/core/cli.py,sha256=ycTB7QHCB-74OnKnjXqkXq-GBqyjBqo7u4v1kTgv2jE,7656
11
11
  dara/core/configuration.py,sha256=8VynDds7a_uKXSpeNvjOUK3qfclg0WPniFEspL-6fi8,21153
@@ -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=Im4a5iqdsf8aqjkimleKOX99wE-kvHlHDyICw7bgcCk,20640
63
+ dara/core/internal/websocket.py,sha256=KlEzIofyXWX8Axe4-mUILH1PO6hnK7webmYfDeCkvxc,20642
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=NS7UoNAICvBgpZmZlKQzv9a2x5IhQO8vA_Jfq2HO73E,4877537
84
+ dara/core/umd/dara.core.umd.js,sha256=tKXGvAz2QMypS1jccgAlZiyO3mERdzdRqhPqJ5LGlfg,4877507
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.0a3.dist-info/LICENSE,sha256=r9u1w2RvpLMV6YjuXHIKXRBKzia3fx_roPwboGcLqCc,10944
109
- dara_core-1.14.0a3.dist-info/METADATA,sha256=InpFqVDrz4d-lYG2gFDs175nDCJB3923gfqcEiLRyc4,7457
110
- dara_core-1.14.0a3.dist-info/WHEEL,sha256=sP946D7jFCHeNz5Iq4fL4Lu-PrWrFsgfLXbbkciIZwg,88
111
- dara_core-1.14.0a3.dist-info/entry_points.txt,sha256=H__D5sNIGuPIhVam0DChNL-To5k8Y7nY7TAFz9Mz6cc,139
112
- dara_core-1.14.0a3.dist-info/RECORD,,
108
+ dara_core-1.14.2.dist-info/LICENSE,sha256=r9u1w2RvpLMV6YjuXHIKXRBKzia3fx_roPwboGcLqCc,10944
109
+ dara_core-1.14.2.dist-info/METADATA,sha256=j6suOxjKVn_HOFJ_J9SwtPpl_GchXjv02nmb4wz6xBI,7383
110
+ dara_core-1.14.2.dist-info/WHEEL,sha256=sP946D7jFCHeNz5Iq4fL4Lu-PrWrFsgfLXbbkciIZwg,88
111
+ dara_core-1.14.2.dist-info/entry_points.txt,sha256=H__D5sNIGuPIhVam0DChNL-To5k8Y7nY7TAFz9Mz6cc,139
112
+ dara_core-1.14.2.dist-info/RECORD,,