synapse-sdk 1.0.0a27__py3-none-any.whl → 1.0.0a29__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,6 +1,6 @@
1
1
  from pathlib import Path
2
2
 
3
- from dotenv import dotenv_values, set_key, unset_key
3
+ from dotenv import dotenv_values, load_dotenv, set_key, unset_key
4
4
 
5
5
  CONFIG_DIR = Path.home() / '.config' / 'synapse_alias'
6
6
  DEFAULT_FILE = CONFIG_DIR / '__default__'
@@ -41,6 +41,7 @@ def delete_alias_file(alias_name):
41
41
 
42
42
 
43
43
  def get_default_alias():
44
+ ensure_config_dir()
44
45
  if DEFAULT_FILE.exists():
45
46
  default_data = dotenv_values(DEFAULT_FILE)
46
47
  return default_data.get('DEFAULT_ALIAS')
@@ -52,3 +53,9 @@ def set_default_alias(alias_name):
52
53
  ensure_config_dir()
53
54
  with open(DEFAULT_FILE, 'w') as f:
54
55
  f.write(f'DEFAULT_ALIAS={alias_name}\n')
56
+
57
+
58
+ def load_dotenv_default_alias():
59
+ default_alias = get_default_alias()
60
+ if default_alias is not None:
61
+ load_dotenv(CONFIG_DIR / default_alias)
@@ -3,14 +3,14 @@ import os
3
3
  import click
4
4
  from dotenv import load_dotenv
5
5
 
6
- from synapse_sdk.cli.alias.utils import CONFIG_DIR, get_default_alias
6
+ from synapse_sdk.cli.alias.utils import load_dotenv_default_alias
7
7
  from synapse_sdk.i18n import gettext as _
8
8
 
9
9
  from .create import create
10
10
  from .publish import publish
11
11
  from .run import run
12
12
 
13
- load_dotenv(CONFIG_DIR / get_default_alias())
13
+ load_dotenv_default_alias()
14
14
  load_dotenv(os.path.join(os.getcwd(), '.env'), override=True)
15
15
 
16
16
 
@@ -1,4 +1,5 @@
1
1
  from synapse_sdk.clients.base import BaseClient
2
+ from synapse_sdk.utils.file import convert_file_to_base64
2
3
 
3
4
 
4
5
  class IntegrationClientMixin(BaseClient):
@@ -60,6 +61,13 @@ class IntegrationClientMixin(BaseClient):
60
61
 
61
62
  def create_logs(self, data):
62
63
  path = 'logs/'
64
+ if not isinstance(data, list):
65
+ data = [data]
66
+
67
+ for item in data:
68
+ if 'file' in item:
69
+ item['file'] = convert_file_to_base64(item['file'])
70
+
63
71
  return self._post(path, data=data)
64
72
 
65
73
  def create_serve_application(self, data):
synapse_sdk/loggers.py CHANGED
@@ -68,13 +68,16 @@ class BaseLogger:
68
68
 
69
69
  return progress
70
70
 
71
+ def log(self, action, data, file=None):
72
+ raise NotImplementedError
73
+
71
74
 
72
75
  class ConsoleLogger(BaseLogger):
73
76
  def set_progress(self, current, total, category=None):
74
77
  super().set_progress(current, total, category=category)
75
78
  print(self.get_current_progress())
76
79
 
77
- def log(self, action, data):
80
+ def log(self, action, data, file=None):
78
81
  print(action, data)
79
82
 
80
83
 
@@ -99,7 +102,7 @@ class BackendLogger(BaseLogger):
99
102
  except ClientError:
100
103
  pass
101
104
 
102
- def log(self, event, data):
105
+ def log(self, event, data, file=None):
103
106
  print(event, data)
104
107
 
105
108
  log = {
@@ -108,7 +111,11 @@ class BackendLogger(BaseLogger):
108
111
  'datetime': datetime.datetime.now().strftime('%Y-%m-%d %H:%M:%S.%f'),
109
112
  'job': self.job_id,
110
113
  }
