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

Files changed (49) hide show
  1. synapse_sdk/devtools/docs/docs/api/clients/ray.md +1 -1
  2. synapse_sdk/devtools/docs/docs/api/index.md +5 -5
  3. synapse_sdk/devtools/docs/docs/features/utils/file.md +415 -0
  4. synapse_sdk/devtools/docs/docs/{api → features}/utils/network.md +1 -1
  5. synapse_sdk/devtools/docs/docs/plugins/export-plugins.md +140 -0
  6. synapse_sdk/devtools/docs/docs/plugins/upload-plugins.md +680 -0
  7. synapse_sdk/devtools/docs/i18n/ko/docusaurus-plugin-content-docs/current/api/clients/ray.md +1 -1
  8. synapse_sdk/devtools/docs/i18n/ko/docusaurus-plugin-content-docs/current/api/index.md +5 -5
  9. synapse_sdk/devtools/docs/i18n/ko/docusaurus-plugin-content-docs/current/features/index.md +5 -5
  10. synapse_sdk/devtools/docs/i18n/ko/docusaurus-plugin-content-docs/current/features/utils/file.md +415 -0
  11. synapse_sdk/devtools/docs/i18n/ko/docusaurus-plugin-content-docs/current/{api → features}/utils/network.md +1 -1
  12. synapse_sdk/devtools/docs/i18n/ko/docusaurus-plugin-content-docs/current/plugins/export-plugins.md +138 -0
  13. synapse_sdk/devtools/docs/i18n/ko/docusaurus-plugin-content-docs/current/plugins/plugins.md +48 -2
  14. synapse_sdk/devtools/docs/i18n/ko/docusaurus-plugin-content-docs/current/plugins/upload-plugins.md +897 -0
  15. synapse_sdk/devtools/docs/sidebars.ts +11 -10
  16. synapse_sdk/plugins/README.md +934 -0
  17. synapse_sdk/plugins/categories/export/templates/plugin/__init__.py +17 -2
  18. synapse_sdk/plugins/categories/upload/actions/upload/__init__.py +20 -0
  19. synapse_sdk/plugins/categories/upload/actions/upload/action.py +623 -0
  20. synapse_sdk/plugins/categories/upload/actions/upload/enums.py +221 -0
  21. synapse_sdk/plugins/categories/upload/actions/upload/exceptions.py +36 -0
  22. synapse_sdk/plugins/categories/upload/actions/upload/models.py +149 -0
  23. synapse_sdk/plugins/categories/upload/actions/upload/run.py +178 -0
  24. synapse_sdk/plugins/categories/upload/actions/upload/utils.py +139 -0
  25. synapse_sdk/plugins/categories/upload/templates/plugin/upload.py +6 -1
  26. synapse_sdk/plugins/models.py +13 -7
  27. synapse_sdk/utils/file/__init__.py +39 -0
  28. synapse_sdk/utils/file/archive.py +32 -0
  29. synapse_sdk/utils/file/checksum.py +56 -0
  30. synapse_sdk/utils/file/chunking.py +31 -0
  31. synapse_sdk/utils/file/download.py +124 -0
  32. synapse_sdk/utils/file/encoding.py +40 -0
  33. synapse_sdk/utils/file/io.py +22 -0
  34. synapse_sdk/utils/file/video/__init__.py +29 -0
  35. synapse_sdk/utils/file/video/transcode.py +307 -0
  36. {synapse_sdk-1.0.0b22.dist-info → synapse_sdk-1.0.0b24.dist-info}/METADATA +2 -1
  37. {synapse_sdk-1.0.0b22.dist-info → synapse_sdk-1.0.0b24.dist-info}/RECORD +46 -28
  38. synapse_sdk/devtools/docs/docs/api/utils/file.md +0 -195
  39. synapse_sdk/devtools/docs/i18n/ko/docusaurus-plugin-content-docs/current/api/utils/file.md +0 -195
  40. synapse_sdk/plugins/categories/upload/actions/upload.py +0 -1368
  41. /synapse_sdk/devtools/docs/docs/{api → features}/utils/storage.md +0 -0
  42. /synapse_sdk/devtools/docs/docs/{api → features}/utils/types.md +0 -0
  43. /synapse_sdk/devtools/docs/i18n/ko/docusaurus-plugin-content-docs/current/{api → features}/utils/storage.md +0 -0
  44. /synapse_sdk/devtools/docs/i18n/ko/docusaurus-plugin-content-docs/current/{api → features}/utils/types.md +0 -0
  45. /synapse_sdk/utils/{file.py → file.py.backup} +0 -0
  46. {synapse_sdk-1.0.0b22.dist-info → synapse_sdk-1.0.0b24.dist-info}/WHEEL +0 -0
  47. {synapse_sdk-1.0.0b22.dist-info → synapse_sdk-1.0.0b24.dist-info}/entry_points.txt +0 -0
  48. {synapse_sdk-1.0.0b22.dist-info → synapse_sdk-1.0.0b24.dist-info}/licenses/LICENSE +0 -0
  49. {synapse_sdk-1.0.0b22.dist-info → synapse_sdk-1.0.0b24.dist-info}/top_level.txt +0 -0
