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

@@ -0,0 +1,139 @@
1
+ import json
2
+ import os
3
+
4
+
5
+ class PathAwareJSONEncoder(json.JSONEncoder):
6
+ """Custom JSON encoder that handles Path objects and datetime objects.
7
+
8
+ Extends the default JSON encoder to properly serialize Path objects
9
+ and datetime objects that are commonly used in upload operations.
10
+
11
+ Supported object types:
12
+ - Path objects (converts to string using __fspath__ or as_posix)
13
+ - Datetime objects (converts using isoformat)
14
+ - All other standard JSON-serializable types
15
+
16
+ Example:
17
+ >>> data = {"path": Path("/tmp/file.txt"), "timestamp": datetime.now()}
18
+ >>> json.dumps(data, cls=PathAwareJSONEncoder)
19
+ '{"path": "/tmp/file.txt", "timestamp": "2023-01-01T12:00:00"}'
20
+ """
21
+
22
+ def default(self, obj):
23
+ if hasattr(obj, '__fspath__'):
24
+ return obj.__fspath__()
25
+ elif hasattr(obj, 'as_posix'):
26
+ return obj.as_posix()
27
+ elif hasattr(obj, 'isoformat'):
28
+ return obj.isoformat()
29
+ return super().default(obj)
30
+
31
+
32
+ class ExcelSecurityConfig:
33
+ """Configuration class for Excel file security limits.
34
+
35
+ Manages security constraints for Excel file processing to prevent
36
+ resource exhaustion and security vulnerabilities. All limits can
37
+ be configured via environment variables.
38
+
39
+ Attributes:
40
+ MAX_FILE_SIZE_MB (int): Maximum file size in megabytes
41
+ MAX_FILE_SIZE_BYTES (int): Maximum file size in bytes
42
+ MAX_MEMORY_USAGE_MB (int): Maximum memory usage in megabytes
43
+ MAX_MEMORY_USAGE_BYTES (int): Maximum memory usage in bytes
44
+ MAX_ROWS (int): Maximum number of rows allowed
45
+ MAX_COLUMNS (int): Maximum number of columns allowed
46
+ MAX_FILENAME_LENGTH (int): Maximum filename length
47
+ MAX_COLUMN_NAME_LENGTH (int): Maximum column name length
48
+ MAX_METADATA_VALUE_LENGTH (int): Maximum metadata value length
49
+
50
+ Environment Variables:
51
+ EXCEL_MAX_FILE_SIZE_MB: Override default file size limit (default: 10)
52
+ EXCEL_MAX_MEMORY_MB: Override default memory limit (default: 30)
53
+ EXCEL_MAX_ROWS: Override default row limit (default: 10000)
54
+ EXCEL_MAX_COLUMNS: Override default column limit (default: 50)
55
+ EXCEL_MAX_FILENAME_LENGTH: Override filename length limit (default: 255)
56
+ EXCEL_MAX_COLUMN_NAME_LENGTH: Override column name length (default: 100)
57
+ EXCEL_MAX_METADATA_VALUE_LENGTH: Override metadata value length (default: 1000)
58
+ """
59
+
60
+ def __init__(self):
61
+ self.MAX_FILE_SIZE_MB = int(os.getenv('EXCEL_MAX_FILE_SIZE_MB', '10'))
62
+ self.MAX_FILE_SIZE_BYTES = self.MAX_FILE_SIZE_MB * 1024 * 1024
63
+
64
+ self.MAX_MEMORY_USAGE_MB = int(os.getenv('EXCEL_MAX_MEMORY_MB', '30'))
65
+ self.MAX_MEMORY_USAGE_BYTES = self.MAX_MEMORY_USAGE_MB * 1024 * 1024
66
+
67
+ self.MAX_ROWS = int(os.getenv('EXCEL_MAX_ROWS', '10000'))
68
+ self.MAX_COLUMNS = int(os.getenv('EXCEL_MAX_COLUMNS', '50'))
69
+
70
+ self.MAX_FILENAME_LENGTH = int(os.getenv('EXCEL_MAX_FILENAME_LENGTH', '255'))
71
+ self.MAX_COLUMN_NAME_LENGTH = int(os.getenv('EXCEL_MAX_COLUMN_NAME_LENGTH', '100'))
72
+ self.MAX_METADATA_VALUE_LENGTH = int(os.getenv('EXCEL_MAX_METADATA_VALUE_LENGTH', '1000'))
73
+
74
+
75
+ class ExcelMetadataUtils:
76
+ """Utility class for Excel metadata processing and validation.
77
+
78
+ Provides helper methods for validating and processing Excel metadata
79
+ while respecting security constraints defined in ExcelSecurityConfig.
80
+
81
+ Args:
82
+ config (ExcelSecurityConfig): Security configuration instance
83
+
84
+ Example:
85
+ >>> config = ExcelSecurityConfig()
86
+ >>> utils = ExcelMetadataUtils(config)
87
+ >>> safe_value = utils.validate_and_truncate_string("long text", 10)
88
+ >>> is_valid = utils.is_valid_filename_length("file.xlsx")
89
+ """
90
+
91
+ def __init__(self, config: ExcelSecurityConfig):
92
+ self.config = config
93
+
94
+ def validate_and_truncate_string(self, value: str, max_length: int) -> str:
95
+ """Validate and truncate string to maximum length.
96
+
97
+ Converts non-string values to strings, trims whitespace, and
98
+ truncates to the specified maximum length if necessary.
99
+
100
+ Args:
101
+ value (str): Value to validate and truncate
102
+ max_length (int): Maximum allowed length
103
+
104
+ Returns:
105
+ str: Validated and truncated string
106
+
107
+ Example:
108
+ >>> utils.validate_and_truncate_string(" long text ", 5)
109
+ 'long '
110
+ """
111
+ if not isinstance(value, str):
112
+ value = str(value)
113
+
114
+ value = value.strip()
115
+
116
+ if len(value) > max_length:
117
+ return value[:max_length]
118
+
119
+ return value
120
+
121
+ def is_valid_filename_length(self, filename: str) -> bool:
122
+ """Check if filename length is within security limits.
123
+
124
+ Validates that the filename (after trimming whitespace) does not
125
+ exceed the maximum filename length configured in security settings.
126
+
127
+ Args:
128
+ filename (str): Filename to validate
129
+
130
+ Returns:
131
+ bool: True if filename length is valid, False otherwise
132
+
133
+ Example:
134
+ >>> utils.is_valid_filename_length("file.xlsx")
135
+ True
136
+ >>> utils.is_valid_filename_length("x" * 300)
137
+ False
138
+ """
139
+ return len(filename.strip()) <= self.config.MAX_FILENAME_LENGTH
@@ -10,7 +10,12 @@ class Uploader:
10
10
  """
11
11
 
12
12
  def __init__(
13
- self, run, path: Path, file_specification: List = None, organized_files: List = None, extra_params: Dict = None
13
+ self,
14
+ run,
15
+ path: Path,
16
+ file_specification: List = None,
17
+ organized_files: List = None,
18
+ extra_params: Dict = None,
14
19
  ):
15
20
  """Initialize the plugin upload action class.