114
+ if file:
115
+ log['file'] = file
116
+
111
117
  self.logs_queue.append(log)
118
+
112
119
  try:
113
120
  self.client.create_logs(self.logs_queue)
114
121
  self.logs_queue.clear()
@@ -18,8 +18,13 @@ from synapse_sdk.utils.pydantic.validators import non_blank
18
18
 
19
19
  class TrainRun(Run):
20
20
  def log_metric(self, category, key, value, **metrics):
21
+ # TODO validate input via plugin config
21
22
  self.log('metric', {'category': category, 'key': key, 'value': value, 'metrics': metrics})
22
23
 
24
+ def log_visualization(self, category, group, image, **meta):
25
+ # TODO validate input via plugin config
26
+ self.log('visualization', {'category': category, 'group': group, **meta}, file=image)
27
+
23
28
 
24
29
  class Hyperparameter(BaseModel):
25
30
  batch_size: int
@@ -113,8 +113,8 @@ class Run:
113
113
  def set_progress(self, current, total, category=''):
114
114
  self.logger.set_progress(current, total, category)
115
115
 
116
- def log(self, event, data):
117
- self.logger.log(event, data)
116
+ def log(self, event, data, file=None):
117
+ self.logger.log(event, data, file=file)
118
118
 
119
119
  def log_message(self, message, context=Context.INFO.value):
120
120
  self.logger.log('message', {'context': context, 'content': message})
synapse_sdk/utils/file.py CHANGED
@@ -1,6 +1,8 @@
1
1
  import asyncio
2
+ import base64
2
3
  import hashlib
3
4
  import json
5
+ import mimetypes
4
6
  import operator
5
7
  import zipfile
6
8
  from functools import reduce
@@ -182,3 +184,36 @@ def get_temp_path(sub_path=None):
182
184
  if sub_path:
183
185
  path = path / sub_path
184
186
  return path
187
+
188
+
189
+ def convert_file_to_base64(file_path):
190
+ """
191
+ Convert a file to base64 using pathlib.
192
+
193
+ Args:
194
+ file_path (str): Path to the file to convert
195
+
196
+ Returns:
197
+ str: Base64 encoded string of the file contents
198
+ """
199
+ # Convert string path to Path object
200
+ path = Path(file_path)
201
+
202
+ try:
203
+ # Read binary content of the file
204
+ binary_content = path.read_bytes()
205
+
206
+ # Convert to base64
207
+ base64_encoded = base64.b64encode(binary_content).decode('utf-8')
208
+
209
+ # Get the MIME type of the file
210
+ mime_type, _ = mimetypes.guess_type(path)
211
+ assert mime_type is not None, 'MIME type cannot be guessed'
212
+
213
+ # Convert bytes to string for readable output
214
+ return f'data:{mime_type};base64,{base64_encoded}'
215
+
216
+ except FileNotFoundError:
217
+ raise FileNotFoundError(f'File not found: {file_path}')
218
+ except Exception as e:
219
+ raise Exception(f'Error converting file to base64: {str(e)}')
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.2
2
2
  Name: synapse-sdk
3
- Version: 1.0.0a27
3
+ Version: 1.0.0a29
4
4
  Summary: synapse sdk
5
5
  Author-email: datamaker <developer@datamaker.io>
6
6
  License: MIT
@@ -4,7 +4,7 @@ locale/ko/LC_MESSAGES/messages.mo,sha256=7HJEJA0wKlN14xQ5VF4FCNet54tjw6mfWYj3IaB
4
4
  locale/ko/LC_MESSAGES/messages.po,sha256=TFii_RbURDH-Du_9ZQf3wNh-2briGk1IqY33-9GKrMU,1126
5
5
  synapse_sdk/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
6
6
  synapse_sdk/i18n.py,sha256=VXMR-Zm_1hTAg9iPk3YZNNq-T1Bhx1J2fEtRT6kyYbg,766
