synapse-sdk 1.0.0a21__py3-none-any.whl → 1.0.0a22__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.

Potentially problematic release.


This version of synapse-sdk might be problematic. Click here for more details.

@@ -1,10 +1,17 @@
1
1
  from synapse_sdk.clients.backend.annotation import AnnotationClientMixin
2
+ from synapse_sdk.clients.backend.core import CoreClientMixin
2
3
  from synapse_sdk.clients.backend.dataset import DatasetClientMixin
3
4
  from synapse_sdk.clients.backend.integration import IntegrationClientMixin
4
5
  from synapse_sdk.clients.backend.ml import MLClientMixin
5
6
 
6
7
 
7
- class BackendClient(AnnotationClientMixin, DatasetClientMixin, IntegrationClientMixin, MLClientMixin):
8
+ class BackendClient(
9
+ AnnotationClientMixin,
10
+ CoreClientMixin,
11
+ DatasetClientMixin,
12
+ IntegrationClientMixin,
13
+ MLClientMixin,
14
+ ):
8
15
  name = 'Backend'
9
16
  token = None
10
17
  tenant = None
@@ -0,0 +1,32 @@
1
+ import hashlib
2
+ import os
3
+ from pathlib import Path
4
+
5
+ from synapse_sdk.clients.base import BaseClient
6
+
7
+
8
+ class CoreClientMixin(BaseClient):
9
+ def create_chunked_upload(self, file_path):
10
+ def read_file_in_chunks(file_path, chunk_size=1024 * 1024 * 50):
11
+ with open(file_path, 'rb') as file:
12
+ while chunk := file.read(chunk_size):
13
+ yield chunk
14
+
15
+ file_path = Path(file_path)
16
+ size = os.path.getsize(file_path)
17
+ hash_md5 = hashlib.md5()
18
+
19
+ url = 'chunked_upload/'
20
+ offset = 0
21
+ for chunk in read_file_in_chunks(file_path):
22
+ hash_md5.update(chunk)
23
+ data = self._put(
24
+ url,
25
+ data={'filename': file_path.name},
26
+ files={'file': chunk},
27
+ headers={'Content-Range': f'bytes {offset}-{offset + len(chunk) - 1}/{size}'},
28
+ )
29
+ offset = data['offset']
30
+ url = data['url']
31
+
32
+ return self._post(url, data={'md5': hash_md5.hexdigest()})
@@ -14,8 +14,9 @@ class MLClientMixin(BaseClient):
14
14
 
15
15
  def create_model(self, data):
16
16
  path = 'models/'
17
- files = {'file': data.pop('file')}
18
- return self._post(path, data=data, files=files)
17
+ file = data.pop('file')
18
+ data['chunked_upload'] = self.create_chunked_upload(file)['id']
19
+ return self._post(path, data=data)
19
20
 
20
21
  def list_ground_truth_events(self, params=None, url_conversion=None, list_all=False):
21
22
  path = 'ground_truth_events/'
@@ -28,11 +28,13 @@ class BaseClient:
28
28
  def _request(self, method, path, **kwargs):
29
29
  url = self._get_url(path)
30
30
  headers = self._get_headers()
31
+ headers.update(kwargs.pop('headers', {}))
31
32
 
32
33
  if method in ['post', 'put', 'patch']:
33
34
  if kwargs.get('files') is not None:
34
35
  for name, file in kwargs['files'].items():
35
- kwargs['files'][name] = Path(str(file)).open(mode='rb')
36
+ if isinstance(file, (str, Path)):
37
+ kwargs['files'][name] = Path(str(file)).open(mode='rb')
36
38
  for name, value in kwargs['data'].items():
37
39
  if isinstance(value, dict):
38
40
  kwargs['data'][name] = json.dumps(value)
@@ -17,8 +17,8 @@ from synapse_sdk.utils.pydantic.validators import non_blank
17
17
 
18
18
 
19
19
  class TrainRun(Run):
20
- def log_metric(self, key, value, **metrics):
21
- self.log('metric', {'key': key, 'value': value, 'metrics': metrics})
20
+ def log_metric(self, category, key, value, **metrics):
21
+ self.log('metric', {'category': category, 'key': key, 'value': value, 'metrics': metrics})
22
22
 
23
23
 
24
24
  class Hyperparameter(BaseModel):
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: synapse-sdk
3
- Version: 1.0.0a21
3
+ Version: 1.0.0a22
4
4
  Summary: synapse sdk
