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

File without changes
@@ -0,0 +1,31 @@
1
+ class FileSpecificationValidator:
2
+ """File specification validator class for synapse backend collection.
3
+
4
+ Args:
5
+ file_spec_template (list):
6
+ * List of dictionaries containing file specification template
7
+ * This is from synapse-backend file specification data.
8
+ organized_files (list): List of dictionaries containing organized files.
9
+ """
10
+
11
+ def __init__(self, file_spec_template, organized_files):
12
+ self.file_spec_template = file_spec_template
13
+ self.organized_files = organized_files
14
+
15
+ def validate(self):
16
+ """Validate the file specification template with organized files.
17
+
18
+ Returns:
19
+ bool: True if the file specification template is valid, False otherwise.
20
+ """
21
+ for spec in self.file_spec_template:
22
+ spec_name = spec['name']
23
+ is_required = spec['is_required']
24
+
25
+ for file_group in self.organized_files:
26
+ files = file_group['files']
27
+ if is_required and spec_name not in files:
28
+ return False
29
+ if spec_name in files and not files[spec_name]:
30
+ return False
31
+ return True
@@ -1,4 +1,7 @@
1
+ from packaging import version
2
+
1
3
  from synapse_sdk.clients.exceptions import ClientError
4
+ from synapse_sdk.i18n import gettext as _
2
5
  from synapse_sdk.plugins.categories.base import Action
3
6
  from synapse_sdk.plugins.categories.decorators import register_action
4
7
  from synapse_sdk.plugins.enums import PluginCategory, RunMethod
@@ -25,12 +28,36 @@ class DeploymentAction(Action):
25
28
 
26
29
  self.ray_init()
27
30
 
28
- deployment = serve.deployment(ray_actor_options=self.get_actor_options())(serve.ingress(app)(self.entrypoint))
31
+ ray_actor_options = self.get_actor_options()
32
+
33
+ if self.is_gradio_deployment:
34
+ from ray.serve.gradio_integrations import GradioServer
35
+
36
+ self.assert_gradio_version()
37
+
38
+ # GradioIngress differs from serve.ingress(app), thus the difference in self.entrypoint callable
39
+ try:
40
+ entrypoint = self.entrypoint().app
41
+ except (TypeError, ImportError):
42
+ raise ClientError(
43
+ 400,
44
+ _(
45
+ 'Gradio app is not callable.'
46
+ 'Please ensure that your Deployment class defines a callable `app` function'
47
+ ),
48
+ )
49
+
50
+ deployment = GradioServer.options(ray_actor_options=ray_actor_options).bind(entrypoint)
51
+ else:
52
+ deployment = serve.deployment(ray_actor_options=ray_actor_options)(
53
+ serve.ingress(app)(self.entrypoint)
54
+ ).bind(self.envs['SYNAPSE_PLUGIN_RUN_HOST'])
55
+
29
56
  serve.delete(self.plugin_release.code)
30
57
 
31
58
  # TODO add run object
32
59
  serve.run(
33
- deployment.bind(self.envs['SYNAPSE_PLUGIN_RUN_HOST']),
60
+ deployment,
34
61
  name=self.plugin_release.code,
35
62
  route_prefix=f'/{self.plugin_release.checksum}',
36
63
  )
@@ -51,3 +78,30 @@ class DeploymentAction(Action):
51
78
  except ClientError:
52
79
  pass
53
80
  return None
81
+
82
+ @property
83
+ def is_gradio_deployment(self):
84
+ return self.config.get('gradio_app', False)
85
+
86
+ def assert_gradio_version(self):
87
+ """Assert gradio version is not greater than 3.50.2.
88
+ Ray Serve cannot pickle gradio endpoints, thus gradio version greater than 3.50.2 is not supported (SSE Issues)
89
+ """
90
+ GRADIO_VERSION_MAX_ALLOWED = '3.50.2'
91
+
92
+ gradio_installed = False
93
+ gradio_version = None
94
+ for req in self.requirements:
95
+ if req.startswith('gradio=='):
96
+ gradio_installed = True
97
+ gradio_version = req.split('==')[1]
98
+ break
99
+
100
+ assert gradio_installed, _(
101
+ 'Gradio is not installed or version is not specified. Please install gradio==3.50.2 to use this feature.'
102
+ )
103
+
104
+ if version.parse(gradio_version) > version.parse(GRADIO_VERSION_MAX_ALLOWED):
105
+ raise AssertionError(
106
+ f'Gradio version {gradio_version} is greater than maximum allowed version {GRADIO_VERSION_MAX_ALLOWED}'
107
+ )
@@ -1,4 +1,3 @@
1
- from enum import Enum
2
1
  from typing import Annotated, Dict, List
3
2
 
4
3
  from pydantic import AfterValidator, BaseModel, field_validator