16
21
 
@@ -124,9 +124,9 @@ class Run:
124
124
  context = None
125
125
  client = None
126
126
 
127
- def __init__(self, job_id, context):
127
+ def __init__(self, job_id, context=None):
128
128
  self.job_id = job_id
129
- self.context = context
129
+ self.context = context or {}
130
130
  config = get_backend_config()
131
131
  if config:
132
132
  self.client = BackendClient(
@@ -134,17 +134,23 @@ class Run:
134
134
  access_token=config['token'],
135
135
  )
136
136
  else:
137
+ # Handle missing environment variables for test environments
138
+ envs = self.context.get('envs', {})
139
+ host = envs.get('SYNAPSE_PLUGIN_RUN_HOST', os.getenv('SYNAPSE_PLUGIN_RUN_HOST', 'http://localhost:8000'))
140
+ token = envs.get('SYNAPSE_PLUGIN_RUN_USER_TOKEN', os.getenv('SYNAPSE_PLUGIN_RUN_USER_TOKEN'))
141
+ tenant = envs.get('SYNAPSE_PLUGIN_RUN_TENANT', os.getenv('SYNAPSE_PLUGIN_RUN_TENANT'))
142
+
137
143
  self.client = BackendClient(
138
- self.context['envs']['SYNAPSE_PLUGIN_RUN_HOST'],
139
- token=self.context['envs'].get('SYNAPSE_PLUGIN_RUN_USER_TOKEN'),
140
- tenant=self.context['envs'].get('SYNAPSE_PLUGIN_RUN_TENANT'),
144
+ host,
145
+ token=token,
146
+ tenant=tenant,
141
147
  )
142
148
  self.set_logger()
143
149
 
144
150
  def set_logger(self):
145
151
  kwargs = {
146
- 'progress_categories': self.context['progress_categories'],
147
- 'metrics_categories': self.context['metrics_categories'],
152
+ 'progress_categories': self.context.get('progress_categories'),
153
+ 'metrics_categories': self.context.get('metrics_categories'),
148
154
  }