5
5
  Author-email: datamaker <developer@datamaker.io>
6
6
  License: MIT
@@ -8,18 +8,19 @@ synapse_sdk/loggers.py,sha256=RsDDOiOeUCih1XOkWQJseYdYCX_wt50AZJRe6aPf96Q,4004
8
8
  synapse_sdk/cli/__init__.py,sha256=WmYGW1qZEXXIGJe3SGr8QjOStY4svuZKK1Lp_aPvtPs,140
9
9
  synapse_sdk/cli/create_plugin.py,sha256=egbW_92WwxfHz50Gy4znX5Bf5fxDdQj3GFyd0l3Y3SY,228
10
10
  synapse_sdk/clients/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
11
- synapse_sdk/clients/base.py,sha256=un2vseaQ7YY6rVQqd5fIyzclg7VYLAEx2TwUkZof3ik,3354
11
+ synapse_sdk/clients/base.py,sha256=Yo_WUHNQ2NgNe3sBav0cM_armOdBz34o7fn3lbtrHO0,3462
12
12
  synapse_sdk/clients/exceptions.py,sha256=ylv7x10eOp4aA3a48jwonnvqvkiYwzJYXjkVkRTAjwk,220
13
13
  synapse_sdk/clients/utils.py,sha256=8pPJTdzHiRPSbZMoQYHAgR2BAMO6u_R_jMV6a2p34iQ,392
14
14
  synapse_sdk/clients/agent/__init__.py,sha256=Pz8_iTbIbnb7ywGJ3feqoZVmO2I3mEbwpWsISIxh0BU,1968
15
15
  synapse_sdk/clients/agent/core.py,sha256=YicfkO0YvjDDOt1jNWoZ0mokrh8xxKibBL4qF5yOjKs,169
16
16
  synapse_sdk/clients/agent/ray.py,sha256=JrwLyVOUDG2yYsbPrxyUtWbM-FWp9B6Bl_GdDby0rt8,1559
17
17
  synapse_sdk/clients/agent/service.py,sha256=s7KuPK_DB1nr2VHrigttV1WyFonaGHNrPvU8loRxHcE,478
18
- synapse_sdk/clients/backend/__init__.py,sha256=50MW1CMWGaKnALSv2fOjhJZG55Xb3yrqlKtnSZldwcU,1004
18
+ synapse_sdk/clients/backend/__init__.py,sha256=aozhPhvRTPHz1P90wxEay07B-Ct4vj_yTw5H9_PJEBE,1105
19
19
  synapse_sdk/clients/backend/annotation.py,sha256=eZc5EidgR_RfMGwvv1r1_mLkPdRd8e52c4zuuMjMX34,979
20
+ synapse_sdk/clients/backend/core.py,sha256=5XAOdo6JZ0drfk-FMPJ96SeTd9oja-VnTwzGXdvK7Bg,1027
20
21
  synapse_sdk/clients/backend/dataset.py,sha256=a_svyCKgzF7N99l8V4u4wXD8JxiGuLW9z2EBinnz7b8,1738
21
22
  synapse_sdk/clients/backend/integration.py,sha256=Jg_8fEmbrgYXfZZcG8cDtLxR6ugPmnbNhPDyRu_Uib0,2160
22
- synapse_sdk/clients/backend/ml.py,sha256=vNo1FOG9welXGizcnylLSW_-l9iJSQrTI3DhyCCyFKw,1015
23
+ synapse_sdk/clients/backend/ml.py,sha256=jlkqS9pI0S0Ubq4pWVeaaaPk-E0J-cZg5zkSX7GuQ_o,1063
23
24
  synapse_sdk/clients/ray/__init__.py,sha256=9ZSPXVVxlJ8Wp8ku7l021ENtPjVrGgQDgqifkkVAXgM,187
24
25
  synapse_sdk/clients/ray/core.py,sha256=a4wyCocAma2HAm-BHlbZnoVbpfdR-Aad2FM0z6vPFvw,731
25
26
  synapse_sdk/clients/ray/serve.py,sha256=rbCpXZYWf0oP8XJ9faa9QFNPYU7h8dltIG8xn9ZconY,907