@@ -6,6 +5,7 @@ from pydantic_core import PydanticCustomError
6
5
 
7
6
  from synapse_sdk.clients.exceptions import ClientError
8
7
  from synapse_sdk.clients.utils import get_batched_list
8
+ from synapse_sdk.clients.validators.collections import FileSpecificationValidator
9
9
  from synapse_sdk.i18n import gettext as _
10
10
  from synapse_sdk.plugins.categories.base import Action
11
11
  from synapse_sdk.plugins.categories.decorators import register_action
@@ -145,7 +145,7 @@ class UploadAction(Action):
145
145
 
146
146
  # Analyze Collection file specifications to determine the data structure for upload.
147
147
  self.run.set_progress(0, 1, category='analyze_collection')
148
- file_specification_skeleton = self._analyze_collection()
148
+ file_specification_template = self._analyze_collection()
149
149
  self.run.set_progress(1, 1, category='analyze_collection')
150
150
 
151
151
  # Setup result dict.
@@ -153,7 +153,7 @@ class UploadAction(Action):
153
153
 
154
154
  # Organize data according to Collection file specification structure.
155
155
  organized_files = uploader.handle_upload_files()
156
- if not self._validate_organized_files(file_specification_skeleton, organized_files):
156
+ if not self._validate_organized_files(file_specification_template, organized_files):
157
157
  self.run.log_message('Validate organized files failed.')
158
158
  return result
159
159
 
@@ -219,9 +219,10 @@ class UploadAction(Action):
219
219
  collection = client.get_dataset(collection_id)
220
220
  return collection['file_specifications']
221
221
 
222
- def _validate_organized_files(self, file_specification_skeleton: Dict, organized_files: List) -> bool:
222
+ def _validate_organized_files(self, file_specification_template: Dict, organized_files: List) -> bool:
223
223
  """Validate organized files from Uploader."""
224
- return True
224
+ validator = FileSpecificationValidator(file_specification_template, organized_files)
225
+ return validator.validate()
225
226
 
226
227
  def _upload_files(self, organized_files) -> List:
