supervisely 6.73.332__py3-none-any.whl → 6.73.333__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/api/task_api.py +1 -1
- supervisely/nn/inference/inference.py +81 -2
- {supervisely-6.73.332.dist-info → supervisely-6.73.333.dist-info}/METADATA +1 -1
- {supervisely-6.73.332.dist-info → supervisely-6.73.333.dist-info}/RECORD +8 -8
- {supervisely-6.73.332.dist-info → supervisely-6.73.333.dist-info}/LICENSE +0 -0
- {supervisely-6.73.332.dist-info → supervisely-6.73.333.dist-info}/WHEEL +0 -0
- {supervisely-6.73.332.dist-info → supervisely-6.73.333.dist-info}/entry_points.txt +0 -0
- {supervisely-6.73.332.dist-info → supervisely-6.73.333.dist-info}/top_level.txt +0 -0
supervisely/api/task_api.py
CHANGED
|
@@ -786,7 +786,7 @@ class TaskApi(ModuleApiBase, ModuleWithStatus):
|
|
|
786
786
|
resp = self._api.post("tasks.data.get", data)
|
|
787
787
|
return resp.json()["result"]
|
|
788
788
|
|
|
789
|
-
def get_field(self, task_id: int, field:
|
|
789
|
+
def get_field(self, task_id: int, field: str):
|
|
790
790
|
"""get_field"""
|
|
791
791
|
result = self.get_fields(task_id, [field])
|
|
792
792
|
return result[field]
|
|
@@ -11,7 +11,7 @@ import time
|
|
|
11
11
|
import uuid
|
|
12
12
|
from collections import OrderedDict, defaultdict
|
|
13
13
|
from concurrent.futures import ThreadPoolExecutor
|
|
14
|
-
from dataclasses import asdict
|
|
14
|
+
from dataclasses import asdict, dataclass
|
|
15
15
|
from functools import partial, wraps
|
|
16
16
|
from pathlib import Path
|
|
17
17
|
from queue import Queue
|
|
@@ -46,7 +46,7 @@ from supervisely.annotation.label import Label
|
|
|
46
46
|
from supervisely.annotation.obj_class import ObjClass
|
|
47
47
|
from supervisely.annotation.tag_collection import TagCollection
|
|
48
48
|
from supervisely.annotation.tag_meta import TagMeta, TagValueType
|
|
49
|
-
from supervisely.api.api import Api
|
|
49
|
+
from supervisely.api.api import Api, ApiField
|
|
50
50
|
from supervisely.api.app_api import WorkflowMeta, WorkflowSettings
|
|
51
51
|
from supervisely.api.image_api import ImageInfo
|
|
52
52
|
from supervisely.app.content import StateJson, get_data_dir
|
|
@@ -91,6 +91,33 @@ except ImportError:
|
|
|
91
91
|
from typing_extensions import Literal
|
|
92
92
|
|
|
93
93
|
|
|
94
|
+
@dataclass
|
|
95
|
+
class AutoRestartInfo:
|
|
96
|
+
deploy_params: dict
|
|
97
|
+
|
|
98
|
+
class Fields:
|
|
99
|
+
AUTO_RESTART_INFO = "autoRestartInfo"
|
|
100
|
+
DEPLOY_PARAMS = "deployParams"
|
|
101
|
+
|
|
102
|
+
def generate_fields(self) -> List[dict]:
|
|
103
|
+
return [
|
|
104
|
+
{
|
|
105
|
+
ApiField.FIELD: self.Fields.AUTO_RESTART_INFO,
|
|
106
|
+
ApiField.PAYLOAD: {self.Fields.DEPLOY_PARAMS: self.deploy_params},
|
|
107
|
+
}
|
|
108
|
+
]
|
|
109
|
+
|
|
110
|
+
@classmethod
|
|
111
|
+
def from_response(cls, data: dict):
|
|
112
|
+
autorestart_info = data.get(cls.Fields.AUTO_RESTART_INFO, None)
|
|
113
|
+
if autorestart_info is None:
|
|
114
|
+
return None
|
|
115
|
+
return cls(deploy_params=autorestart_info.get(cls.Fields.DEPLOY_PARAMS, None))
|
|
116
|
+
|
|
117
|
+
def is_changed(self, deploy_params: dict) -> bool:
|
|
118
|
+
return self.deploy_params != deploy_params
|
|
119
|
+
|
|
120
|
+
|
|
94
121
|
class Inference:
|
|
95
122
|
FRAMEWORK_NAME: str = None
|
|
96
123
|
"""Name of framework to register models in Supervisely"""
|
|
@@ -127,6 +154,7 @@ class Inference:
|
|
|
127
154
|
model_dir = os.path.join(get_data_dir(), "models")
|
|
128
155
|
sly_fs.mkdir(model_dir)
|
|
129
156
|
|
|
157
|
+
self.autorestart = None
|
|
130
158
|
self.device: str = None
|
|
131
159
|
self.runtime: str = None
|
|
132
160
|
self.model_precision: str = None
|
|
@@ -327,6 +355,9 @@ class Inference:
|
|
|
327
355
|
self._user_layout_card.unlock()
|
|
328
356
|
|
|
329
357
|
def set_params_to_gui(self, deploy_params: dict) -> None:
|
|
358
|
+
"""
|
|
359
|
+
Set params for load_model method to GUI.
|
|
360
|
+
"""
|
|
330
361
|
if isinstance(self.gui, GUI.ServingGUI):
|
|
331
362
|
self._user_layout_card.hide()
|
|
332
363
|
self._api_request_model_info.set_text(json.dumps(deploy_params), "json")
|
|
@@ -677,6 +708,16 @@ class Inference:
|
|
|
677
708
|
self.load_model(**deploy_params)
|
|
678
709
|
self._model_served = True
|
|
679
710
|
self._deploy_params = deploy_params
|
|
711
|
+
try:
|
|
712
|
+
if self.autorestart is None:
|
|
713
|
+
logger.debug("Autorestart info is not set. Creating new one.")
|
|
714
|
+
self.autorestart = AutoRestartInfo(self._deploy_params)
|
|
715
|
+
self.api.task.set_fields(self._task_id, self.autorestart.generate_fields())
|
|
716
|
+
elif self.autorestart.is_changed(self._deploy_params):
|
|
717
|
+
logger.debug("Autorestart info is changed. Updating.")
|
|
718
|
+
self.autorestart.deploy_params.update(self._deploy_params)
|
|
719
|
+
except Exception as e:
|
|
720
|
+
logger.warning(f"Failed to update autorestart info: {repr(e)}")
|
|
680
721
|
if self.gui is not None:
|
|
681
722
|
self.update_gui(self._model_served)
|
|
682
723
|
self.gui.show_deployed_model_info(self)
|
|
@@ -2420,6 +2461,29 @@ class Inference:
|
|
|
2420
2461
|
future.add_done_callback(end_callback)
|
|
2421
2462
|
logger.debug("Scheduled task.", extra={"inference_request_uuid": inference_request_uuid})
|
|
2422
2463
|
|
|
2464
|
+
def _deploy_on_autorestart(self):
|
|
2465
|
+
try:
|
|
2466
|
+
self._api_request_model_layout._title = (
|
|
2467
|
+
"Model was deployed during auto restart with the following settings"
|
|
2468
|
+
)
|
|
2469
|
+
self._api_request_model_layout.update_data()
|
|
2470
|
+
deploy_params = self.autorestart.deploy_params
|
|
2471
|
+
if isinstance(self.gui, GUI.ServingGUITemplate):
|
|
2472
|
+
model_files = self._download_model_files(deploy_params)
|
|
2473
|
+
deploy_params["model_files"] = model_files
|
|
2474
|
+
self._load_model_headless(**deploy_params)
|
|
2475
|
+
elif isinstance(self.gui, GUI.ServingGUI):
|
|
2476
|
+
self._load_model(deploy_params)
|
|
2477
|
+
|
|
2478
|
+
self.set_params_to_gui(deploy_params)
|
|
2479
|
+
# update to set correct device
|
|
2480
|
+
device = deploy_params.get("device", "cpu")
|
|
2481
|
+
self.gui.set_deployed(device)
|
|
2482
|
+
return {"result": "model was successfully deployed"}
|
|
2483
|
+
except Exception as e:
|
|
2484
|
+
self.gui._success_label.hide()
|
|
2485
|
+
raise e
|
|
2486
|
+
|
|
2423
2487
|
def serve(self):
|
|
2424
2488
|
if not self._use_gui and not self._is_local_deploy:
|
|
2425
2489
|
Progress("Deploying model ...", 1)
|
|
@@ -2463,6 +2527,21 @@ class Inference:
|
|
|
2463
2527
|
else:
|
|
2464
2528
|
self._app = Application(layout=self.get_ui())
|
|
2465
2529
|
|
|
2530
|
+
try:
|
|
2531
|
+
if self._task_id is not None:
|
|
2532
|
+
logger.debug("Checking autorestart info...")
|
|
2533
|
+
response = self.api.task.get_fields(
|
|
2534
|
+
self._task_id, [AutoRestartInfo.Fields.AUTO_RESTART_INFO]
|
|
2535
|
+
)
|
|
2536
|
+
self.autorestart = AutoRestartInfo.from_response(response)
|
|
2537
|
+
if self.autorestart is not None:
|
|
2538
|
+
logger.debug("Autorestart info:", extra=self.autorestart.deploy_params)
|
|
2539
|
+
self._deploy_on_autorestart()
|
|
2540
|
+
else:
|
|
2541
|
+
logger.debug("Autorestart info is not set.")
|
|
2542
|
+
except Exception:
|
|
2543
|
+
logger.error("Autorestart failed.", exc_info=True)
|
|
2544
|
+
|
|
2466
2545
|
server = self._app.get_server()
|
|
2467
2546
|
self._app.set_ready_check_function(self.is_model_deployed)
|
|
2468
2547
|
|
|
@@ -42,7 +42,7 @@ supervisely/api/remote_storage_api.py,sha256=qTuPhPsstgEjRm1g-ZInddik8BNC_38YvBB
|
|
|
42
42
|
supervisely/api/report_api.py,sha256=Om7CGulUbQ4BuJ16eDtz7luLe0JQNqab-LoLpUXu7YE,7123
|
|
43
43
|
supervisely/api/role_api.py,sha256=aBL4mxtn08LDPXQuS153-lQFN6N2kcwiz8MbescZ8Gk,3044
|
|
44
44
|
supervisely/api/storage_api.py,sha256=FPGYf3Rn3LBoe38RBNdoiURs306oshzvKOEOQ56XAbs,13030
|
|
45
|
-
supervisely/api/task_api.py,sha256=
|
|
45
|
+
supervisely/api/task_api.py,sha256=ZuPXAfHO5WwWRfR0f93iprkcGlqRMK0q2UXF55dGneo,53873
|
|
46
46
|
supervisely/api/team_api.py,sha256=bEoz3mrykvliLhKnzEy52vzdd_H8VBJCpxF-Bnek9Q8,19467
|
|
47
47
|
supervisely/api/user_api.py,sha256=4S97yIc6AMTZCa0N57lzETnpIE8CeqClvCb6kjUkgfc,24940
|
|
48
48
|
supervisely/api/video_annotation_tool_api.py,sha256=3A9-U8WJzrTShP_n9T8U01M9FzGYdeS51CCBTzUnooo,6686
|
|
@@ -883,7 +883,7 @@ supervisely/nn/benchmark/visualization/widgets/table/__init__.py,sha256=47DEQpj8
|
|
|
883
883
|
supervisely/nn/benchmark/visualization/widgets/table/table.py,sha256=atmDnF1Af6qLQBUjLhK18RMDKAYlxnsuVHMSEa5a-e8,4319
|
|
884
884
|
supervisely/nn/inference/__init__.py,sha256=QFukX2ip-U7263aEPCF_UCFwj6EujbMnsgrXp5Bbt8I,1623
|
|
885
885
|
supervisely/nn/inference/cache.py,sha256=LAirR5mFHCtK59EO1lefQ2qhpp0vBvRTH26EVrs13Y0,32073
|
|
886
|
-
supervisely/nn/inference/inference.py,sha256=
|
|
886
|
+
supervisely/nn/inference/inference.py,sha256=pIylesTNxmhnJqd3sd5cs9QjAew2wPuqH63KOlimOqA,169495
|
|
887
887
|
supervisely/nn/inference/session.py,sha256=jmkkxbe2kH-lEgUU6Afh62jP68dxfhF5v6OGDfLU62E,35757
|
|
888
888
|
supervisely/nn/inference/video_inference.py,sha256=8Bshjr6rDyLay5Za8IB8Dr6FURMO2R_v7aELasO8pR4,5746
|
|
889
889
|
supervisely/nn/inference/gui/__init__.py,sha256=wCxd-lF5Zhcwsis-wScDA8n1Gk_1O00PKgDviUZ3F1U,221
|
|
@@ -1082,9 +1082,9 @@ supervisely/worker_proto/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZ
|
|
|
1082
1082
|
supervisely/worker_proto/worker_api_pb2.py,sha256=VQfi5JRBHs2pFCK1snec3JECgGnua3Xjqw_-b3aFxuM,59142
|
|
1083
1083
|
supervisely/worker_proto/worker_api_pb2_grpc.py,sha256=3BwQXOaP9qpdi0Dt9EKG--Lm8KGN0C5AgmUfRv77_Jk,28940
|
|
1084
1084
|
supervisely_lib/__init__.py,sha256=7-3QnN8Zf0wj8NCr2oJmqoQWMKKPKTECvjH9pd2S5vY,159
|
|
1085
|
-
supervisely-6.73.
|
|
1086
|
-
supervisely-6.73.
|
|
1087
|
-
supervisely-6.73.
|
|
1088
|
-
supervisely-6.73.
|
|
1089
|
-
supervisely-6.73.
|
|
1090
|
-
supervisely-6.73.
|
|
1085
|
+
supervisely-6.73.333.dist-info/LICENSE,sha256=xx0jnfkXJvxRnG63LTGOxlggYnIysveWIZ6H3PNdCrQ,11357
|
|
1086
|
+
supervisely-6.73.333.dist-info/METADATA,sha256=dYUKmQZXH6UwwNCIKAYsS0ycDRlPKEpcUlBM7q6djPU,33596
|
|
1087
|
+
supervisely-6.73.333.dist-info/WHEEL,sha256=iAkIy5fosb7FzIOwONchHf19Qu7_1wCWyFNR5gu9nU0,91
|
|
1088
|
+
supervisely-6.73.333.dist-info/entry_points.txt,sha256=U96-5Hxrp2ApRjnCoUiUhWMqijqh8zLR03sEhWtAcms,102
|
|
1089
|
+
supervisely-6.73.333.dist-info/top_level.txt,sha256=kcFVwb7SXtfqZifrZaSE3owHExX4gcNYe7Q2uoby084,28
|
|
1090
|
+
supervisely-6.73.333.dist-info/RECORD,,
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|