7
- synapse_sdk/loggers.py,sha256=RsDDOiOeUCih1XOkWQJseYdYCX_wt50AZJRe6aPf96Q,4004
7
+ synapse_sdk/loggers.py,sha256=OSTDDhEAvj8fiAuYNZqsZ9bygGM20sMC5yJ_nOaLDDU,4155
8
8
  synapse_sdk/types.py,sha256=khzn8KpgxFdn1SrpbcuX84m_Md1Mz_HIoUoPq8uok40,698
9
9
  synapse_sdk/cli/__init__.py,sha256=P-_FXCqb_nTVdQznuHop6kDXF_JuncZpeAmgHiGoILQ,152
10
10
  synapse_sdk/cli/alias/__init__.py,sha256=jDy8N_KupVy7n_jKKWhjQOj76-mR-uoVvMoyzObUkuI,405
@@ -15,8 +15,8 @@ synapse_sdk/cli/alias/delete.py,sha256=V2_5j9IyXIxEO82PL3JJAF7WHrn-LwFe_PyfPJTF5
15
15
  synapse_sdk/cli/alias/list.py,sha256=fsKe5MVyl9ki3bwEwDj1nWAWfnNKOmkLO3bbbHOfsL4,564
16
16
  synapse_sdk/cli/alias/read.py,sha256=gkcSO6zAqvqHMduKIajvzftEgYphp4pIVjsIShgPoHk,349
17
17
  synapse_sdk/cli/alias/update.py,sha256=LOpkpe6ZP_HcOOwC5RkJHVxQuNcQHGnyN98tABjz754,531
18
- synapse_sdk/cli/alias/utils.py,sha256=CyavTlSw7ezkx2LpX2UG9ZJ64oBKQT0pvjRoSX0dtuQ,1346
19
- synapse_sdk/cli/plugin/__init__.py,sha256=A88y2w42BWwwyQoH5KBSNn8r9sJjGg5-cG7gkP25X4M,766
18
+ synapse_sdk/cli/alias/utils.py,sha256=9kWrDfRCFqlkCtLXSleMJ-PH6Q49R1FfnbfyY34ck5s,1540
19
+ synapse_sdk/cli/plugin/__init__.py,sha256=P5WMpTe_cVvaXdZngk8_ugJynRdel9rxVicwi05U3zo,744
20
20
  synapse_sdk/cli/plugin/create.py,sha256=HpYTpohV1NbSrULaVUlc4jWLWznPrx7glgydTM3sS5E,218
21
21
  synapse_sdk/cli/plugin/publish.py,sha256=sIl1wiuSC3lAUpE3rOF4UDKDy2G5EVLlelMjk2aT05g,1221
22
22
  synapse_sdk/cli/plugin/run.py,sha256=xz5LRm3zh8Y9DMjw5FFRFVRWSCWtYfZJskfCmrPikaQ,2598
@@ -32,7 +32,7 @@ synapse_sdk/clients/backend/__init__.py,sha256=aozhPhvRTPHz1P90wxEay07B-Ct4vj_yT
32
32
  synapse_sdk/clients/backend/annotation.py,sha256=eZc5EidgR_RfMGwvv1r1_mLkPdRd8e52c4zuuMjMX34,979
33
33
  synapse_sdk/clients/backend/core.py,sha256=5XAOdo6JZ0drfk-FMPJ96SeTd9oja-VnTwzGXdvK7Bg,1027
34
34
  synapse_sdk/clients/backend/dataset.py,sha256=w7izflbTjHKysiDl7ia7MAO391_dzN2ofK40A7QwtBQ,1721