149
155
 
150
156
  if self.job_id:
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: synapse-sdk
3
- Version: 1.0.0b21
3
+ Version: 1.0.0b23
4
4
  Summary: synapse sdk
5
5
  Author-email: datamaker <developer@datamaker.io>
6
6
  License: MIT
@@ -53,7 +53,7 @@ synapse_sdk/devtools/docs/README.md,sha256=yBzWf0K1ef4oymFXDaHo0nYWEgMQJqsOyrkNh
53
53
  synapse_sdk/devtools/docs/docusaurus.config.ts,sha256=K1b002RS0x0tsOyib_6CSgUlASEULC9vAX8YDpbsRN4,3229
54
54
  synapse_sdk/devtools/docs/package-lock.json,sha256=dtepgbPC8gq5uz-hdcac4hIU-Cs209tX0sfBuB7RfEQ,705694
55
55
  synapse_sdk/devtools/docs/package.json,sha256=8veqayA4U3OLpdQaz6AzB59RQwTU-5soeYlYYWIxq28,1187
56
- synapse_sdk/devtools/docs/sidebars.ts,sha256=ZfHa2kSwhvnDAsTZo6DR3IjeNXC4-J-_jYWSvZOA_zg,1559
56
+ synapse_sdk/devtools/docs/sidebars.ts,sha256=mvTBax6592aFOHth_ejBTEqlqA60xM_A1UMIHbTe6Qg,1593
57
57
  synapse_sdk/devtools/docs/tsconfig.json,sha256=O9BNlRPjPiaVHW2_boShMbmTnh0Z2k0KQO6Alf9FMVY,215
58
58
  synapse_sdk/devtools/docs/blog/2019-05-28-first-blog-post.md,sha256=iP7gl_FPqo-qX13lkSRcRoT6ayJNmCkXoyvlm7GH248,312
59
59
  synapse_sdk/devtools/docs/blog/2019-05-29-long-blog-post.md,sha256=cM-dhhTeurEWMcdn0Kx-NpNts2YUUraSI_XFk_gVHEE,3122
@@ -89,6 +89,7 @@ synapse_sdk/devtools/docs/docs/features/index.md,sha256=FD2hUzTzFgKa5pcDWPtA6eVw
89
89
  synapse_sdk/devtools/docs/docs/features/converters/index.md,sha256=W5d5UO8nbOLWs1G9IgdTutlMl-d6M0hDLMJbg8DrCQ8,12713
90
90
  synapse_sdk/devtools/docs/docs/plugins/export-plugins.md,sha256=W8u8o9PWZQJ-rBvwuw-daWtqsOfFod_j_4yNj4zbOj0,27028
91
91
  synapse_sdk/devtools/docs/docs/plugins/plugins.md,sha256=2WMjbTKjIXTAdeODeTvJkDSsR9PiA58_VnCFuBnWRw4,24358
92
+ synapse_sdk/devtools/docs/docs/plugins/upload-plugins.md,sha256=6-IE6QNimgggIJF5BxeGBUhKfV76WPglGH1-olU_R8Q,18489
92
93
  synapse_sdk/devtools/docs/docs/tutorial-basics/_category_.json,sha256=qQVHZ1p0CxHg5Gb4CYNxUSeqZ3LVo4nXN_N0yUMVpDM,180
93
94
  synapse_sdk/devtools/docs/docs/tutorial-basics/congratulations.md,sha256=zJbcwKNVYGpLAGJO7e3cTdptFhb6m_NUzYDU5i6MWgc,1078
94
95
  synapse_sdk/devtools/docs/docs/tutorial-basics/create-a-blog-post.md,sha256=FNk-D3eiMmoc7sdVKazXibjsKl7-6b65KuEYkGOwcYk,886
@@ -127,6 +128,7 @@ synapse_sdk/devtools/docs/i18n/ko/docusaurus-plugin-content-docs/current/feature
127
128
  synapse_sdk/devtools/docs/i18n/ko/docusaurus-plugin-content-docs/current/features/converters/index.md,sha256=WpXcLBqC-xlvuoh-AhNOtFSo4qmnBIbR_wqLlazT7zo,1366
128
129
  synapse_sdk/devtools/docs/i18n/ko/docusaurus-plugin-content-docs/current/plugins/export-plugins.md,sha256=f1fe6zWV5t60QZwCev7e-GIW50itfZviZ8zVZTaoka0,28371
129
130
  synapse_sdk/devtools/docs/i18n/ko/docusaurus-plugin-content-docs/current/plugins/plugins.md,sha256=63auCIr_5_IFZgvPDd9XSovM1cv3TSx9U0zQRjrsxkI,3108
