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

@@ -22,8 +22,10 @@ class GradioAction(Action):
22
22
  return dir
23
23
 
24
24
  @property
25
- def _requirements(self):
26
- return self.config.get('requirements', ['gradio>=5'])
25
+ def requirements_file(self):
26
+ requirements_file = self.working_directory / 'requirements.txt'
27
+ if requirements_file.exists():
28
+ return requirements_file
27
29
 
28
30
  @property
29
31
  def tag(self):
@@ -40,7 +42,7 @@ class GradioAction(Action):
40
42
  try:
41
43
  # Write Dockerfile and requirements.txt
42
44
  path_dockerfile = self.write_dockerfile_template()
43
- self.write_requirements(path_dockerfile.parent / 'requirements.txt')
45
+ self.check_requirements()
44
46
 
45
47
  # Build docker image
46
48
  self.build_docker_image(path_dockerfile)
@@ -59,11 +61,15 @@ class GradioAction(Action):
59
61
  dockerfile_path = self.working_directory / 'Dockerfile'
60
62
 
61
63
  with open(dockerfile_path, 'w') as f:
62
- f.write("""FROM python:3.10
64
+ f.write("""FROM python:3.12-slim
63
65
  WORKDIR /home/user/app
64
66
 
65
67
  RUN pip install --no-cache-dir pip -U && \\
66
68
  pip install --no-cache-dir uvicorn
69
+
70
+ RUN apt-get update && \\
71
+ apt-get install -y git nmap ffmpeg libsm6 libxext6 libgl1-mesa-glx && \\
72
+ rm -rf /var/lib/apt/lists/*
67
73
 
68
74
  RUN apt-get update && \\
69
75
  apt-get install -y curl && \\
@@ -82,22 +88,19 @@ CMD ["python", "app.py"]
82
88
  """)
83
89
  return dockerfile_path
84
90
 
85
- def write_requirements(self, path):
86
- with open(path, 'w') as f:
87
- f.write('\n'.join(self._requirements))
91
+ def check_requirements(self):
92
+ default_packages = ['gradio', 'synapse-sdk', 'python-nmap']
93
+ if self.requirements_file is None:
94
+ with open(self.working_directory / 'requirements.txt', 'a') as f:
95
+ f.write('\n' + '\n'.join(default_packages))
96
+ else:
97
+ with open(self.requirements_file, 'a') as f:
98
+ f.write('\n' + '\n'.join(default_packages[1:]))
88
99
 
89
100
  def build_docker_image(self, path_dockerfile):
90
101
  self.run.log('deploy', 'Start building docker image')
91
102
  result = subprocess.run(
92
- [
93
- 'docker',
94
- 'build',
95
- '-t',
96
- self.tag,
97
- '-f',
98
- str(path_dockerfile),
99
- '.',
100
- ],
103
+ ['docker', 'build', '-t', self.tag, '-f', str(path_dockerfile), '.'],
101
104
  cwd=self.working_directory,
102
105
  check=True,
103
106
  )
@@ -113,19 +116,30 @@ CMD ["python", "app.py"]
113
116
  subprocess.run(['docker', 'rm', self.tag], check=True)
114
117
 
115
118
  # Run docker image
116
- self.run.log('deploy', 'Starting docker container')
119
+ command = [
120
+ 'docker',
121
+ 'run',
122
+ '-d',
123
+ '--name',
124
+ self.tag,
125
+ '-p',
126
+ f'{self.deploy_port}:7860',
127
+ '-p',
128
+ '8991-8999:8991-8999',
129
+ '--add-host',
130
+ 'host.docker.internal:host-gateway',
131
+ '-e',
132
+ 'GRADIO_SERVER_NAME=0.0.0.0',
133
+ ]
134
+
135
+ # extend synapse env vars
136
+ for key, value in self.envs.items():
137
+ command.extend(['-e', f'{key}={value}'])
138
+ command.append(self.tag)
139
+
140
+ self.run.log('deploy', f'Starting docker container with command: {" ".join(command)}')
141
+
117
142
  subprocess.run(
118
- [
119
- 'docker',
120
- 'run',
121
- '-d',
122
- '--name',
123
- self.tag,
124
- '-p',
125
- f'{self.deploy_port}:7860',
126
- '-p',
127
- '8991-8999:8991-8999',
128
- self.tag,
129
- ],
143
+ command,
130
144
  check=True,
131
145
  )
synapse_sdk/utils/http.py CHANGED
@@ -38,7 +38,7 @@ class SingleFileHttpServer(SimpleHTTPRequestHandler):
38
38
 
39
39
 
40
40
  @contextmanager
41
- def temp_file_server(image=None, file_path=None, format='JPEG', host='localhost', port=None, content_type=None):
41
+ def temp_file_server(image=None, file_path=None, format='JPEG', host='0.0.0.0', port=None, content_type=None):
42
42
  """
43
43
  Context manager that serves a file temporarily via HTTP.
44
44
 
@@ -46,7 +46,7 @@ def temp_file_server(image=None, file_path=None, format='JPEG', host='localhost'
46
46
  image: A PIL Image object to serve (optional)
47
47
  file_path: Path to an existing file to serve (optional - used if image not provided)
48
48
  format: Image format when saving a PIL Image (default: "JPEG")
49
- host: Host to serve on (default: "localhost")
49
+ host: Host to serve on (default: "0.0.0.0")
50
50
  port: Port to serve on (default: auto-selected free port)
51
51
  content_type: Content type header (default: auto-detected based on format)
52
52
 
@@ -92,7 +92,7 @@ def temp_file_server(image=None, file_path=None, format='JPEG', host='localhost'
92
92
 
93
93
  time.sleep(0.1)
94
94
 
95
- url = f'http://{host}:{port}'
95
+ url = f'http://localhost:{port}'
96
96
 
97
97
  try:
98
98
  yield url
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: synapse-sdk
3
- Version: 1.0.0a40
3
+ Version: 1.0.0a41
4
4
  Summary: synapse sdk
5
5
  Author-email: datamaker <developer@datamaker.io>
6
6
  License: MIT
@@ -68,7 +68,7 @@ synapse_sdk/plugins/categories/export/templates/plugin/export.py,sha256=39XLGo8u
68
68
  synapse_sdk/plugins/categories/neural_net/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
69
69
  synapse_sdk/plugins/categories/neural_net/actions/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
70
70
  synapse_sdk/plugins/categories/neural_net/actions/deployment.py,sha256=y2LrS-pwazqRI5O0q1NUy45NQYsBj6ykbrXnDMs_fqE,1987
71
- synapse_sdk/plugins/categories/neural_net/actions/gradio.py,sha256=pcrMr3pmNJmVjS2wRvyGmCvIoxYKSQJAheXqJBNRfm4,3790
71
+ synapse_sdk/plugins/categories/neural_net/actions/gradio.py,sha256=246hZyiRb8z2JtohbEOFW2QN56vli_3LciexEmQYX7w,4444
72
72
  synapse_sdk/plugins/categories/neural_net/actions/inference.py,sha256=0a655ELqNVjPFZTJDiw4EUdcMCPGveUEKyoYqpwMFBU,1019
73
73
  synapse_sdk/plugins/categories/neural_net/actions/test.py,sha256=JY25eg-Fo6WbgtMkGoo_qNqoaZkp3AQNEypJmeGzEog,320
74
74
  synapse_sdk/plugins/categories/neural_net/actions/train.py,sha256=kve6iTCg2kUeavMQTR2JFuoYDu-QWZFFlB58ZICQtdM,5406
@@ -120,7 +120,7 @@ synapse_sdk/utils/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU
120
120
  synapse_sdk/utils/dataset.py,sha256=zWTzFmv589izFr62BDuApi3r5FpTsdm-5AmriC0AEdM,1865
121
121
  synapse_sdk/utils/debug.py,sha256=F7JlUwYjTFZAMRbBqKm6hxOIz-_IXYA8lBInOS4jbS4,100
122
122
  synapse_sdk/utils/file.py,sha256=wWBQAx0cB5a-fjfRMeJV-KjBil1ZyKRz-vXno3xBSoo,6834
123
- synapse_sdk/utils/http.py,sha256=GqYONHfovwBmP4p3ZczVCNvn4oApx2QzfzGIEiICqJo,3770
123
+ synapse_sdk/utils/http.py,sha256=VyehrKHPnCrXXSYLmqZXTAOYW1-LhrWyWnnLr8MVKNA,3769
124
124
  synapse_sdk/utils/module_loading.py,sha256=chHpU-BZjtYaTBD_q0T7LcKWtqKvYBS4L0lPlKkoMQ8,1020
125
125
  synapse_sdk/utils/network.py,sha256=WI8qn6KlKpHdMi45V57ofKJB8zusJrbQsxT74LwVfsY,1000
126
126
  synapse_sdk/utils/string.py,sha256=rEwuZ9SAaZLcQ8TYiwNKr1h2u4CfnrQx7SUL8NWmChg,216
@@ -134,9 +134,9 @@ synapse_sdk/utils/storage/providers/__init__.py,sha256=x7RGwZryT2FpVxS7fGWryRVpq
134
134
  synapse_sdk/utils/storage/providers/gcp.py,sha256=i2BQCu1Kej1If9SuNr2_lEyTcr5M_ncGITZrL0u5wEA,363
135
135
  synapse_sdk/utils/storage/providers/s3.py,sha256=W94rQvhGRXti3R4mYP7gmU5pcyCQpGFIBLvxxqLVdRM,2231
136
136
  synapse_sdk/utils/storage/providers/sftp.py,sha256=_8s9hf0JXIO21gvm-JVS00FbLsbtvly4c-ETLRax68A,1426
137
- synapse_sdk-1.0.0a40.dist-info/licenses/LICENSE,sha256=bKzmC5YAg4V1Fhl8OO_tqY8j62hgdncAkN7VrdjmrGk,1101
138
- synapse_sdk-1.0.0a40.dist-info/METADATA,sha256=P24axYuG6BpxcsvfyKnMuZh6NpNBQCaN3gcRnggwxDg,1203
139
- synapse_sdk-1.0.0a40.dist-info/WHEEL,sha256=CmyFI0kx5cdEMTLiONQRbGQwjIoR1aIYB7eCAQ4KPJ0,91
140
- synapse_sdk-1.0.0a40.dist-info/entry_points.txt,sha256=VNptJoGoNJI8yLXfBmhgUefMsmGI0m3-0YoMvrOgbxo,48
141
- synapse_sdk-1.0.0a40.dist-info/top_level.txt,sha256=ytgJMRK1slVOKUpgcw3LEyHHP7S34J6n_gJzdkcSsw8,12
142
- synapse_sdk-1.0.0a40.dist-info/RECORD,,
137
+ synapse_sdk-1.0.0a41.dist-info/licenses/LICENSE,sha256=bKzmC5YAg4V1Fhl8OO_tqY8j62hgdncAkN7VrdjmrGk,1101
138
+ synapse_sdk-1.0.0a41.dist-info/METADATA,sha256=Txz9DmdCWS8KzIWa2XEpLM0YYOzlCgcTQUXtDYxCw0c,1203
139
+ synapse_sdk-1.0.0a41.dist-info/WHEEL,sha256=CmyFI0kx5cdEMTLiONQRbGQwjIoR1aIYB7eCAQ4KPJ0,91
140
+ synapse_sdk-1.0.0a41.dist-info/entry_points.txt,sha256=VNptJoGoNJI8yLXfBmhgUefMsmGI0m3-0YoMvrOgbxo,48
141
+ synapse_sdk-1.0.0a41.dist-info/top_level.txt,sha256=ytgJMRK1slVOKUpgcw3LEyHHP7S34J6n_gJzdkcSsw8,12
142
+ synapse_sdk-1.0.0a41.dist-info/RECORD,,