35
- synapse_sdk/clients/backend/integration.py,sha256=Jg_8fEmbrgYXfZZcG8cDtLxR6ugPmnbNhPDyRu_Uib0,2160
35
+ synapse_sdk/clients/backend/integration.py,sha256=ekuMqpJ2OIt8ko3NISZCIvtoer7mhvDjXUgPXV4ju6E,2410
36
36
  synapse_sdk/clients/backend/ml.py,sha256=jlkqS9pI0S0Ubq4pWVeaaaPk-E0J-cZg5zkSX7GuQ_o,1063
37
37
  synapse_sdk/clients/ray/__init__.py,sha256=9ZSPXVVxlJ8Wp8ku7l021ENtPjVrGgQDgqifkkVAXgM,187
38
38
  synapse_sdk/clients/ray/core.py,sha256=a4wyCocAma2HAm-BHlbZnoVbpfdR-Aad2FM0z6vPFvw,731
@@ -40,7 +40,7 @@ synapse_sdk/clients/ray/serve.py,sha256=rbCpXZYWf0oP8XJ9faa9QFNPYU7h8dltIG8xn9Zc
40
40
  synapse_sdk/plugins/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
41
41
  synapse_sdk/plugins/enums.py,sha256=s59P6Oz2WAK9IX-kLVhNOvNKYJifKlWBhPpZbc9-ttE,486
42
42
  synapse_sdk/plugins/exceptions.py,sha256=Qs7qODp_RRLO9y2otU2T4ryj5LFwIZODvSIXkAh91u0,691
43
- synapse_sdk/plugins/models.py,sha256=JFaU1aqzminwWasNKuRBYd5hrBTRHDOZkl2nqZ1l0IM,3687
43
+ synapse_sdk/plugins/models.py,sha256=7En1biVK_7kR8aI-3I-kJ-lXbveRRobppMGOeFd3ZpU,3709
44
44
  synapse_sdk/plugins/upload.py,sha256=VJOotYMayylOH0lNoAGeGHRkLdhP7jnC_A0rFQMvQpQ,3228
45
45
  synapse_sdk/plugins/utils.py,sha256=4_K6jIl0WrsXOEhFp94faMOriSsddOhIiaXcawYYUUA,3300
46
46
  synapse_sdk/plugins/categories/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
@@ -65,7 +65,7 @@ synapse_sdk/plugins/categories/neural_net/actions/__init__.py,sha256=47DEQpj8HBS
65
65
  synapse_sdk/plugins/categories/neural_net/actions/deployment.py,sha256=Wmi7in_Mgizt1d5XcDR080h1CIMWKh2_mjub9N380qA,1917
66
66
  synapse_sdk/plugins/categories/neural_net/actions/inference.py,sha256=0a655ELqNVjPFZTJDiw4EUdcMCPGveUEKyoYqpwMFBU,1019
67
67
  synapse_sdk/plugins/categories/neural_net/actions/test.py,sha256=JY25eg-Fo6WbgtMkGoo_qNqoaZkp3AQNEypJmeGzEog,320
68
- synapse_sdk/plugins/categories/neural_net/actions/train.py,sha256=4zq2ryWjqDa6MyI2BGe3sAofMh2NeY3XAo-1gEFXBs4,5145
68
+ synapse_sdk/plugins/categories/neural_net/actions/train.py,sha256=CBg8ky2-bvS5pZlzuf49HcdpyronHkSugwq0UeHhiKg,5401
69
69
  synapse_sdk/plugins/categories/neural_net/base/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
70
70
  synapse_sdk/plugins/categories/neural_net/base/inference.py,sha256=R5DASI6-5vzsjDOYxqeGGMBjnav5qHF4hNJT8zNUR3I,1097
71
71
  synapse_sdk/plugins/categories/neural_net/templates/config.yaml,sha256=dXKB1hO53hDZB73xnxLVCNQl8Sm7svMmVmuMrOCQmEU,343
@@ -105,7 +105,7 @@ synapse_sdk/shared/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuF
105
105
  synapse_sdk/shared/enums.py,sha256=WMZPag9deVF7VCXaQkLk7ly_uX1KwbNzRx9TdvgaeFE,138