@@ -1,195 +0,0 @@
1
- ---
2
- id: file
3
- title: File Utilities
4
- sidebar_position: 1
5
- ---
6
-
7
- # File Utilities
8
-
9
- File operations and handling utilities.
10
-
11
- ## File Operations
12
-
13
- ### Archive Functions
14
-
15
- Functions for creating and extracting plugin archives.
16
-
17
- ### Download Functions
18
-
19
- Utilities for downloading files from URLs.
20
-
21
- ```python
22
- from synapse_sdk.utils.file import download_file
23
-
24
- local_path = download_file(url, destination)
25
- ```
26
-
27
- ### Upload Functions
28
-
29
- File upload utilities with chunked upload support.
30
-
31
- ## Chunked File Operations
32
-
33
- ### read_file_in_chunks
34
-
35
- Read files in chunks for efficient memory usage, particularly useful for large files or when processing files in chunks for uploading or hashing.
36
-
37
- ```python
38
- from synapse_sdk.utils.file import read_file_in_chunks
39
-
40
- # Read a file in default 50MB chunks
41
- for chunk in read_file_in_chunks('/path/to/large_file.bin'):
42
- process_chunk(chunk)
43
-
44
- # Read with custom chunk size (10MB)
45
- for chunk in read_file_in_chunks('/path/to/file.bin', chunk_size=1024*1024*10):
46
- upload_chunk(chunk)
47
- ```
48
-
49
- **Parameters:**
50
-
51
- - `file_path` (str | Path): Path to the file to read
52
- - `chunk_size` (int, optional): Size of each chunk in bytes. Defaults to 50MB (52,428,800 bytes)
53
-
54
- **Returns:**
55
-
56
- - Generator yielding file content chunks as bytes
57
-
58
- **Raises:**
59
-
60
- - `FileNotFoundError`: If the file doesn't exist
61
- - `PermissionError`: If the file can't be read due to permissions
62
- - `OSError`: If there's an OS-level error reading the file
63
-
64
- ### Use Cases
65
-
66
- **Large File Processing**: Efficiently process files that are too large to fit in memory:
67
-
68
- ```python
69
- import hashlib
70
-
71
- def calculate_hash_for_large_file(file_path):
72
- hash_md5 = hashlib.md5()
73
- for chunk in read_file_in_chunks(file_path):
74
- hash_md5.update(chunk)
75
- return hash_md5.hexdigest()
76
- ```
77
-
78
- **Chunked Upload Integration**: The function integrates seamlessly with the `CoreClientMixin.create_chunked_upload` method:
79
-
80
- ```python
81
- from synapse_sdk.clients.backend.core import CoreClientMixin
82
-
83
- client = CoreClientMixin(base_url='https://api.example.com')
84
- result = client.create_chunked_upload('/path/to/large_file.zip')
85
- ```
86
-
87
- **Best Practices:**
88
-
89
- - Use default chunk size (50MB) for optimal upload performance
90
- - Adjust chunk size based on available memory and network conditions
91
- - For very large files (>1GB), consider using smaller chunks for better progress tracking
92
- - Always handle exceptions when working with file operations
93
-
94
- ## Checksum Functions
95
-
96
- ### get_checksum_from_file
97
-
98
- Calculate checksum for file-like objects without requiring Django dependencies. This function works with any file-like object that has a `read()` method, making it compatible with Django's File objects, BytesIO, StringIO, and regular file objects.
99
-
100
- ```python
101
- import hashlib
102
- from io import BytesIO
103
- from synapse_sdk.utils.file import get_checksum_from_file
104
-
105
- # Basic usage with BytesIO (defaults to SHA1)
106
- data = BytesIO(b'Hello, world!')
107
- checksum = get_checksum_from_file(data)
108
- print(checksum) # SHA1 hash as hexadecimal string
109
-
110
- # Using different hash algorithms
111
- checksum_md5 = get_checksum_from_file(data, digest_mod=hashlib.md5)
112
- checksum_sha256 = get_checksum_from_file(data, digest_mod=hashlib.sha256)
113
-
114
- # With real file objects
115
- with open('/path/to/file.txt', 'rb') as f:
116
- checksum = get_checksum_from_file(f)
117
-
118
- # With StringIO (text files)
119
- from io import StringIO
120
- text_data = StringIO('Hello, world!')
121
- checksum = get_checksum_from_file(text_data) # Automatically UTF-8 encoded
122
- ```
123
-
124
- **Parameters:**
125
-
126
- - `file` (IO[Any]): File-like object with read() method that supports reading in chunks
127
- - `digest_mod` (Callable[[], Any], optional): Hash algorithm from hashlib. Defaults to `hashlib.sha1`
128
-
129
- **Returns:**
130
-
131
- - `str`: Hexadecimal digest of the file contents
132
-
133
- **Key Features:**
134
-
135
- - **Memory Efficient**: Reads files in 4KB chunks to handle large files
136
- - **Automatic File Pointer Reset**: Resets to beginning if the file object supports seeking
137
- - **Text/Binary Agnostic**: Handles both text (StringIO) and binary (BytesIO) file objects
138
- - **No Django Dependency**: Works without Django while being compatible with Django File objects
139
- - **Flexible Hash Algorithms**: Supports any hashlib algorithm (SHA1, SHA256, MD5, etc.)
140
-
141
- **Use Cases:**
142
-
143
- **Django File Object Compatibility**: Works with Django's File objects without requiring Django:
144
-
145
- ```python
146
- # Simulating Django File-like behavior
147
- class FileWrapper:
148
- def __init__(self, data):
149
- self._data = data
150
- self._pos = 0
151
-
152
- def read(self, size=None):
153
- if size is None:
154
- result = self._data[self._pos:]
155
- self._pos = len(self._data)
156
- else:
157
- result = self._data[self._pos:self._pos + size]
158
- self._pos += len(result)
159
- return result
160
-
161
- file_obj = FileWrapper(b'File content')
162
- checksum = get_checksum_from_file(file_obj)
163
- ```
164
-
165
- **Large File Processing**: Efficiently calculate checksums for large files:
166
-
167
- ```python
168
- # Large file processing with memory efficiency
169
- with open('/path/to/large_file.bin', 'rb') as large_file:
170
- checksum = get_checksum_from_file(large_file, digest_mod=hashlib.sha256)
171
- ```
172
-
173
- **Multiple Hash Algorithms**: Calculate different checksums for the same file:
174
-
175
- ```python
176
- algorithms = [
177
- ('MD5', hashlib.md5),
178
- ('SHA1', hashlib.sha1),
179
- ('SHA256', hashlib.sha256),
180
- ]
181
-
182
- with open('/path/to/file.bin', 'rb') as f:
183
- checksums = {}
184
- for name, algo in algorithms:
185
- f.seek(0) # Reset file pointer
186
- checksums[name] = get_checksum_from_file(f, digest_mod=algo)
187
- ```
188
-
189
- ## Path Utilities
190
-
191
- Functions for path manipulation and validation.
192
-
193
- ## Temporary Files
194
-
195
- Utilities for managing temporary files and cleanup.
@@ -1,195 +0,0 @@
1
- ---
2
- id: file
3
- title: 파일 유틸리티
4
- sidebar_position: 1
5
- ---
6
-
7
- # 파일 유틸리티
8
-
9
- 파일 작업 및 처리 유틸리티입니다.
10
-
11
- ## 파일 작업
12
-
13
- ### 아카이브 함수
14
-
15
- 플러그인 아카이브를 생성하고 추출하는 함수입니다.
16
-
17
- ### 다운로드 함수
18
-
19
- URL에서 파일을 다운로드하는 유틸리티입니다.
20
-
21
- ```python
22
- from synapse_sdk.utils.file import download_file
23
-
24
- local_path = download_file(url, destination)
25
- ```
26
-
27
- ### 업로드 함수
28
-
29
- 청크 업로드 지원을 포함한 파일 업로드 유틸리티입니다.
30
-
31
- ## 청크 파일 작업
32
-
33
- ### read_file_in_chunks
34
-
35
- 효율적인 메모리 사용을 위해 파일을 청크 단위로 읽습니다. 대용량 파일이나 업로드 또는 해싱을 위해 파일을 청크 단위로 처리할 때 특히 유용합니다.
36
-
37
- ```python
38
- from synapse_sdk.utils.file import read_file_in_chunks
39
-
40
- # 기본 50MB 청크로 파일 읽기
41
- for chunk in read_file_in_chunks('/path/to/large_file.bin'):
42
- process_chunk(chunk)
43
-
44
- # 사용자 정의 청크 크기로 읽기 (10MB)
45
- for chunk in read_file_in_chunks('/path/to/file.bin', chunk_size=1024*1024*10):
46
- upload_chunk(chunk)
47
- ```
48
-
49
- **매개변수:**
50
-
51
- - `file_path` (str | Path): 읽을 파일의 경로
52
- - `chunk_size` (int, 선택사항): 각 청크의 바이트 크기. 기본값은 50MB (52,428,800바이트)
53
-
54
- **반환값:**
55
-
56
- - 파일 내용 청크를 바이트로 생성하는 제너레이터
57
-
58
- **예외:**
59
-
60
- - `FileNotFoundError`: 파일이 존재하지 않는 경우
61
- - `PermissionError`: 권한으로 인해 파일을 읽을 수 없는 경우
62
- - `OSError`: 파일 읽기 시 OS 수준 오류가 발생한 경우
63
-
64
- ### 사용 사례
65
-
66
- **대용량 파일 처리**: 메모리에 맞지 않는 대용량 파일을 효율적으로 처리합니다:
67
-
68
- ```python
69
- import hashlib
70
-
71
- def calculate_hash_for_large_file(file_path):
72
- hash_md5 = hashlib.md5()
73
- for chunk in read_file_in_chunks(file_path):
74
- hash_md5.update(chunk)
75
- return hash_md5.hexdigest()
76
- ```
77
-
78
- **청크 업로드 통합**: 이 함수는 `CoreClientMixin.create_chunked_upload` 메서드와 완벽하게 통합됩니다:
79
-
80
- ```python
81
- from synapse_sdk.clients.backend.core import CoreClientMixin
82
-
83
- client = CoreClientMixin(base_url='https://api.example.com')
84
- result = client.create_chunked_upload('/path/to/large_file.zip')
85
- ```
86
-
87
- **모범 사례:**
88
-
89
- - 최적의 업로드 성능을 위해 기본 청크 크기(50MB) 사용
90
- - 사용 가능한 메모리와 네트워크 조건에 따라 청크 크기 조정
91
- - 매우 큰 파일(>1GB)의 경우, 더 나은 진행 상황 추적을 위해 작은 청크 사용 고려
92
- - 파일 작업 시 항상 예외 처리
93
-
94
- ## 체크섬 함수
95
-
96
- ### get_checksum_from_file
97
-
98
- Django 의존성 없이 파일 형태 객체의 체크섬을 계산합니다. 이 함수는 `read()` 메서드가 있는 모든 파일 형태 객체와 함께 작동하며, Django의 File 객체, BytesIO, StringIO, 일반 파일 객체와 호환됩니다.
99
-
100
- ```python
101
- import hashlib
102
- from io import BytesIO
103
- from synapse_sdk.utils.file import get_checksum_from_file
104
-
105
- # BytesIO와 기본 사용법 (기본값은 SHA1)
106
- data = BytesIO(b'Hello, world!')
107
- checksum = get_checksum_from_file(data)
108
- print(checksum) # 16진수 문자열로 된 SHA1 해시
109
-
110
- # 다른 해시 알고리즘 사용
111
- checksum_md5 = get_checksum_from_file(data, digest_mod=hashlib.md5)
112
- checksum_sha256 = get_checksum_from_file(data, digest_mod=hashlib.sha256)
113
-
114
- # 실제 파일 객체와 함께 사용
115
- with open('/path/to/file.txt', 'rb') as f:
116
- checksum = get_checksum_from_file(f)
117
-
118
- # StringIO와 함께 사용 (텍스트 파일)
119
- from io import StringIO
120
- text_data = StringIO('Hello, world!')
121
- checksum = get_checksum_from_file(text_data) # 자동으로 UTF-8로 인코딩
122
- ```
123
-
124
- **매개변수:**
125
-
126
- - `file` (IO[Any]): 청크 단위로 읽기를 지원하는 read() 메서드가 있는 파일 형태 객체
127
- - `digest_mod` (Callable[[], Any], 선택사항): hashlib의 해시 알고리즘. 기본값은 `hashlib.sha1`
128
-
129
- **반환값:**
130
-
131
- - `str`: 파일 내용의 16진수 다이제스트
132
-
133
- **주요 기능:**
134
-
135
- - **메모리 효율적**: 대용량 파일을 처리하기 위해 4KB 청크로 파일 읽기
136
- - **자동 파일 포인터 리셋**: 파일 객체가 시킹을 지원하는 경우 시작 위치로 리셋
137
- - **텍스트/바이너리 무관**: 텍스트(StringIO)와 바이너리(BytesIO) 파일 객체 모두 처리
138
- - **Django 의존성 없음**: Django File 객체와 호환되면서도 Django 없이 작동
139
- - **유연한 해시 알고리즘**: 모든 hashlib 알고리즘 지원 (SHA1, SHA256, MD5 등)
140
-
141
- **사용 사례:**
142
-
143
- **Django 파일 객체 호환성**: Django를 요구하지 않으면서도 Django의 File 객체와 함께 작동합니다:
144
-
145
- ```python
146
- # Django File 형태 동작 시뮬레이션
147
- class FileWrapper:
148
- def __init__(self, data):
149
- self._data = data
150
- self._pos = 0
151
-
152
- def read(self, size=None):
153
- if size is None:
154
- result = self._data[self._pos:]
155
- self._pos = len(self._data)
156
- else:
157
- result = self._data[self._pos:self._pos + size]
158
- self._pos += len(result)
159
- return result
160
-
161
- file_obj = FileWrapper(b'File content')
162
- checksum = get_checksum_from_file(file_obj)
163
- ```
164
-
165
- **대용량 파일 처리**: 대용량 파일의 체크섬을 효율적으로 계산합니다:
166
-
167
- ```python
168
- # 메모리 효율성을 갖춘 대용량 파일 처리
169
- with open('/path/to/large_file.bin', 'rb') as large_file:
170
- checksum = get_checksum_from_file(large_file, digest_mod=hashlib.sha256)
171
- ```
172
-
173
- **다중 해시 알고리즘**: 같은 파일에 대해 다른 체크섬을 계산합니다:
174
-
175
- ```python
176
- algorithms = [
177
- ('MD5', hashlib.md5),
178
- ('SHA1', hashlib.sha1),
179
- ('SHA256', hashlib.sha256),
180
- ]
181
-
182
- with open('/path/to/file.bin', 'rb') as f:
183
- checksums = {}
184
- for name, algo in algorithms:
185
- f.seek(0) # 파일 포인터 리셋
186
- checksums[name] = get_checksum_from_file(f, digest_mod=algo)
187
- ```
188
-
189
- ## 경로 유틸리티
190
-
191
- 경로 조작 및 검증을 위한 함수입니다.
192
-
193
- ## 임시 파일
194
-
195
- 임시 파일 관리 및 정리를 위한 유틸리티입니다.