synapse-sdk 1.0.0b23__py3-none-any.whl → 2025.9.1__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/clients/agent/ray.py +50 -0
- synapse_sdk/devtools/docs/docs/api/clients/ray.md +24 -3
- synapse_sdk/devtools/docs/docs/api/index.md +5 -5
- synapse_sdk/devtools/docs/docs/features/utils/file.md +415 -0
- synapse_sdk/devtools/docs/docs/{api → features}/utils/network.md +1 -1
- synapse_sdk/devtools/docs/docs/plugins/export-plugins.md +140 -0
- synapse_sdk/devtools/docs/i18n/ko/docusaurus-plugin-content-docs/current/api/clients/ray.md +24 -3
- synapse_sdk/devtools/docs/i18n/ko/docusaurus-plugin-content-docs/current/api/index.md +5 -5
- synapse_sdk/devtools/docs/i18n/ko/docusaurus-plugin-content-docs/current/features/index.md +5 -5
- synapse_sdk/devtools/docs/i18n/ko/docusaurus-plugin-content-docs/current/features/utils/file.md +415 -0
- synapse_sdk/devtools/docs/i18n/ko/docusaurus-plugin-content-docs/current/{api → features}/utils/network.md +1 -1
- synapse_sdk/devtools/docs/i18n/ko/docusaurus-plugin-content-docs/current/plugins/export-plugins.md +138 -0
- synapse_sdk/devtools/docs/i18n/ko/docusaurus-plugin-content-docs/current/plugins/plugins.md +48 -2
- synapse_sdk/devtools/docs/sidebars.ts +10 -10
- synapse_sdk/plugins/categories/export/templates/plugin/__init__.py +17 -2
- synapse_sdk/utils/file/__init__.py +39 -0
- synapse_sdk/utils/file/archive.py +32 -0
- synapse_sdk/utils/file/checksum.py +56 -0
- synapse_sdk/utils/file/chunking.py +31 -0
- synapse_sdk/utils/file/download.py +124 -0
- synapse_sdk/utils/file/encoding.py +40 -0
- synapse_sdk/utils/file/io.py +22 -0
- synapse_sdk/utils/file/video/__init__.py +29 -0
- synapse_sdk/utils/file/video/transcode.py +307 -0
- {synapse_sdk-1.0.0b23.dist-info → synapse_sdk-2025.9.1.dist-info}/METADATA +3 -2
- {synapse_sdk-1.0.0b23.dist-info → synapse_sdk-2025.9.1.dist-info}/RECORD +35 -26
- synapse_sdk/devtools/docs/docs/api/utils/file.md +0 -195
- synapse_sdk/devtools/docs/i18n/ko/docusaurus-plugin-content-docs/current/api/utils/file.md +0 -195
- /synapse_sdk/devtools/docs/docs/{api → features}/utils/storage.md +0 -0
- /synapse_sdk/devtools/docs/docs/{api → features}/utils/types.md +0 -0
- /synapse_sdk/devtools/docs/i18n/ko/docusaurus-plugin-content-docs/current/{api → features}/utils/storage.md +0 -0
- /synapse_sdk/devtools/docs/i18n/ko/docusaurus-plugin-content-docs/current/{api → features}/utils/types.md +0 -0
- /synapse_sdk/utils/{file.py → file.py.backup} +0 -0
- {synapse_sdk-1.0.0b23.dist-info → synapse_sdk-2025.9.1.dist-info}/WHEEL +0 -0
- {synapse_sdk-1.0.0b23.dist-info → synapse_sdk-2025.9.1.dist-info}/entry_points.txt +0 -0
- {synapse_sdk-1.0.0b23.dist-info → synapse_sdk-2025.9.1.dist-info}/licenses/LICENSE +0 -0
- {synapse_sdk-1.0.0b23.dist-info → synapse_sdk-2025.9.1.dist-info}/top_level.txt +0 -0
|
@@ -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
|
-
임시 파일 관리 및 정리를 위한 유틸리티입니다.
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|