106
106
  synapse_sdk/utils/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
107
107
  synapse_sdk/utils/debug.py,sha256=F7JlUwYjTFZAMRbBqKm6hxOIz-_IXYA8lBInOS4jbS4,100
108
- synapse_sdk/utils/file.py,sha256=eF1GDxjPaq2QOiKKCHSzgCkBRYSBSwP4rKOAApAQR3E,5661
108
+ synapse_sdk/utils/file.py,sha256=zP8eOZifGiYP9PyC4ivQwxs-ljbtXRtbWN4yOjZF6tc,6658
109
109
  synapse_sdk/utils/module_loading.py,sha256=chHpU-BZjtYaTBD_q0T7LcKWtqKvYBS4L0lPlKkoMQ8,1020
110
110
  synapse_sdk/utils/network.py,sha256=wg-oFM0gKK5REqIUO8d-x9yXJfqbnkSbbF0_qyxpwz4,412
111
111
  synapse_sdk/utils/storage.py,sha256=a8OVbd38ATr0El4G4kuV07lr_tJZrpIJBSy4GHb0qZ8,2581
@@ -114,9 +114,9 @@ synapse_sdk/utils/pydantic/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJ
114
114
  synapse_sdk/utils/pydantic/config.py,sha256=1vYOcUI35GslfD1rrqhFkNXXJOXt4IDqOPSx9VWGfNE,123
115
115
  synapse_sdk/utils/pydantic/errors.py,sha256=0v0T12eQBr1KrFiEOBu6KMaPK4aPEGEC6etPJGoR5b4,1061
116
116
  synapse_sdk/utils/pydantic/validators.py,sha256=G47P8ObPhsePmd_QZDK8EdPnik2CbaYzr_N4Z6En8dc,193
117
- synapse_sdk-1.0.0a27.dist-info/LICENSE,sha256=bKzmC5YAg4V1Fhl8OO_tqY8j62hgdncAkN7VrdjmrGk,1101
118
- synapse_sdk-1.0.0a27.dist-info/METADATA,sha256=HIpc3MxfEPZqeCjtiNM4S5pCicSkJA5xvS7QQ57kAzQ,1070
119
- synapse_sdk-1.0.0a27.dist-info/WHEEL,sha256=In9FTNxeP60KnTkGw7wk6mJPYd_dQSjEZmXdBdMCI-8,91
120
- synapse_sdk-1.0.0a27.dist-info/entry_points.txt,sha256=VNptJoGoNJI8yLXfBmhgUefMsmGI0m3-0YoMvrOgbxo,48
121
- synapse_sdk-1.0.0a27.dist-info/top_level.txt,sha256=ytgJMRK1slVOKUpgcw3LEyHHP7S34J6n_gJzdkcSsw8,12
122
- synapse_sdk-1.0.0a27.dist-info/RECORD,,
117
+ synapse_sdk-1.0.0a29.dist-info/LICENSE,sha256=bKzmC5YAg4V1Fhl8OO_tqY8j62hgdncAkN7VrdjmrGk,1101
118
+ synapse_sdk-1.0.0a29.dist-info/METADATA,sha256=1DF4WZPzyfQO1HZzHzzvP0isb2pCpCmQyx-8u6YhKlA,1070
119
+ synapse_sdk-1.0.0a29.dist-info/WHEEL,sha256=In9FTNxeP60KnTkGw7wk6mJPYd_dQSjEZmXdBdMCI-8,91
120
+ synapse_sdk-1.0.0a29.dist-info/entry_points.txt,sha256=VNptJoGoNJI8yLXfBmhgUefMsmGI0m3-0YoMvrOgbxo,48
121
+ synapse_sdk-1.0.0a29.dist-info/top_level.txt,sha256=ytgJMRK1slVOKUpgcw3LEyHHP7S34J6n_gJzdkcSsw8,12
122
+ synapse_sdk-1.0.0a29.dist-info/RECORD,,