synapse-sdk 1.0.0a43__py3-none-any.whl → 1.0.0a45__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,4 +1,3 @@
1
- import json
2
1
  from abc import ABC, abstractmethod
3
2
  from datetime import datetime
4
3
  from typing import Annotated, Any, Literal
@@ -33,7 +32,7 @@ class ExportRun(Run):
33
32
  """Log export file information.
34
33
 
35
34
  Args:
36
- log_type (str): The type of log ('export_data_file' or 'export_origin_file').
35
+ log_type (str): The type of log ('export_data_file' or 'export_original_file').
37
36
  target_id (int): The ID of the data file.
38
37
  data_file_info (dict): The JSON info of the data file.
39
38
  status (ExportStatus): The status of the data file.
@@ -44,7 +43,7 @@ class ExportRun(Run):
44
43
  log_type,
45
44
  self.DataFileLog(
46
45
  target_id=target_id,
47
- data_file_info=json.dumps(data_file_info),
46
+ data_file_info=data_file_info,
48
47
  status=status.value,
49
48
  error=error,
50
49
  created=now,
@@ -69,7 +68,7 @@ class ExportRun(Run):
69
68
  error: str | None = None,
70
69
  ):
71
70
  """Log export origin data file."""
72
- self.log_file('export_origin_file', target_id, data_file_info, status, error)
71
+ self.log_file('export_original_file', target_id, data_file_info, status, error)
73
72
 
74
73
 
75
74
  class ExportTargetHandler(ABC):
@@ -140,7 +140,7 @@ def save_as_json(run, result, base_path, error_file_list):
140
140
  # Default save file name: original file name
141
141
  file_name = get_original_file_pathlib(result['files']).stem
142
142
  json_data = result['data']
143
- file_info = {'file_name': file_name}
143
+ file_info = {'file_name': f'{file_name}.json'}
144
144
  error_msg = ''
145
145
  try:
146
146
  with (base_path / f'{file_name}.json').open('w', encoding='utf-8') as f:
@@ -4,3 +4,5 @@ actions:
4
4
  options:
5
5
  allow_generate_tasks: false
6
6
  allow_generate_ground_truths: false
7
+ ui_schema: |
8
+ Dumped FormKit Schema for upload plugin custom options
synapse_sdk/utils/http.py CHANGED
@@ -3,6 +3,7 @@ import os
3
3
  import tempfile
4
4
  import threading
5
5
  import time
6
+ import uuid
6
7
  from contextlib import contextmanager
7
8
  from http.server import HTTPServer, SimpleHTTPRequestHandler
8
9
 
@@ -17,23 +18,32 @@ class SingleFileHttpServer(SimpleHTTPRequestHandler):
17
18
  regardless of the request path.
18
19
  """
19
20
 
20
- def __init__(self, *args, file_path=None, content_type=None, **kwargs):
21
+ def __init__(self, *args, file_path=None, content_type=None, random_path=None, **kwargs):
21
22
  self.file_path = file_path
22
23
  self.content_type = content_type
24
+ self.random_path = random_path
23
25
  super().__init__(*args, **kwargs)
24
26
 
25
27
  def do_GET(self):
26
28
  """Handle GET requests by serving the single file."""
27
29
  try:
28
- # Always serve the specified file regardless of the path requested
29
- self.send_response(200)
30
- if self.content_type:
31
- self.send_header('Content-type', self.content_type)
32
- self.send_header('Content-Length', str(os.path.getsize(self.file_path)))
33
- self.end_headers()
34
-
35
- with open(self.file_path, 'rb') as file:
36
- self.wfile.write(file.read())
30
+ # Check if the path matches our random path
31
+ if self.random_path and self.path == f'/{self.random_path}':
32
+ self.send_response(200)
33
+ if self.content_type:
34
+ self.send_header('Content-type', self.content_type)
35
+ self.send_header('Content-Length', str(os.path.getsize(self.file_path)))
36
+ self.end_headers()
37
+
38
+ with open(self.file_path, 'rb') as file:
39
+ self.wfile.write(file.read())
40
+ elif self.path == '/':
41
+ # Redirect root to the random path
42
+ self.send_response(302)
43
+ self.send_header('Location', f'/{self.random_path}')
44
+ self.end_headers()
45
+ else:
46
+ self.send_error(404, 'File not found')
37
47
 