131
+ synapse_sdk/devtools/docs/i18n/ko/docusaurus-plugin-content-docs/current/plugins/upload-plugins.md,sha256=E-xplOw6ZEgB0rtarshmSqRIFpYL12Ax5mXULI4VWXo,24740
130
132
  synapse_sdk/devtools/docs/i18n/ko/docusaurus-theme-classic/footer.json,sha256=SCLmysIhJ6XEEfnL7cOQb3s08EG4LA-ColdRRxecIH8,1601
131
133
  synapse_sdk/devtools/docs/i18n/ko/docusaurus-theme-classic/navbar.json,sha256=M-ly81cWnesYYtCRcfMvOsKl5P0z52K9kiw0T6GIQ60,429
132
134
  synapse_sdk/devtools/docs/src/components/HomepageFeatures/index.tsx,sha256=xaUQaq9OuqoaRAZQo-ZWev0vbmIkn9l04QfUBxlhnnU,1923
@@ -161,10 +163,11 @@ synapse_sdk/devtools/streamlit_app/utils/json_viewer.py,sha256=W1OH27fq3dazrENBC
161
163
  synapse_sdk/devtools/streamlit_app/utils/log_formatter.py,sha256=fQZoEGP-FK9Sgoqh0Z-o1zX_MHpiXVZXLu_4WMcvYNQ,1292
162
164
  synapse_sdk/devtools/streamlit_app/utils/styles.py,sha256=ivVBlHzJll9uVZX25Sdbu5Hq40SOmaRamrCqY9A9aFY,5147
163
165
  synapse_sdk/devtools/streamlit_app/utils/ui_components.py,sha256=ciSyNEhPYNU6KqnfgDI9RZr1tGFZeiOJ9qBDhlXqmUY,9557
166
+ synapse_sdk/plugins/README.md,sha256=3NVHRq3wpwxNT7XYOUKjWGj9AstcrZMmpax9Tz0n_c4,28037
164
167
  synapse_sdk/plugins/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
165
168
  synapse_sdk/plugins/enums.py,sha256=ibixwqA3sCNSriG1jAtL54JQc_Zwo3MufwYUqGhVncc,523
166
169
  synapse_sdk/plugins/exceptions.py,sha256=Qs7qODp_RRLO9y2otU2T4ryj5LFwIZODvSIXkAh91u0,691
167
- synapse_sdk/plugins/models.py,sha256=2UMtDe2n8MSrPMlvNR6wATKD5mpStAjvenKC168VQdU,5361
170
+ synapse_sdk/plugins/models.py,sha256=KePsoG75wEbJlke-BAH3rTGPuJT4ByPuPA61Nq_hRnY,5683
168
171
  synapse_sdk/plugins/upload.py,sha256=VJOotYMayylOH0lNoAGeGHRkLdhP7jnC_A0rFQMvQpQ,3228
169
172
  synapse_sdk/plugins/categories/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
170
173
  synapse_sdk/plugins/categories/base.py,sha256=IYZ5vd7_5Lk5stJn2jHR9qhduSsg6lLgr1ciV_-XwlA,11327
@@ -221,10 +224,16 @@ synapse_sdk/plugins/categories/smart_tool/templates/plugin/__init__.py,sha256=47
221
224
  synapse_sdk/plugins/categories/smart_tool/templates/plugin/auto_label.py,sha256=eevNg0nOcYFR4z_L_R-sCvVOYoLWSAH1jwDkAf3YCjY,320
222
225
  synapse_sdk/plugins/categories/upload/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
223
226
  synapse_sdk/plugins/categories/upload/actions/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
224
- synapse_sdk/plugins/categories/upload/actions/upload.py,sha256=lFosLHBC0bAI6rC9BYdrmd47VoQRXDtd6hi-0p7oG04,55001
227
+ synapse_sdk/plugins/categories/upload/actions/upload/__init__.py,sha256=YYzjNk9LcMHYcy_F5m3R5KFl3JILRoUmrw7uB3iH-_c,550
228
+ synapse_sdk/plugins/categories/upload/actions/upload/action.py,sha256=Ggjfh9ZOW3yk4MoXKTYIsoVtpzkcEGJtnM2OUdVFCMs,27092
229
+ synapse_sdk/plugins/categories/upload/actions/upload/enums.py,sha256=TQ-HiGI_-15rc11XQiCT6O5hRzmjkdCnRhX3Ci3bKk0,7856
230
+ synapse_sdk/plugins/categories/upload/actions/upload/exceptions.py,sha256=QIpts9h78OD8GWCIGjX9jSV4v3Gb0cqH9Eo-6OwN1Qk,1223
231
+ synapse_sdk/plugins/categories/upload/actions/upload/models.py,sha256=DXmjTV_67P0d6WVk3XYdaYbr2rUrhVorWnf7Wgeakeg,6036
232
+ synapse_sdk/plugins/categories/upload/actions/upload/run.py,sha256=BZRwy_AtJQtlKjgHx2qadHUS9IC-E_w0zEMpwKgR-P0,6389
233
+ synapse_sdk/plugins/categories/upload/actions/upload/utils.py,sha256=I2DXxMfb-hzwCqlUjKvBCJDraiGwGxJBUuYJTucKf1Y,5316
225
234
  synapse_sdk/plugins/categories/upload/templates/config.yaml,sha256=BvW1sqs02IgzO_fndxmtQ9CCmlNPwVIiuptQzzA6uAo,998
