synapse-sdk 1.0.0a40__py3-none-any.whl → 1.0.0a42__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.
- synapse_sdk/plugins/categories/neural_net/actions/gradio.py +51 -31
- synapse_sdk/utils/http.py +3 -3
- {synapse_sdk-1.0.0a40.dist-info → synapse_sdk-1.0.0a42.dist-info}/METADATA +1 -1
- {synapse_sdk-1.0.0a40.dist-info → synapse_sdk-1.0.0a42.dist-info}/RECORD +8 -8
- {synapse_sdk-1.0.0a40.dist-info → synapse_sdk-1.0.0a42.dist-info}/WHEEL +0 -0
- {synapse_sdk-1.0.0a40.dist-info → synapse_sdk-1.0.0a42.dist-info}/entry_points.txt +0 -0
- {synapse_sdk-1.0.0a40.dist-info → synapse_sdk-1.0.0a42.dist-info}/licenses/LICENSE +0 -0
- {synapse_sdk-1.0.0a40.dist-info → synapse_sdk-1.0.0a42.dist-info}/top_level.txt +0 -0
|
@@ -22,8 +22,10 @@ class GradioAction(Action):
|
|
|
22
22
|
return dir
|
|
23
23
|
|
|
24
24
|
@property
|
|
25
|
-
def
|
|
26
|
-
|
|
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.
|
|
45
|
+
self.check_requirements()
|
|
44
46
|
|
|
45
47
|
# Build docker image
|
|
46
48
|
self.build_docker_image(path_dockerfile)
|
|
@@ -59,12 +61,16 @@ 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.
|
|
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
|
|
67
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/*
|
|
73
|
+
|
|
68
74
|
RUN apt-get update && \\
|
|
69
75
|
apt-get install -y curl && \\
|
|
70
76
|
curl -fsSL https://deb.nodesource.com/setup_22.x | bash - && \\
|
|
@@ -72,9 +78,15 @@ RUN apt-get update && \\
|
|
|
72
78
|
rm -rf /var/lib/apt/lists/* && \\
|
|
73
79
|
apt-get clean
|
|
74
80
|
|
|
75
|
-
COPY .
|
|
81
|
+
COPY requiments_default.txt .
|
|
82
|
+
|
|
83
|
+
COPY requirements.txt .
|
|
84
|
+
|
|
85
|
+
RUN pip install --no-cache-dir -r requirements_default.txt
|
|
76
86
|
|
|
77
|
-
RUN pip install --no-cache-dir -r requirements.txt
|
|
87
|
+
RUN pip install --no-cache-dir -U -r requirements.txt
|
|
88
|
+
|
|
89
|
+
COPY . .
|
|
78
90
|
|
|
79
91
|
EXPOSE 7860
|
|
80
92
|
|
|
@@ -82,22 +94,19 @@ CMD ["python", "app.py"]
|
|
|
82
94
|
""")
|
|
83
95
|
return dockerfile_path
|
|
84
96
|
|
|
85
|
-
def
|
|
86
|
-
|
|
87
|
-
|
|
97
|
+
def check_requirements(self):
|
|
98
|
+
default_packages = ['gradio', 'synapse-sdk', 'python-nmap']
|
|
99
|
+
with open(self.working_directory / 'requirements_default.txt', 'a') as f:
|
|
100
|
+
f.write('\n' + '\n'.join(default_packages))
|
|
101
|
+
|
|
102
|
+
if self.requirements_file is None:
|
|
103
|
+
with open(self.working_directory / 'requirements.txt', 'a'):
|
|
104
|
+
pass
|
|
88
105
|
|
|
89
106
|
def build_docker_image(self, path_dockerfile):
|
|
90
107
|
self.run.log('deploy', 'Start building docker image')
|
|
91
108
|
result = subprocess.run(
|
|
92
|
-
[
|
|
93
|
-
'docker',
|
|
94
|
-
'build',
|
|
95
|
-
'-t',
|
|
96
|
-
self.tag,
|
|
97
|
-
'-f',
|
|
98
|
-
str(path_dockerfile),
|
|
99
|
-
'.',
|
|
100
|
-
],
|
|
109
|
+
['docker', 'build', '-t', self.tag, '-f', str(path_dockerfile), '.'],
|
|
101
110
|
cwd=self.working_directory,
|
|
102
111
|
check=True,
|
|
103
112
|
)
|
|
@@ -113,19 +122,30 @@ CMD ["python", "app.py"]
|
|
|
113
122
|
subprocess.run(['docker', 'rm', self.tag], check=True)
|
|
114
123
|
|
|
115
124
|
# Run docker image
|
|
116
|
-
|
|
125
|
+
command = [
|
|
126
|
+
'docker',
|
|
127
|
+
'run',
|
|
128
|
+
'-d',
|
|
129
|
+
'--name',
|
|
130
|
+
self.tag,
|
|
131
|
+
'-p',
|
|
132
|
+
f'{self.deploy_port}:7860',
|
|
133
|
+
'-p',
|
|
134
|
+
'8991-8999:8991-8999',
|
|
135
|
+
'--add-host',
|
|
136
|
+
'host.docker.internal:host-gateway',
|
|
137
|
+
'-e',
|
|
138
|
+
'GRADIO_SERVER_NAME=0.0.0.0',
|
|
139
|
+
]
|
|
140
|
+
|
|
141
|
+
# extend synapse env vars
|
|
142
|
+
for key, value in self.envs.items():
|
|
143
|
+
command.extend(['-e', f'{key}={value}'])
|
|
144
|
+
command.append(self.tag)
|
|
145
|
+
|
|
146
|
+
self.run.log('deploy', f'Starting docker container with command: {" ".join(command)}')
|
|
147
|
+
|
|
117
148
|
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
|
-
],
|
|
149
|
+
command,
|
|
130
150
|
check=True,
|
|
131
151
|
)
|
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='
|
|
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: "
|
|
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://
|
|
95
|
+
url = f'http://localhost:{port}'
|
|
96
96
|
|
|
97
97
|
try:
|
|
98
98
|
yield url
|
|
@@ -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=
|
|
71
|
+
synapse_sdk/plugins/categories/neural_net/actions/gradio.py,sha256=nflEUKk7kbuGRk-PwVV7lhhXNftxQGaX6wSvB37Dgmc,4506
|
|
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=
|
|
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.
|
|
138
|
-
synapse_sdk-1.0.
|
|
139
|
-
synapse_sdk-1.0.
|
|
140
|
-
synapse_sdk-1.0.
|
|
141
|
-
synapse_sdk-1.0.
|
|
142
|
-
synapse_sdk-1.0.
|
|
137
|
+
synapse_sdk-1.0.0a42.dist-info/licenses/LICENSE,sha256=bKzmC5YAg4V1Fhl8OO_tqY8j62hgdncAkN7VrdjmrGk,1101
|
|
138
|
+
synapse_sdk-1.0.0a42.dist-info/METADATA,sha256=4YCxPnhmqxZat_YxP1p9sRp5qUiKEi8zHUu-6LY67Io,1203
|
|
139
|
+
synapse_sdk-1.0.0a42.dist-info/WHEEL,sha256=CmyFI0kx5cdEMTLiONQRbGQwjIoR1aIYB7eCAQ4KPJ0,91
|
|
140
|
+
synapse_sdk-1.0.0a42.dist-info/entry_points.txt,sha256=VNptJoGoNJI8yLXfBmhgUefMsmGI0m3-0YoMvrOgbxo,48
|
|
141
|
+
synapse_sdk-1.0.0a42.dist-info/top_level.txt,sha256=ytgJMRK1slVOKUpgcw3LEyHHP7S34J6n_gJzdkcSsw8,12
|
|
142
|
+
synapse_sdk-1.0.0a42.dist-info/RECORD,,
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|