38
48
  except Exception as e:
39
49
  self.send_error(500, str(e))
@@ -68,8 +78,11 @@ def temp_file_server(image=None, file_path=None, format='JPEG', host='0.0.0.0',
68
78
  port = get_available_ports_host(start_port=8991, end_port=8999)
69
79
 
70
80
  temp_dir = None
81
+ temp_file_path = None
71
82
 
72
83
  try:
84
+ random_filename = f'{uuid.uuid4().hex}'
85
+
73
86
  if image is not None:
74
87
  temp_dir = tempfile.mkdtemp()
75
88
  ext_map = {'JPEG': '.jpg', 'PNG': '.png', 'GIF': '.gif', 'WEBP': '.webp'}
@@ -82,9 +95,15 @@ def temp_file_server(image=None, file_path=None, format='JPEG', host='0.0.0.0',
82
95
  temp_file_path = os.path.join(temp_dir, f'temp_image{ext}')
83
96
  image.save(temp_file_path, format=format)
84
97
  file_path = temp_file_path
98
+ random_filename += ext
99
+ else:
100
+ _, ext = os.path.splitext(file_path)
101
+ random_filename += ext
85
102
 
86
103
  def handler(*args, **kwargs):
87
- return SingleFileHttpServer(*args, file_path=file_path, content_type=content_type, **kwargs)
104
+ return SingleFileHttpServer(
105
+ *args, file_path=file_path, content_type=content_type, random_path=random_filename, **kwargs
106
+ )
88
107
 
89
108
  server = HTTPServer((host, port), handler)
90
109
 
@@ -92,10 +111,9 @@ def temp_file_server(image=None, file_path=None, format='JPEG', host='0.0.0.0',
92
111
  server_thread.daemon = True
93
112
  server_thread.start()
94
113
 
95
- url = f'http://localhost:{port}'
114
+ url = f'http://localhost:{port}/{random_filename}'
96
115
 
97
- timeout = time.time() + 10
98
- while time.time() < timeout:
116
+ while True:
99
117
  try:
100
118
  response = requests.get(url)
101
119
  if response.status_code == 200:
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: synapse-sdk
3
- Version: 1.0.0a43
3
+ Version: 1.0.0a45
4
4
  Summary: synapse sdk
5
5
  Author-email: datamaker <developer@datamaker.io>
6
6
  License: MIT
@@ -61,10 +61,10 @@ synapse_sdk/plugins/categories/data_validation/templates/plugin/validation.py,sh
61
61
  synapse_sdk/plugins/categories/export/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
62
62
  synapse_sdk/plugins/categories/export/enums.py,sha256=gtyngvQ1DKkos9iKGcbecwTVQQ6sDwbrBPSGPNb5Am0,127
63
63
  synapse_sdk/plugins/categories/export/actions/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
64
- synapse_sdk/plugins/categories/export/actions/export.py,sha256=m-V-PsCmcF1rhiv8Rf9s3xaqJgpjC_kwITv5od5epGQ,9918
64
+ synapse_sdk/plugins/categories/export/actions/export.py,sha256=CHALeT0qE4tsMivDCNTQqsSBs0BNBXYsN-c6D4KFl8c,9898
65
65
  synapse_sdk/plugins/categories/export/templates/config.yaml,sha256=N7YmnFROb3s3M35SA9nmabyzoSb5O2t2TRPicwFNN2o,56
66
66
  synapse_sdk/plugins/categories/export/templates/plugin/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
67
- synapse_sdk/plugins/categories/export/templates/plugin/export.py,sha256=39XLGo8ui5FscbwZyX3JwmrJqGGvOYrY3FMYDKXwTOQ,5192
67
+ synapse_sdk/plugins/categories/export/templates/plugin/export.py,sha256=UzPOYvH2rwUlTUpMgcbn7mBsenf3hmWytE-eD_cB_9A,5202
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
@@ -101,7 +101,7 @@ synapse_sdk/plugins/categories/smart_tool/templates/plugin/auto_label.py,sha256=
101
101
  synapse_sdk/plugins/categories/upload/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
102
102
  synapse_sdk/plugins/categories/upload/actions/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
103
103
  synapse_sdk/plugins/categories/upload/actions/upload.py,sha256=9DIH4Aw70LxDpfhrpD0MfncE1m9oj-v52FpaChkVEnA,14755
104
- synapse_sdk/plugins/categories/upload/templates/config.yaml,sha256=0PhB2uD-9ufavZs7EiF6xj4aBgZuif9mFFGGfzG7HuY,147
104
+ synapse_sdk/plugins/categories/upload/templates/config.yaml,sha256=PARk7_F5zNqMK6VMXiMtzG16Um9i0-f-tHYa38Nf498,225
105
105
  synapse_sdk/plugins/categories/upload/templates/plugin/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
106
106
  synapse_sdk/plugins/categories/upload/templates/plugin/upload.py,sha256=dnK8gy33GjG5ettayawDJv1gM3xCm1K6lM-PfeeTjQw,1163
107
107
  synapse_sdk/plugins/templates/cookiecutter.json,sha256=NxOWk9A_v1pO0Ny4IYT9Cj5iiJ16--cIQrGC67QdR0I,396
@@ -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=L0YZIfgg2GOexqA1dKihae1-MagDRYIMJn2ilVNuj-8,4076
123
+ synapse_sdk/utils/http.py,sha256=yRxYfru8tMnBVeBK-7S0Ga13yOf8oRHquG5e8K_FWcI,4759
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.0a43.dist-info/licenses/LICENSE,sha256=bKzmC5YAg4V1Fhl8OO_tqY8j62hgdncAkN7VrdjmrGk,1101
138
- synapse_sdk-1.0.0a43.dist-info/METADATA,sha256=btu9DJL27zAyQTixfosy2HdnA-EkfK5KVgXaLR4F2CM,1203
139
- synapse_sdk-1.0.0a43.dist-info/WHEEL,sha256=CmyFI0kx5cdEMTLiONQRbGQwjIoR1aIYB7eCAQ4KPJ0,91
140
- synapse_sdk-1.0.0a43.dist-info/entry_points.txt,sha256=VNptJoGoNJI8yLXfBmhgUefMsmGI0m3-0YoMvrOgbxo,48
141
- synapse_sdk-1.0.0a43.dist-info/top_level.txt,sha256=ytgJMRK1slVOKUpgcw3LEyHHP7S34J6n_gJzdkcSsw8,12
142
- synapse_sdk-1.0.0a43.dist-info/RECORD,,
137
+ synapse_sdk-1.0.0a45.dist-info/licenses/LICENSE,sha256=bKzmC5YAg4V1Fhl8OO_tqY8j62hgdncAkN7VrdjmrGk,1101
138
+ synapse_sdk-1.0.0a45.dist-info/METADATA,sha256=Txp3cPnNXTEMiw3T0QPEdBZVg2gUi8M8Bv9c48yEvbw,1203
139
+ synapse_sdk-1.0.0a45.dist-info/WHEEL,sha256=CmyFI0kx5cdEMTLiONQRbGQwjIoR1aIYB7eCAQ4KPJ0,91
140
+ synapse_sdk-1.0.0a45.dist-info/entry_points.txt,sha256=VNptJoGoNJI8yLXfBmhgUefMsmGI0m3-0YoMvrOgbxo,48
141
+ synapse_sdk-1.0.0a45.dist-info/top_level.txt,sha256=ytgJMRK1slVOKUpgcw3LEyHHP7S34J6n_gJzdkcSsw8,12
142
+ synapse_sdk-1.0.0a45.dist-info/RECORD,,