226
235
  synapse_sdk/plugins/categories/upload/templates/plugin/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
227
- synapse_sdk/plugins/categories/upload/templates/plugin/upload.py,sha256=YW3-wYeFMU5BJPoxnzXD7VoqKTQHC3bDgENdxxmchlk,1871
236
+ synapse_sdk/plugins/categories/upload/templates/plugin/upload.py,sha256=Wdwb6cIcfuvaXiQrrf0UITWt6nHmd_dIgxXowTmyvII,1912
228
237
  synapse_sdk/plugins/templates/cookiecutter.json,sha256=NxOWk9A_v1pO0Ny4IYT9Cj5iiJ16--cIQrGC67QdR0I,396
229
238
  synapse_sdk/plugins/templates/plugin-config-schema.json,sha256=4--HbwLMvmN3BCGbaeEXZKlU_YV3utTANHSwfwR03dM,12126
230
239
  synapse_sdk/plugins/templates/schema.json,sha256=PQaH6CWYxDR6bFmTeJtEVjTZk51JWWJF7b-VzKx4-7k,14364
@@ -278,9 +287,9 @@ synapse_sdk/utils/storage/providers/gcp.py,sha256=i2BQCu1Kej1If9SuNr2_lEyTcr5M_n
278
287
  synapse_sdk/utils/storage/providers/http.py,sha256=2DhIulND47JOnS5ZY7MZUex7Su3peAPksGo1Wwg07L4,5828
279
288
  synapse_sdk/utils/storage/providers/s3.py,sha256=ZmqekAvIgcQBdRU-QVJYv1Rlp6VHfXwtbtjTSphua94,2573
280
289
  synapse_sdk/utils/storage/providers/sftp.py,sha256=_8s9hf0JXIO21gvm-JVS00FbLsbtvly4c-ETLRax68A,1426
281
- synapse_sdk-1.0.0b21.dist-info/licenses/LICENSE,sha256=bKzmC5YAg4V1Fhl8OO_tqY8j62hgdncAkN7VrdjmrGk,1101
282
- synapse_sdk-1.0.0b21.dist-info/METADATA,sha256=VD7SBqV0hCgUfPmQE46hgppxDIJaIu9zR58IuLILw_g,3745
283
- synapse_sdk-1.0.0b21.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
284
- synapse_sdk-1.0.0b21.dist-info/entry_points.txt,sha256=VNptJoGoNJI8yLXfBmhgUefMsmGI0m3-0YoMvrOgbxo,48
285
- synapse_sdk-1.0.0b21.dist-info/top_level.txt,sha256=ytgJMRK1slVOKUpgcw3LEyHHP7S34J6n_gJzdkcSsw8,12
286
- synapse_sdk-1.0.0b21.dist-info/RECORD,,
290
+ synapse_sdk-1.0.0b23.dist-info/licenses/LICENSE,sha256=bKzmC5YAg4V1Fhl8OO_tqY8j62hgdncAkN7VrdjmrGk,1101
291
+ synapse_sdk-1.0.0b23.dist-info/METADATA,sha256=9Ei8_lzCHlc2TOUN7xLUzRf41GqlAbLc8V83Icw0PVw,3745
292
+ synapse_sdk-1.0.0b23.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
293
+ synapse_sdk-1.0.0b23.dist-info/entry_points.txt,sha256=VNptJoGoNJI8yLXfBmhgUefMsmGI0m3-0YoMvrOgbxo,48
294
+ synapse_sdk-1.0.0b23.dist-info/top_level.txt,sha256=ytgJMRK1slVOKUpgcw3LEyHHP7S34J6n_gJzdkcSsw8,12
295
+ synapse_sdk-1.0.0b23.dist-info/RECORD,,