supervisely 6.73.453__py3-none-any.whl → 6.73.454__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.
- supervisely/app/__init__.py +1 -1
- supervisely/app/fastapi/__init__.py +1 -0
- supervisely/app/fastapi/subapp.py +17 -0
- {supervisely-6.73.453.dist-info → supervisely-6.73.454.dist-info}/METADATA +1 -1
- {supervisely-6.73.453.dist-info → supervisely-6.73.454.dist-info}/RECORD +9 -9
- {supervisely-6.73.453.dist-info → supervisely-6.73.454.dist-info}/LICENSE +0 -0
- {supervisely-6.73.453.dist-info → supervisely-6.73.454.dist-info}/WHEEL +0 -0
- {supervisely-6.73.453.dist-info → supervisely-6.73.454.dist-info}/entry_points.txt +0 -0
- {supervisely-6.73.453.dist-info → supervisely-6.73.454.dist-info}/top_level.txt +0 -0
supervisely/app/__init__.py
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
from fastapi import FastAPI
|
2
2
|
from supervisely.app.content import StateJson, DataJson
|
3
3
|
from supervisely.app.content import get_data_dir, get_synced_data_dir
|
4
|
-
from supervisely.app.fastapi.subapp import call_on_autostart
|
4
|
+
from supervisely.app.fastapi.subapp import call_on_autostart, session_user_api
|
5
5
|
import supervisely.app.fastapi as fastapi
|
6
6
|
import supervisely.app.widgets as widgets
|
7
7
|
import supervisely.app.development as development
|
@@ -19,6 +19,7 @@ import jinja2
|
|
19
19
|
import numpy as np
|
20
20
|
import psutil
|
21
21
|
from async_asgi_testclient import TestClient
|
22
|
+
from cachetools import TTLCache
|
22
23
|
from fastapi import (
|
23
24
|
Depends,
|
24
25
|
FastAPI,
|
@@ -70,6 +71,9 @@ HEALTH_ENDPOINTS = ["/health", "/is_ready"]
|
|
70
71
|
# Context variable for response time
|
71
72
|
response_time_ctx: ContextVar[float] = ContextVar("response_time", default=None)
|
72
73
|
|
74
|
+
# Mapping from user_id to Api instance
|
75
|
+
_USER_API_CACHE = TTLCache(maxsize=500, ttl=60 * 15) # Cache up to 15 minutes
|
76
|
+
|
73
77
|
|
74
78
|
class ReadyzFilter(logging.Filter):
|
75
79
|
def filter(self, record):
|
@@ -852,6 +856,10 @@ def _init(
|
|
852
856
|
request.state.api = Api(
|
853
857
|
request.state.server_address, request.state.api_token
|
854
858
|
)
|
859
|
+
if sly_env.is_multiuser_mode_enabled():
|
860
|
+
user_id = sly_env.user_from_multiuser_app()
|
861
|
+
if user_id is not None:
|
862
|
+
_USER_API_CACHE[user_id] = request.state.api
|
855
863
|
else:
|
856
864
|
request.state.api = None
|
857
865
|
|
@@ -1306,3 +1314,12 @@ def call_on_autostart(
|
|
1306
1314
|
|
1307
1315
|
def get_name_from_env(default="Supervisely App"):
|
1308
1316
|
return os.environ.get("APP_NAME", default)
|
1317
|
+
|
1318
|
+
def session_user_api() -> Optional[Api]:
|
1319
|
+
"""Returns the API instance for the current session user."""
|
1320
|
+
if not sly_env.is_multiuser_mode_enabled():
|
1321
|
+
return Api.from_env()
|
1322
|
+
user_id = sly_env.user_from_multiuser_app()
|
1323
|
+
if user_id is None:
|
1324
|
+
return None
|
1325
|
+
return _USER_API_CACHE.get(user_id, None)
|
@@ -82,7 +82,7 @@ supervisely/api/volume/volume_api.py,sha256=7mMfKY4HdzrbBvGZFE1SJiRi4OsgDyk3azz4
|
|
82
82
|
supervisely/api/volume/volume_figure_api.py,sha256=Fs7j3h76kw7EI-o3vJHjpvL4Vxn3Fu-DzhArgK_qrPk,26523
|
83
83
|
supervisely/api/volume/volume_object_api.py,sha256=F7pLV2MTlBlyN6fEKdxBSUatIMGWSuu8bWj3Hvcageo,2139
|
84
84
|
supervisely/api/volume/volume_tag_api.py,sha256=yNGgXz44QBSW2VGlNDOVLqLXnH8Q2fFrxDFb_girYXA,3639
|
85
|
-
supervisely/app/__init__.py,sha256=
|
85
|
+
supervisely/app/__init__.py,sha256=Z3RrMZBsaDuvSOqinD5K2rgQsQ-PuydQ1LaXbB4bXc8,651
|
86
86
|
supervisely/app/content.py,sha256=x4EZ3BbqU_nAaoXqbRspebOXDv_b-Smt0TLC6Tk0Yq0,8484
|
87
87
|
supervisely/app/exceptions.py,sha256=w01IUAq7SUu4FJDahTdR9tCoDnbobFQ6huL0uHCWxZs,1370
|
88
88
|
supervisely/app/export_template.py,sha256=_fI8B2Up0luRbRC6NxaJt-c5Z9MeJYh-RzFv0GARKSw,2801
|
@@ -93,7 +93,7 @@ supervisely/app/widgets_context.py,sha256=JkAd4o87eqhkGJbai-Yq6YHULiPsbp1VwGOSBR
|
|
93
93
|
supervisely/app/development/__init__.py,sha256=f2SpWBcCFPbSEBsJijH25eCAK8NcY2An5NU9vPgCBVo,135
|
94
94
|
supervisely/app/development/development.py,sha256=Ij3tn7HmkHr2RRoYxlpK9xkTGnpFjZwy2kArn6ZxVnA,12505
|
95
95
|
supervisely/app/development/sly-net.sh,sha256=M-RWQ7kygrJm88WGsOW0tEccO0fDgj_xGLI8Ifm-Ie4,1111
|
96
|
-
supervisely/app/fastapi/__init__.py,sha256=
|
96
|
+
supervisely/app/fastapi/__init__.py,sha256=ZT7hgv34YNg0CBWHcdvksqXHCcN23f1YdXp-JZd87Ek,482
|
97
97
|
supervisely/app/fastapi/custom_static_files.py,sha256=5todaVIvUG9sAt6vu1IujJn8N7zTmFhVUfeCVbuXbvc,3391
|
98
98
|
supervisely/app/fastapi/dialog_window.html,sha256=ffaAxjK0TQRa7RrY5oA4uE6RzFuS0VnRG1pfoIzTqVM,1183
|
99
99
|
supervisely/app/fastapi/index.html,sha256=dz_e-0RE5ZbOU0ToUaEHe1ROI6Tc3SPL-mHt1CpZTxQ,8793
|
@@ -101,7 +101,7 @@ supervisely/app/fastapi/multi_user.py,sha256=m8Iy0ibTy85C7JkkovcRbDOirmIaz8BOOmA
|
|
101
101
|
supervisely/app/fastapi/no_html_main.html,sha256=NhQP7noyORBx72lFh1CQKgBRupkWjiq6Gaw-9Hkvg7c,37
|
102
102
|
supervisely/app/fastapi/offline.py,sha256=CwMMkJ1frD6wiZS-SEoNDtQ1UJcJe1Ob6ohE3r4CQL8,7414
|
103
103
|
supervisely/app/fastapi/request.py,sha256=NU7rKmxJ1pfkDZ7_yHckRcRAueJRQIqCor11UO2OHr8,766
|
104
|
-
supervisely/app/fastapi/subapp.py,sha256=
|
104
|
+
supervisely/app/fastapi/subapp.py,sha256=N5ly1SmAslUlzA2b8NRscaTTYkoubak3xmYkp5er8t4,51854
|
105
105
|
supervisely/app/fastapi/templating.py,sha256=etFkNJKvoWsHrHpmgDUuybZXcLuzS1IBRxvPnZlT9K8,2928
|
106
106
|
supervisely/app/fastapi/utils.py,sha256=t_UquzlFrdkKtAJmH6eJ279pE8Aa3BaIu4XjX-SEaIE,946
|
107
107
|
supervisely/app/fastapi/websocket.py,sha256=2RqHoN7a_qPz8WMDSxCih69yyi11AaMiVtBhsyg4gxg,3953
|
@@ -1129,9 +1129,9 @@ supervisely/worker_proto/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZ
|
|
1129
1129
|
supervisely/worker_proto/worker_api_pb2.py,sha256=VQfi5JRBHs2pFCK1snec3JECgGnua3Xjqw_-b3aFxuM,59142
|
1130
1130
|
supervisely/worker_proto/worker_api_pb2_grpc.py,sha256=3BwQXOaP9qpdi0Dt9EKG--Lm8KGN0C5AgmUfRv77_Jk,28940
|
1131
1131
|
supervisely_lib/__init__.py,sha256=yRwzEQmVwSd6lUQoAUdBngKEOlnoQ6hA9ZcoZGJRNC4,331
|
1132
|
-
supervisely-6.73.
|
1133
|
-
supervisely-6.73.
|
1134
|
-
supervisely-6.73.
|
1135
|
-
supervisely-6.73.
|
1136
|
-
supervisely-6.73.
|
1137
|
-
supervisely-6.73.
|
1132
|
+
supervisely-6.73.454.dist-info/LICENSE,sha256=xx0jnfkXJvxRnG63LTGOxlggYnIysveWIZ6H3PNdCrQ,11357
|
1133
|
+
supervisely-6.73.454.dist-info/METADATA,sha256=7C7wpc584Nvw35hqqz7ByMADZ42r06AvxDFgg9yO4Hk,35480
|
1134
|
+
supervisely-6.73.454.dist-info/WHEEL,sha256=iAkIy5fosb7FzIOwONchHf19Qu7_1wCWyFNR5gu9nU0,91
|
1135
|
+
supervisely-6.73.454.dist-info/entry_points.txt,sha256=U96-5Hxrp2ApRjnCoUiUhWMqijqh8zLR03sEhWtAcms,102
|
1136
|
+
supervisely-6.73.454.dist-info/top_level.txt,sha256=kcFVwb7SXtfqZifrZaSE3owHExX4gcNYe7Q2uoby084,28
|
1137
|
+
supervisely-6.73.454.dist-info/RECORD,,
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|