@@ -51,7 +52,7 @@ synapse_sdk/plugins/categories/neural_net/actions/__init__.py,sha256=47DEQpj8HBS
51
52
  synapse_sdk/plugins/categories/neural_net/actions/deployment.py,sha256=i3X2CCWADNAwoDhX-6XTZFEu8MekjJoLuqEojrx1vIc,1730
52
53
  synapse_sdk/plugins/categories/neural_net/actions/inference.py,sha256=i18bDDjkuF9V8nxxW-T_umNIOD-Jnq_MMjIjZc6W8n8,645
53
54
  synapse_sdk/plugins/categories/neural_net/actions/test.py,sha256=JY25eg-Fo6WbgtMkGoo_qNqoaZkp3AQNEypJmeGzEog,320
54
- synapse_sdk/plugins/categories/neural_net/actions/train.py,sha256=ZjBE4uHOdVZ318BuepBt2l0KvSflLr1Fqt3dt4KYXJs,5113
55
+ synapse_sdk/plugins/categories/neural_net/actions/train.py,sha256=4zq2ryWjqDa6MyI2BGe3sAofMh2NeY3XAo-1gEFXBs4,5145
55
56
  synapse_sdk/plugins/categories/neural_net/templates/config.yaml,sha256=dXKB1hO53hDZB73xnxLVCNQl8Sm7svMmVmuMrOCQmEU,343
56
57
  synapse_sdk/plugins/categories/neural_net/templates/plugin/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
57
58
  synapse_sdk/plugins/categories/neural_net/templates/plugin/inference.py,sha256=InfqKWJYi6sqiUnfPKHC5KYGhxckDaWZNQ202u-uVP4,366
@@ -103,9 +104,9 @@ synapse_sdk/utils/pydantic/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJ
103
104
  synapse_sdk/utils/pydantic/config.py,sha256=1vYOcUI35GslfD1rrqhFkNXXJOXt4IDqOPSx9VWGfNE,123
104
105
  synapse_sdk/utils/pydantic/errors.py,sha256=0v0T12eQBr1KrFiEOBu6KMaPK4aPEGEC6etPJGoR5b4,1061
105
106
  synapse_sdk/utils/pydantic/validators.py,sha256=G47P8ObPhsePmd_QZDK8EdPnik2CbaYzr_N4Z6En8dc,193
106
- synapse_sdk-1.0.0a21.dist-info/LICENSE,sha256=bKzmC5YAg4V1Fhl8OO_tqY8j62hgdncAkN7VrdjmrGk,1101
107
- synapse_sdk-1.0.0a21.dist-info/METADATA,sha256=nPwrwB1lHWiSi5rbVdo0Uz2C3xk8M_UtDYF19KXLwSg,1049
108
- synapse_sdk-1.0.0a21.dist-info/WHEEL,sha256=PZUExdf71Ui_so67QXpySuHtCi3-J3wvF4ORK6k_S8U,91
109
- synapse_sdk-1.0.0a21.dist-info/entry_points.txt,sha256=VNptJoGoNJI8yLXfBmhgUefMsmGI0m3-0YoMvrOgbxo,48
110
- synapse_sdk-1.0.0a21.dist-info/top_level.txt,sha256=ytgJMRK1slVOKUpgcw3LEyHHP7S34J6n_gJzdkcSsw8,12
111
- synapse_sdk-1.0.0a21.dist-info/RECORD,,
107
+ synapse_sdk-1.0.0a22.dist-info/LICENSE,sha256=bKzmC5YAg4V1Fhl8OO_tqY8j62hgdncAkN7VrdjmrGk,1101
108
+ synapse_sdk-1.0.0a22.dist-info/METADATA,sha256=amlLIpkW9kqYRzaJueKGATMK0jY0WG4-2SfZP6cre4I,1049
109
+ synapse_sdk-1.0.0a22.dist-info/WHEEL,sha256=PZUExdf71Ui_so67QXpySuHtCi3-J3wvF4ORK6k_S8U,91
110
+ synapse_sdk-1.0.0a22.dist-info/entry_points.txt,sha256=VNptJoGoNJI8yLXfBmhgUefMsmGI0m3-0YoMvrOgbxo,48
111
+ synapse_sdk-1.0.0a22.dist-info/top_level.txt,sha256=ytgJMRK1slVOKUpgcw3LEyHHP7S34J6n_gJzdkcSsw8,12
112
+ synapse_sdk-1.0.0a22.dist-info/RECORD,,