synapse-sdk 1.0.0a22__py3-none-any.whl → 1.0.0a23__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.
- synapse_sdk/plugins/categories/neural_net/actions/deployment.py +10 -2
- synapse_sdk/plugins/categories/neural_net/actions/inference.py +13 -1
- synapse_sdk/plugins/categories/neural_net/base/__init__.py +0 -0
- synapse_sdk/plugins/categories/neural_net/base/inference.py +37 -0
- {synapse_sdk-1.0.0a22.dist-info → synapse_sdk-1.0.0a23.dist-info}/METADATA +2 -1
- {synapse_sdk-1.0.0a22.dist-info → synapse_sdk-1.0.0a23.dist-info}/RECORD +10 -8
- {synapse_sdk-1.0.0a22.dist-info → synapse_sdk-1.0.0a23.dist-info}/WHEEL +1 -1
- {synapse_sdk-1.0.0a22.dist-info → synapse_sdk-1.0.0a23.dist-info}/LICENSE +0 -0
- {synapse_sdk-1.0.0a22.dist-info → synapse_sdk-1.0.0a23.dist-info}/entry_points.txt +0 -0
- {synapse_sdk-1.0.0a22.dist-info → synapse_sdk-1.0.0a23.dist-info}/top_level.txt +0 -0
|
@@ -21,11 +21,19 @@ class DeploymentAction(Action):
|
|
|
21
21
|
def start(self):
|
|
22
22
|
from ray import serve
|
|
23
23
|
|
|
24
|
+
from synapse_sdk.plugins.categories.neural_net.base.inference import app
|
|
25
|
+
|
|
24
26
|
self.ray_init()
|
|
25
|
-
|
|
27
|
+
|
|
28
|
+
deployment = serve.deployment(ray_actor_options=self.get_actor_options())(serve.ingress(app)(self.entrypoint))
|
|
26
29
|
serve.delete(self.plugin_release.code)
|
|
30
|
+
|
|
27
31
|
# TODO add run object
|
|
28
|
-
serve.run(
|
|
32
|
+
serve.run(
|
|
33
|
+
deployment.bind(self.envs['SYNAPSE_PLUGIN_RUN_HOST']),
|
|
34
|
+
name=self.plugin_release.code,
|
|
35
|
+
route_prefix=f'/{self.plugin_release.checksum}',
|
|
36
|
+
)
|
|
29
37
|
|
|
30
38
|
# 백엔드에 ServeApplication 추가
|
|
31
39
|
serve_application = self.create_serve_application()
|
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
import jwt
|
|
2
|
+
|
|
1
3
|
from synapse_sdk.plugins.categories.base import Action
|
|
2
4
|
from synapse_sdk.plugins.categories.decorators import register_action
|
|
3
5
|
from synapse_sdk.plugins.enums import PluginCategory, RunMethod
|
|
@@ -11,8 +13,18 @@ class InferenceAction(Action):
|
|
|
11
13
|
|
|
12
14
|
def __init__(self, *args, **kwargs):
|
|
13
15
|
super().__init__(*args, **kwargs)
|
|
14
|
-
headers = {'serve_multiplexed_model_id':
|
|
16
|
+
headers = {'serve_multiplexed_model_id': self.get_serve_multiplexed_model_id()}
|
|
15
17
|
if 'headers' in self.params:
|
|
16
18
|
self.params['headers'].update(headers)
|
|
17
19
|
else:
|
|
18
20
|
self.params['headers'] = headers
|
|
21
|
+
|
|
22
|
+
def get_serve_multiplexed_model_id(self):
|
|
23
|
+
return jwt.encode(
|
|
24
|
+
{
|
|
25
|
+
'model': str(self.params.pop('model')),
|
|
26
|
+
'token': self.envs['SYNAPSE_PLUGIN_RUN_USER_TOKEN'],
|
|
27
|
+
'tenant': self.envs['SYNAPSE_PLUGIN_RUN_TENANT'],
|
|
28
|
+
},
|
|
29
|
+
self.envs['SYNAPSE_PLUGIN_RUN_HOST'],
|
|
30
|
+
)
|
|
File without changes
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
import tempfile
|
|
2
|
+
|
|
3
|
+
import jwt
|
|
4
|
+
from clients.backend import BackendClient
|
|
5
|
+
from fastapi import FastAPI
|
|
6
|
+
from ray import serve
|
|
7
|
+
|
|
8
|
+
from synapse_sdk.utils.file import unarchive
|
|
9
|
+
|
|
10
|
+
app = FastAPI()
|
|
11
|
+
|
|
12
|
+
|
|
13
|
+
class BaseInference:
|
|
14
|
+
backend_url = None
|
|
15
|
+
client = None
|
|
16
|
+
|
|
17
|
+
def __init__(self, backend_url):
|
|
18
|
+
self.backend_url = backend_url
|
|
19
|
+
|
|
20
|
+
@serve.multiplexed()
|
|
21
|
+
async def _load_model(self, model_id: str):
|
|
22
|
+
model_info = jwt.decode(model_id, self.backend_url, algorithms='HS256')
|
|
23
|
+
client = BackendClient(self.backend_url, token=model_info['token'], tenant=model_info['tenant'])
|
|
24
|
+
model = client.get_model(model_info['model'])
|
|
25
|
+
with tempfile.TemporaryDirectory() as temp_path:
|
|
26
|
+
unarchive(model['file'], temp_path)
|
|
27
|
+
model['path'] = temp_path
|
|
28
|
+
return await self._get_model(model)
|
|
29
|
+
|
|
30
|
+
async def get_model(self):
|
|
31
|
+
return await self._load_model(serve.get_multiplexed_model_id())
|
|
32
|
+
|
|
33
|
+
async def _get_model(self, model):
|
|
34
|
+
raise NotImplementedError
|
|
35
|
+
|
|
36
|
+
async def infer(self, *args, **kwargs):
|
|
37
|
+
raise NotImplementedError
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.1
|
|
2
2
|
Name: synapse-sdk
|
|
3
|
-
Version: 1.0.
|
|
3
|
+
Version: 1.0.0a23
|
|
4
4
|
Summary: synapse sdk
|
|
5
5
|
Author-email: datamaker <developer@datamaker.io>
|
|
6
6
|
License: MIT
|
|
@@ -16,6 +16,7 @@ Requires-Dist: tqdm
|
|
|
16
16
|
Requires-Dist: python-dotenv
|
|
17
17
|
Requires-Dist: pyyaml
|
|
18
18
|
Requires-Dist: pydantic
|
|
19
|
+
Requires-Dist: pyjwt
|
|
19
20
|
Provides-Extra: all
|
|
20
21
|
Requires-Dist: ray[all]; extra == "all"
|
|
21
22
|
|
|
@@ -49,10 +49,12 @@ synapse_sdk/plugins/categories/import/actions/__init__.py,sha256=47DEQpj8HBSa-_T
|
|
|
49
49
|
synapse_sdk/plugins/categories/import/actions/import.py,sha256=URn6TOp081odMT5D4NlZ2XEcyKelJx8fxzdoKSkXSAI,320
|
|
50
50
|
synapse_sdk/plugins/categories/neural_net/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
51
51
|
synapse_sdk/plugins/categories/neural_net/actions/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
52
|
-
synapse_sdk/plugins/categories/neural_net/actions/deployment.py,sha256=
|
|
53
|
-
synapse_sdk/plugins/categories/neural_net/actions/inference.py,sha256=
|
|
52
|
+
synapse_sdk/plugins/categories/neural_net/actions/deployment.py,sha256=Wmi7in_Mgizt1d5XcDR080h1CIMWKh2_mjub9N380qA,1917
|
|
53
|
+
synapse_sdk/plugins/categories/neural_net/actions/inference.py,sha256=0a655ELqNVjPFZTJDiw4EUdcMCPGveUEKyoYqpwMFBU,1019
|
|
54
54
|
synapse_sdk/plugins/categories/neural_net/actions/test.py,sha256=JY25eg-Fo6WbgtMkGoo_qNqoaZkp3AQNEypJmeGzEog,320
|
|
55
55
|
synapse_sdk/plugins/categories/neural_net/actions/train.py,sha256=4zq2ryWjqDa6MyI2BGe3sAofMh2NeY3XAo-1gEFXBs4,5145
|
|
56
|
+
synapse_sdk/plugins/categories/neural_net/base/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
57
|
+
synapse_sdk/plugins/categories/neural_net/base/inference.py,sha256=EgL_drVmQUtDKmS89mkDHyd7WyOZiUB65uxaomhZeAo,1085
|
|
56
58
|
synapse_sdk/plugins/categories/neural_net/templates/config.yaml,sha256=dXKB1hO53hDZB73xnxLVCNQl8Sm7svMmVmuMrOCQmEU,343
|
|
57
59
|
synapse_sdk/plugins/categories/neural_net/templates/plugin/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
58
60
|
synapse_sdk/plugins/categories/neural_net/templates/plugin/inference.py,sha256=InfqKWJYi6sqiUnfPKHC5KYGhxckDaWZNQ202u-uVP4,366
|
|
@@ -104,9 +106,9 @@ synapse_sdk/utils/pydantic/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJ
|
|
|
104
106
|
synapse_sdk/utils/pydantic/config.py,sha256=1vYOcUI35GslfD1rrqhFkNXXJOXt4IDqOPSx9VWGfNE,123
|
|
105
107
|
synapse_sdk/utils/pydantic/errors.py,sha256=0v0T12eQBr1KrFiEOBu6KMaPK4aPEGEC6etPJGoR5b4,1061
|
|
106
108
|
synapse_sdk/utils/pydantic/validators.py,sha256=G47P8ObPhsePmd_QZDK8EdPnik2CbaYzr_N4Z6En8dc,193
|
|
107
|
-
synapse_sdk-1.0.
|
|
108
|
-
synapse_sdk-1.0.
|
|
109
|
-
synapse_sdk-1.0.
|
|
110
|
-
synapse_sdk-1.0.
|
|
111
|
-
synapse_sdk-1.0.
|
|
112
|
-
synapse_sdk-1.0.
|
|
109
|
+
synapse_sdk-1.0.0a23.dist-info/LICENSE,sha256=bKzmC5YAg4V1Fhl8OO_tqY8j62hgdncAkN7VrdjmrGk,1101
|
|
110
|
+
synapse_sdk-1.0.0a23.dist-info/METADATA,sha256=h1RJux0qCOIxJ69o70K5qUV0Zcd1z6HQf1CrU5w2XyE,1070
|
|
111
|
+
synapse_sdk-1.0.0a23.dist-info/WHEEL,sha256=A3WOREP4zgxI0fKrHUG8DC8013e3dK3n7a6HDbcEIwE,91
|
|
112
|
+
synapse_sdk-1.0.0a23.dist-info/entry_points.txt,sha256=VNptJoGoNJI8yLXfBmhgUefMsmGI0m3-0YoMvrOgbxo,48
|
|
113
|
+
synapse_sdk-1.0.0a23.dist-info/top_level.txt,sha256=ytgJMRK1slVOKUpgcw3LEyHHP7S34J6n_gJzdkcSsw8,12
|
|
114
|
+
synapse_sdk-1.0.0a23.dist-info/RECORD,,
|
|
File without changes
|
|
File without changes
|
|
File without changes
|