227
228
  """Upload files to synapse-backend.
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: synapse-sdk
3
- Version: 1.0.0a33
3
+ Version: 1.0.0a35
4
4
  Summary: synapse sdk
5
5
  Author-email: datamaker <developer@datamaker.io>
6
6
  License: MIT
@@ -39,6 +39,8 @@ synapse_sdk/clients/backend/models.py,sha256=ycuzIBi3pyKIFkNzrNGsv3cA49BjLmjyylN
39
39
  synapse_sdk/clients/ray/__init__.py,sha256=9ZSPXVVxlJ8Wp8ku7l021ENtPjVrGgQDgqifkkVAXgM,187
40
40
  synapse_sdk/clients/ray/core.py,sha256=a4wyCocAma2HAm-BHlbZnoVbpfdR-Aad2FM0z6vPFvw,731
41
41
  synapse_sdk/clients/ray/serve.py,sha256=rbCpXZYWf0oP8XJ9faa9QFNPYU7h8dltIG8xn9ZconY,907
42
+ synapse_sdk/clients/validators/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
43
+ synapse_sdk/clients/validators/collections.py,sha256=LtnwvutsScubOUcZ2reGHLCzseXxtNIdnH2nv098aUU,1195
42
44
  synapse_sdk/plugins/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
43
45
  synapse_sdk/plugins/enums.py,sha256=ibixwqA3sCNSriG1jAtL54JQc_Zwo3MufwYUqGhVncc,523
44
46
  synapse_sdk/plugins/exceptions.py,sha256=Qs7qODp_RRLO9y2otU2T4ryj5LFwIZODvSIXkAh91u0,691
@@ -64,7 +66,7 @@ synapse_sdk/plugins/categories/export/templates/plugin/__init__.py,sha256=47DEQp
64
66
  synapse_sdk/plugins/categories/export/templates/plugin/export.py,sha256=nbjvgFVQpPN5Lo1UnPL5p__BYeejMZLMZ4RT_yd7vJU,4561
65
67
  synapse_sdk/plugins/categories/neural_net/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
66
68
  synapse_sdk/plugins/categories/neural_net/actions/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
67
- synapse_sdk/plugins/categories/neural_net/actions/deployment.py,sha256=Wmi7in_Mgizt1d5XcDR080h1CIMWKh2_mjub9N380qA,1917
69
+ synapse_sdk/plugins/categories/neural_net/actions/deployment.py,sha256=oetIwZoee5vxriPX3r1onmxgwojUyaRTlnBIdaQ1zk8,3895
68
70
  synapse_sdk/plugins/categories/neural_net/actions/inference.py,sha256=0a655ELqNVjPFZTJDiw4EUdcMCPGveUEKyoYqpwMFBU,1019
69
71
  synapse_sdk/plugins/categories/neural_net/actions/test.py,sha256=JY25eg-Fo6WbgtMkGoo_qNqoaZkp3AQNEypJmeGzEog,320
70
72
  synapse_sdk/plugins/categories/neural_net/actions/train.py,sha256=kve6iTCg2kUeavMQTR2JFuoYDu-QWZFFlB58ZICQtdM,5406
@@ -95,7 +97,7 @@ synapse_sdk/plugins/categories/smart_tool/templates/plugin/__init__.py,sha256=47
95
97
  synapse_sdk/plugins/categories/smart_tool/templates/plugin/auto_label.py,sha256=eevNg0nOcYFR4z_L_R-sCvVOYoLWSAH1jwDkAf3YCjY,320
96
98
  synapse_sdk/plugins/categories/upload/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
97
99
  synapse_sdk/plugins/categories/upload/actions/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
98
- synapse_sdk/plugins/categories/upload/actions/upload.py,sha256=V7gArcj7FZO8AT_ihUGodrc_7q49Q7j9BKc9DvoYOYQ,11178
100
+ synapse_sdk/plugins/categories/upload/actions/upload.py,sha256=ry5Whogy5opZ7U_G6hQlbej8ufs5BS_VaJLY648vpF4,11347
99
101
  synapse_sdk/plugins/categories/upload/templates/config.yaml,sha256=0PhB2uD-9ufavZs7EiF6xj4aBgZuif9mFFGGfzG7HuY,147
100
102
  synapse_sdk/plugins/categories/upload/templates/plugin/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
101
103
  synapse_sdk/plugins/categories/upload/templates/plugin/upload.py,sha256=dnK8gy33GjG5ettayawDJv1gM3xCm1K6lM-PfeeTjQw,1163
@@ -127,9 +129,9 @@ synapse_sdk/utils/storage/providers/__init__.py,sha256=NM9yRIWcPkH53DeNHgIhH9zaD
127
129
  synapse_sdk/utils/storage/providers/gcp.py,sha256=i2BQCu1Kej1If9SuNr2_lEyTcr5M_ncGITZrL0u5wEA,363
128
130
  synapse_sdk/utils/storage/providers/s3.py,sha256=r94aUGVNf8yxihU0lN62yaXdxSS7P783_sfD-hCiK40,1191
129
131
  synapse_sdk/utils/storage/providers/sftp.py,sha256=TUQXkKJf0-fh8NhGC_1zzqI4autFNHZVCqngwkQ1aD4,523
130
- synapse_sdk-1.0.0a33.dist-info/licenses/LICENSE,sha256=bKzmC5YAg4V1Fhl8OO_tqY8j62hgdncAkN7VrdjmrGk,1101
131
- synapse_sdk-1.0.0a33.dist-info/METADATA,sha256=MQpJhcUDqRQxgZEvjSEBDQcvN8q6z26EFjgILJ0MzhU,1160
132
- synapse_sdk-1.0.0a33.dist-info/WHEEL,sha256=CmyFI0kx5cdEMTLiONQRbGQwjIoR1aIYB7eCAQ4KPJ0,91
133
- synapse_sdk-1.0.0a33.dist-info/entry_points.txt,sha256=VNptJoGoNJI8yLXfBmhgUefMsmGI0m3-0YoMvrOgbxo,48
134
- synapse_sdk-1.0.0a33.dist-info/top_level.txt,sha256=ytgJMRK1slVOKUpgcw3LEyHHP7S34J6n_gJzdkcSsw8,12
135
- synapse_sdk-1.0.0a33.dist-info/RECORD,,
132
+ synapse_sdk-1.0.0a35.dist-info/licenses/LICENSE,sha256=bKzmC5YAg4V1Fhl8OO_tqY8j62hgdncAkN7VrdjmrGk,1101
133
+ synapse_sdk-1.0.0a35.dist-info/METADATA,sha256=lUfa4HBsiikuUTv8HjSpFmlhM0DB0JcOb3aKhYQAx24,1160
134
+ synapse_sdk-1.0.0a35.dist-info/WHEEL,sha256=CmyFI0kx5cdEMTLiONQRbGQwjIoR1aIYB7eCAQ4KPJ0,91
135
+ synapse_sdk-1.0.0a35.dist-info/entry_points.txt,sha256=VNptJoGoNJI8yLXfBmhgUefMsmGI0m3-0YoMvrOgbxo,48
136
+ synapse_sdk-1.0.0a35.dist-info/top_level.txt,sha256=ytgJMRK1slVOKUpgcw3LEyHHP7S34J6n_gJzdkcSsw8,12
137
+ synapse_sdk-1.0.0a35.dist-info/RECORD,,