synapse-sdk 1.0.0b13__py3-none-any.whl → 1.0.0b15__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 +9 -11
- synapse_sdk/clients/backend/annotation.py +1 -1
- synapse_sdk/clients/backend/core.py +31 -4
- synapse_sdk/clients/backend/data_collection.py +78 -5
- synapse_sdk/clients/backend/hitl.py +1 -1
- synapse_sdk/clients/backend/ml.py +1 -1
- synapse_sdk/clients/base.py +23 -16
- synapse_sdk/devtools/docs/docs/api/clients/agent.md +43 -0
- synapse_sdk/devtools/docs/docs/api/clients/backend.md +53 -0
- synapse_sdk/devtools/docs/docs/api/clients/base.md +35 -0
- synapse_sdk/devtools/docs/docs/api/clients/ray.md +321 -0
- synapse_sdk/devtools/docs/docs/api/index.md +52 -0
- synapse_sdk/devtools/docs/docs/api/plugins/categories.md +43 -0
- synapse_sdk/devtools/docs/docs/api/plugins/models.md +59 -0
- synapse_sdk/devtools/docs/docs/api/plugins/utils.md +328 -0
- synapse_sdk/devtools/docs/docs/api/utils/file.md +195 -0
- synapse_sdk/devtools/docs/docs/api/utils/network.md +378 -0
- synapse_sdk/devtools/docs/docs/api/utils/storage.md +57 -0
- synapse_sdk/devtools/docs/docs/api/utils/types.md +51 -0
- synapse_sdk/devtools/docs/docs/categories.md +0 -0
- synapse_sdk/devtools/docs/docs/cli-usage.md +280 -0
- synapse_sdk/devtools/docs/docs/concepts/index.md +38 -0
- synapse_sdk/devtools/docs/docs/configuration.md +83 -0
- synapse_sdk/devtools/docs/docs/contributing.md +306 -0
- synapse_sdk/devtools/docs/docs/examples/index.md +29 -0
- synapse_sdk/devtools/docs/docs/faq.md +179 -0
- synapse_sdk/devtools/docs/docs/features/converters/index.md +455 -0
- synapse_sdk/devtools/docs/docs/features/index.md +24 -0
- synapse_sdk/devtools/docs/docs/features/plugins/index.md +509 -0
- synapse_sdk/devtools/docs/docs/installation.md +94 -0
- synapse_sdk/devtools/docs/docs/introduction.md +47 -0
- synapse_sdk/devtools/docs/docs/quickstart.md +78 -0
- synapse_sdk/devtools/docs/docs/troubleshooting.md +519 -0
- synapse_sdk/devtools/docs/docs/tutorial-basics/_category_.json +8 -0
- synapse_sdk/devtools/docs/docs/tutorial-basics/congratulations.md +23 -0
- synapse_sdk/devtools/docs/docs/tutorial-basics/create-a-blog-post.md +34 -0
- synapse_sdk/devtools/docs/docs/tutorial-basics/create-a-document.md +57 -0
- synapse_sdk/devtools/docs/docs/tutorial-basics/create-a-page.md +43 -0
- synapse_sdk/devtools/docs/docs/tutorial-basics/deploy-your-site.md +31 -0
- synapse_sdk/devtools/docs/docs/tutorial-basics/markdown-features.mdx +152 -0
- synapse_sdk/devtools/docs/docs/tutorial-extras/_category_.json +7 -0
- synapse_sdk/devtools/docs/docs/tutorial-extras/img/docsVersionDropdown.png +0 -0
- synapse_sdk/devtools/docs/docs/tutorial-extras/img/localeDropdown.png +0 -0
- synapse_sdk/devtools/docs/docs/tutorial-extras/manage-docs-versions.md +55 -0
- synapse_sdk/devtools/docs/docs/tutorial-extras/translate-your-site.md +88 -0
- synapse_sdk/devtools/docs/docusaurus.config.ts +5 -3
- synapse_sdk/devtools/docs/i18n/ko/code.json +325 -0
- synapse_sdk/devtools/docs/i18n/ko/docusaurus-plugin-content-docs/current/api/clients/agent.md +43 -0
- synapse_sdk/devtools/docs/i18n/ko/docusaurus-plugin-content-docs/current/api/clients/backend.md +53 -0
- synapse_sdk/devtools/docs/i18n/ko/docusaurus-plugin-content-docs/current/api/clients/base.md +35 -0
- synapse_sdk/devtools/docs/i18n/ko/docusaurus-plugin-content-docs/current/api/clients/ray.md +321 -0
- synapse_sdk/devtools/docs/i18n/ko/docusaurus-plugin-content-docs/current/api/index.md +52 -0
- synapse_sdk/devtools/docs/i18n/ko/docusaurus-plugin-content-docs/current/api/utils/file.md +195 -0
- synapse_sdk/devtools/docs/i18n/ko/docusaurus-plugin-content-docs/current/api/utils/network.md +378 -0
- synapse_sdk/devtools/docs/i18n/ko/docusaurus-plugin-content-docs/current/api/utils/storage.md +60 -0
- synapse_sdk/devtools/docs/i18n/ko/docusaurus-plugin-content-docs/current/api/utils/types.md +51 -0
- synapse_sdk/devtools/docs/i18n/ko/docusaurus-plugin-content-docs/current/categories.md +0 -0
- synapse_sdk/devtools/docs/i18n/ko/docusaurus-plugin-content-docs/current/cli-usage.md +280 -0
- synapse_sdk/devtools/docs/i18n/ko/docusaurus-plugin-content-docs/current/concepts/index.md +38 -0
- synapse_sdk/devtools/docs/i18n/ko/docusaurus-plugin-content-docs/current/configuration.md +83 -0
- synapse_sdk/devtools/docs/i18n/ko/docusaurus-plugin-content-docs/current/contributing.md +306 -0
- synapse_sdk/devtools/docs/i18n/ko/docusaurus-plugin-content-docs/current/examples/index.md +29 -0
- synapse_sdk/devtools/docs/i18n/ko/docusaurus-plugin-content-docs/current/faq.md +179 -0
- synapse_sdk/devtools/docs/i18n/ko/docusaurus-plugin-content-docs/current/features/converters/index.md +30 -0
- synapse_sdk/devtools/docs/i18n/ko/docusaurus-plugin-content-docs/current/features/index.md +24 -0
- synapse_sdk/devtools/docs/i18n/ko/docusaurus-plugin-content-docs/current/features/plugins/index.md +30 -0
- synapse_sdk/devtools/docs/i18n/ko/docusaurus-plugin-content-docs/current/installation.md +94 -0
- synapse_sdk/devtools/docs/i18n/ko/docusaurus-plugin-content-docs/current/introduction.md +47 -0
- synapse_sdk/devtools/docs/i18n/ko/docusaurus-plugin-content-docs/current/quickstart.md +78 -0
- synapse_sdk/devtools/docs/i18n/ko/docusaurus-plugin-content-docs/current/troubleshooting.md +519 -0
- synapse_sdk/devtools/docs/i18n/ko/docusaurus-plugin-content-docs/current.json +22 -0
- synapse_sdk/devtools/docs/i18n/ko/docusaurus-theme-classic/footer.json +42 -0
- synapse_sdk/devtools/docs/i18n/ko/docusaurus-theme-classic/navbar.json +18 -0
- synapse_sdk/devtools/docs/node_modules/shell-quote/print.py +3 -0
- synapse_sdk/devtools/docs/package.json +1 -1
- synapse_sdk/plugins/categories/export/actions/export.py +3 -0
- synapse_sdk/plugins/categories/upload/actions/upload.py +9 -4
- synapse_sdk/utils/file.py +77 -0
- {synapse_sdk-1.0.0b13.dist-info → synapse_sdk-1.0.0b15.dist-info}/METADATA +1 -1
- {synapse_sdk-1.0.0b13.dist-info → synapse_sdk-1.0.0b15.dist-info}/RECORD +84 -18
- {synapse_sdk-1.0.0b13.dist-info → synapse_sdk-1.0.0b15.dist-info}/WHEEL +0 -0
- {synapse_sdk-1.0.0b13.dist-info → synapse_sdk-1.0.0b15.dist-info}/entry_points.txt +0 -0
- {synapse_sdk-1.0.0b13.dist-info → synapse_sdk-1.0.0b15.dist-info}/licenses/LICENSE +0 -0
- {synapse_sdk-1.0.0b13.dist-info → synapse_sdk-1.0.0b15.dist-info}/top_level.txt +0 -0
synapse_sdk/clients/agent/ray.py
CHANGED
|
@@ -15,8 +15,7 @@ from synapse_sdk.utils.network import (
|
|
|
15
15
|
|
|
16
16
|
|
|
17
17
|
class RayClientMixin(BaseClient):
|
|
18
|
-
"""
|
|
19
|
-
Mixin class providing Ray cluster management and monitoring functionality.
|
|
18
|
+
"""Mixin class providing Ray cluster management and monitoring functionality.
|
|
20
19
|
|
|
21
20
|
This mixin extends BaseClient with Ray-specific operations for interacting with
|
|
22
21
|
Apache Ray distributed computing clusters. It provides comprehensive job management,
|
|
@@ -95,8 +94,7 @@ class RayClientMixin(BaseClient):
|
|
|
95
94
|
return self._get(path)
|
|
96
95
|
|
|
97
96
|
def websocket_tail_job_logs(self, pk, stream_timeout=10):
|
|
98
|
-
"""
|
|
99
|
-
Stream job logs in real-time using WebSocket protocol.
|
|
97
|
+
"""Stream job logs in real-time using WebSocket protocol.
|
|
100
98
|
|
|
101
99
|
Establishes a WebSocket connection to stream job logs as they are generated.
|
|
102
100
|
This method provides the lowest latency for real-time log monitoring and is
|
|
@@ -153,18 +151,18 @@ class RayClientMixin(BaseClient):
|
|
|
153
151
|
|
|
154
152
|
# Build WebSocket URL
|
|
155
153
|
path = f'ray/jobs/{validated_pk}/logs/ws/'
|
|
156
|
-
url = self._get_url(path)
|
|
154
|
+
url = self._get_url(path, trailing_slash=True)
|
|
157
155
|
ws_url = http_to_websocket_url(url)
|
|
158
156
|
|
|
159
157
|
# Get headers and use WebSocket manager
|
|
160
158
|
headers = self._get_headers()
|
|
159
|
+
headers['Agent-Token'] = f'Token {self.agent_token}'
|
|
161
160
|
context = f'job {validated_pk}'
|
|
162
161
|
|
|
163
162
|
return self._websocket_manager.stream_logs(ws_url, headers, validated_timeout, context)
|
|
164
163
|
|
|
165
164
|
def stream_tail_job_logs(self, pk, stream_timeout=10):
|
|
166
|
-
"""
|
|
167
|
-
Stream job logs in real-time using HTTP chunked transfer encoding.
|
|
165
|
+
"""Stream job logs in real-time using HTTP chunked transfer encoding.
|
|
168
166
|
|
|
169
167
|
Establishes an HTTP connection with chunked transfer encoding to stream
|
|
170
168
|
job logs as they are generated. This method serves as a reliable fallback
|
|
@@ -225,17 +223,17 @@ class RayClientMixin(BaseClient):
|
|
|
225
223
|
validated_timeout = validate_timeout(stream_timeout)
|
|
226
224
|
|
|
227
225
|
# Build HTTP URL and prepare request
|
|
228
|
-
path = f'ray/jobs/{validated_pk}/logs/stream'
|
|
229
|
-
url = self._get_url(path)
|
|
226
|
+
path = f'ray/jobs/{validated_pk}/logs/stream/'
|
|
227
|
+
url = self._get_url(path, trailing_slash=True)
|
|
230
228
|
headers = self._get_headers()
|
|
229
|
+
headers['Agent-Token'] = f'Token {self.agent_token}'
|
|
231
230
|
timeout = (self.timeout['connect'], validated_timeout)
|
|
232
231
|
context = f'job {validated_pk}'
|
|
233
232
|
|
|
234
233
|
return self._http_manager.stream_logs(url, headers, timeout, context)
|
|
235
234
|
|
|
236
235
|
def tail_job_logs(self, pk, stream_timeout=10, protocol='stream'):
|
|
237
|
-
"""
|
|
238
|
-
Tail job logs using either WebSocket or HTTP streaming.
|
|
236
|
+
"""Tail job logs using either WebSocket or HTTP streaming.
|
|
239
237
|
|
|
240
238
|
Args:
|
|
241
239
|
pk: Job primary key
|
|
@@ -24,7 +24,7 @@ class AnnotationClientMixin(BaseClient):
|
|
|
24
24
|
return self._list(path, params=params)
|
|
25
25
|
|
|
26
26
|
def list_tasks(self, params=None, url_conversion=None, list_all=False):
|
|
27
|
-
path = 'tasks/'
|
|
27
|
+
path = 'sdk/tasks/'
|
|
28
28
|
url_conversion = get_default_url_conversion(url_conversion, files_fields=['files'])
|
|
29
29
|
return self._list(path, params=params, url_conversion=url_conversion, list_all=list_all)
|
|
30
30
|
|
|
@@ -3,15 +3,42 @@ import os
|
|
|
3
3
|
from pathlib import Path
|
|
4
4
|
|
|
5
5
|
from synapse_sdk.clients.base import BaseClient
|
|
6
|
+
from synapse_sdk.utils.file import read_file_in_chunks
|
|
6
7
|
|
|
7
8
|
|
|
8
9
|
class CoreClientMixin(BaseClient):
|
|
9
10
|
def create_chunked_upload(self, file_path):
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
while chunk := file.read(chunk_size):
|
|
13
|
-
yield chunk
|
|
11
|
+
"""
|
|
12
|
+
Upload a file using chunked upload for efficient handling of large files.
|
|
14
13
|
|
|
14
|
+
This method breaks the file into chunks and uploads them sequentially to the server.
|
|
15
|
+
It calculates an MD5 hash of the entire file to ensure data integrity during upload.
|
|
16
|
+
|
|
17
|
+
Args:
|
|
18
|
+
file_path (str | Path): Path to the file to upload
|
|
19
|
+
|
|
20
|
+
Returns:
|
|
21
|
+
dict: Response from the server after successful upload completion,
|
|
22
|
+
typically containing upload confirmation and file metadata
|
|
23
|
+
|
|
24
|
+
Raises:
|
|
25
|
+
FileNotFoundError: If the specified file doesn't exist
|
|
26
|
+
PermissionError: If the file can't be read due to permissions
|
|
27
|
+
ClientError: If there's an error during the upload process
|
|
28
|
+
OSError: If there's an OS-level error accessing the file
|
|
29
|
+
|
|
30
|
+
Example:
|
|
31
|
+
```python
|
|
32
|
+
client = CoreClientMixin(base_url='https://api.example.com')
|
|
33
|
+
result = client.create_chunked_upload('/path/to/large_file.zip')
|
|
34
|
+
print(f"Upload completed: {result}")
|
|
35
|
+
```
|
|
36
|
+
|
|
37
|
+
Note:
|
|
38
|
+
- Uses 50MB chunks by default for optimal upload performance
|
|
39
|
+
- Automatically resumes from the last successfully uploaded chunk
|
|
40
|
+
- Verifies upload integrity using MD5 checksum
|
|
41
|
+
"""
|
|
15
42
|
file_path = Path(file_path)
|
|
16
43
|
size = os.path.getsize(file_path)
|
|
17
44
|
hash_md5 = hashlib.md5()
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
from multiprocessing import Pool
|
|
2
2
|
from pathlib import Path
|
|
3
|
-
from typing import Dict, Optional
|
|
3
|
+
from typing import Dict, Optional, Union
|
|
4
4
|
|
|
5
5
|
from tqdm import tqdm
|
|
6
6
|
|
|
@@ -9,6 +9,17 @@ from synapse_sdk.clients.utils import get_batched_list, get_default_url_conversi
|
|
|
9
9
|
|
|
10
10
|
|
|
11
11
|
class DataCollectionClientMixin(BaseClient):
|
|
12
|
+
"""Mixin class for data collection operations.
|
|
13
|
+
|
|
14
|
+
Provides methods for managing data collections, files, and units
|
|
15
|
+
in the Synapse backend. Supports both regular file uploads and
|
|
16
|
+
chunked uploads for large files.
|
|
17
|
+
|
|
18
|
+
This mixin extends BaseClient with data collection-specific functionality
|
|
19
|
+
including file upload capabilities, data unit management, and batch processing
|
|
20
|
+
operations for efficient data collection workflows.
|
|
21
|
+
"""
|
|
22
|
+
|
|
12
23
|
def list_data_collection(self):
|
|
13
24
|
path = 'data_collections/'
|
|
14
25
|
return self._list(path)
|
|
@@ -22,14 +33,66 @@ class DataCollectionClientMixin(BaseClient):
|
|
|
22
33
|
path = f'data_collections/{data_collection_id}/?expand=file_specifications'
|
|
23
34
|
return self._get(path)
|
|
24
35
|
|
|
25
|
-
def create_data_file(
|
|
26
|
-
|
|
36
|
+
def create_data_file(
|
|
37
|
+
self, file_path: Path, use_chunked_upload: bool = False
|
|
38
|
+
) -> Union[Dict[str, Union[str, int]], str]:
|
|
39
|
+
"""Create and upload a data file to the Synapse backend.
|
|
40
|
+
|
|
41
|
+
This method supports two upload strategies:
|
|
42
|
+
1. Direct file upload for smaller files (default)
|
|
43
|
+
2. Chunked upload for large files (automatic when flag is enabled)
|
|
27
44
|
|
|
28
45
|
Args:
|
|
29
|
-
file_path:
|
|
46
|
+
file_path: Path object pointing to the file to upload.
|
|
47
|
+
Must be a valid file path that exists on the filesystem.
|
|
48
|
+
use_chunked_upload: Boolean flag to enable chunked upload for the file.
|
|
49
|
+
When True, automatically creates a chunked upload for the file
|
|
50
|
+
instead of uploading it directly. Defaults to False.
|
|
51
|
+
|
|
52
|
+
Returns:
|
|
53
|
+
Dictionary containing the created data file information including:
|
|
54
|
+
- id: The unique identifier of the created data file
|
|
55
|
+
- checksum: The MD5 checksum of the uploaded file
|
|
56
|
+
- size: The file size in bytes
|
|
57
|
+
- created_at: Timestamp of creation
|
|
58
|
+
- Additional metadata fields from the backend
|
|
59
|
+
Or a string response in case of non-JSON response.
|
|
60
|
+
|
|
61
|
+
Raises:
|
|
62
|
+
FileNotFoundError: If the specified file doesn't exist (for direct upload)
|
|
63
|
+
PermissionError: If the file can't be read due to permissions
|
|
64
|
+
ClientError: If the backend returns an error response
|
|
65
|
+
ValueError: If file_path is not a valid Path object
|
|
66
|
+
|
|
67
|
+
Examples:
|
|
68
|
+
Direct file upload for small files:
|
|
69
|
+
```python
|
|
70
|
+
client = DataCollectionClientMixin(base_url='https://api.example.com')
|
|
71
|
+
file_path = Path('/path/to/small_file.csv')
|
|
72
|
+
result = client.create_data_file(file_path)
|
|
73
|
+
print(f"File uploaded with ID: {result['id']}")
|
|
74
|
+
```
|
|
75
|
+
|
|
76
|
+
Using chunked upload for large files:
|
|
77
|
+
```python
|
|
78
|
+
# Automatically create chunked upload for large file
|
|
79
|
+
file_path = Path('/path/to/large_file.zip')
|
|
80
|
+
result = client.create_data_file(file_path, use_chunked_upload=True)
|
|
81
|
+
print(f"Large file uploaded with ID: {result['id']}")
|
|
82
|
+
```
|
|
83
|
+
|
|
84
|
+
Note:
|
|
85
|
+
- For files larger than 100MB, consider using chunked upload
|
|
86
|
+
- The chunked upload will be automatically created when the flag is enabled
|
|
87
|
+
- Chunked uploads provide better reliability for large files
|
|
30
88
|
"""
|
|
31
89
|
path = 'data_files/'
|
|
32
|
-
|
|
90
|
+
if use_chunked_upload:
|
|
91
|
+
chunked_upload = self.create_chunked_upload(file_path)
|
|
92
|
+
data = {'chunked_upload': chunked_upload['id']}
|
|
93
|
+
return self._post(path, data=data)
|
|
94
|
+
else:
|
|
95
|
+
return self._post(path, files={'file': file_path})
|
|
33
96
|
|
|
34
97
|
def get_data_unit(self, data_unit_id: int, params=None):
|
|
35
98
|
path = f'data_units/{data_unit_id}/'
|
|
@@ -49,6 +112,16 @@ class DataCollectionClientMixin(BaseClient):
|
|
|
49
112
|
url_conversion = get_default_url_conversion(url_conversion, files_fields=['files'])
|
|
50
113
|
return self._list(path, params=params, url_conversion=url_conversion, list_all=list_all)
|
|
51
114
|
|
|
115
|
+
def data_file_verify_checksums(self, checksums: list[str]):
|
|
116
|
+
"""Check checksums from files are exists.
|
|
117
|
+
|
|
118
|
+
Args:
|
|
119
|
+
checksums: A list of MD5 checksums to verify.
|
|
120
|
+
"""
|
|
121
|
+
path = 'data_file/verify_checksums/'
|
|
122
|
+
data = {'checksums': checksums}
|
|
123
|
+
return self._post(path, data=data)
|
|
124
|
+
|
|
52
125
|
def upload_data_collection(
|
|
53
126
|
self,
|
|
54
127
|
data_collection_id: int,
|
|
@@ -8,7 +8,7 @@ class HITLClientMixin(BaseClient):
|
|
|
8
8
|
return self._get(path)
|
|
9
9
|
|
|
10
10
|
def list_assignments(self, params=None, url_conversion=None, list_all=False):
|
|
11
|
-
path = 'assignments/'
|
|
11
|
+
path = 'sdk/assignments/'
|
|
12
12
|
url_conversion = get_default_url_conversion(url_conversion, files_fields=['files'])
|
|
13
13
|
return self._list(path, params=params, url_conversion=url_conversion, list_all=list_all)
|
|
14
14
|
|
|
@@ -19,7 +19,7 @@ class MLClientMixin(BaseClient):
|
|
|
19
19
|
return self._post(path, data=data)
|
|
20
20
|
|
|
21
21
|
def list_ground_truth_events(self, params=None, url_conversion=None, list_all=False):
|
|
22
|
-
path = 'ground_truth_events/'
|
|
22
|
+
path = 'sdk/ground_truth_events/'
|
|
23
23
|
url_conversion = get_default_url_conversion(url_conversion, files_fields=['files'])
|
|
24
24
|
return self._list(path, params=params, url_conversion=url_conversion, list_all=list_all)
|
|
25
25
|
|
synapse_sdk/clients/base.py
CHANGED
|
@@ -39,10 +39,24 @@ class BaseClient:
|
|
|
39
39
|
|
|
40
40
|
self.requests_session = requests_session
|
|
41
41
|
|
|
42
|
-
def _get_url(self, path):
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
42
|
+
def _get_url(self, path, trailing_slash=False):
|
|
43
|
+
"""Construct a full URL from a path.
|
|
44
|
+
|
|
45
|
+
Args:
|
|
46
|
+
path (str): URL path or full URL
|
|
47
|
+
trailing_slash (bool): Whether to ensure URL ends with trailing slash
|
|
48
|
+
|
|
49
|
+
Returns:
|
|
50
|
+
str: Complete URL
|
|
51
|
+
"""
|
|
52
|
+
# Use the path as-is if it's already a full URL, otherwise construct from base_url and path
|
|
53
|
+
url = path if path.startswith(('http://', 'https://')) else f'{self.base_url}/{path.lstrip("/")}'
|
|
54
|
+
|
|
55
|
+
# Add trailing slash if requested and not present
|
|
56
|
+
if trailing_slash and not url.endswith('/'):
|
|
57
|
+
url += '/'
|
|
58
|
+
|
|
59
|
+
return url
|
|
46
60
|
|
|
47
61
|
def _get_headers(self):
|
|
48
62
|
return {}
|
|
@@ -125,8 +139,7 @@ class BaseClient:
|
|
|
125
139
|
return response.text
|
|
126
140
|
|
|
127
141
|
def _get(self, path, url_conversion=None, response_model=None, **kwargs):
|
|
128
|
-
"""
|
|
129
|
-
Perform a GET request and optionally convert response to a pydantic model.
|
|
142
|
+
"""Perform a GET request and optionally convert response to a pydantic model.
|
|
130
143
|
|
|
131
144
|
Args:
|
|
132
145
|
path (str): URL path to request.
|
|
@@ -152,8 +165,7 @@ class BaseClient:
|
|
|
152
165
|
return response
|
|
153
166
|
|
|
154
167
|
def _post(self, path, request_model=None, response_model=None, **kwargs):
|
|
155
|
-
"""
|
|
156
|
-
Perform a POST request and optionally convert response to a pydantic model.
|
|
168
|
+
"""Perform a POST request and optionally convert response to a pydantic model.
|
|
157
169
|
|
|
158
170
|
Args:
|
|
159
171
|
path (str): URL path to request.
|
|
@@ -173,8 +185,7 @@ class BaseClient:
|
|
|
173
185
|
return response
|
|
174
186
|
|
|
175
187
|
def _put(self, path, request_model=None, response_model=None, **kwargs):
|
|
176
|
-
"""
|
|
177
|
-
Perform a PUT request to the specified path.
|
|
188
|
+
"""Perform a PUT request to the specified path.
|
|
178
189
|
|
|
179
190
|
Args:
|
|
180
191
|
path (str): The URL path for the request.
|
|
@@ -196,8 +207,7 @@ class BaseClient:
|
|
|
196
207
|
return response
|
|
197
208
|
|
|
198
209
|
def _patch(self, path, request_model=None, response_model=None, **kwargs):
|
|
199
|
-
"""
|
|
200
|
-
Perform a PATCH HTTP request to the specified path.
|
|
210
|
+
"""Perform a PATCH HTTP request to the specified path.
|
|
201
211
|
|
|
202
212
|
Args:
|
|
203
213
|
path (str): The API endpoint path to make the request to.
|
|
@@ -210,7 +220,6 @@ class BaseClient:
|
|
|
210
220
|
Union[dict, BaseModel]: If response_model is provided, returns an instance of that model.
|
|
211
221
|
Otherwise, returns the raw response data.
|
|
212
222
|
"""
|
|
213
|
-
|
|
214
223
|
if kwargs.get('data') and request_model:
|
|
215
224
|
kwargs['data'] = self._validate_request_body_with_pydantic_model(kwargs['data'], request_model)
|
|
216
225
|
response = self._request('patch', path, **kwargs)
|
|
@@ -220,8 +229,7 @@ class BaseClient:
|
|
|
220
229
|
return response
|
|
221
230
|
|
|
222
231
|
def _delete(self, path, request_model=None, response_model=None, **kwargs):
|
|
223
|
-
"""
|
|
224
|
-
Performs a DELETE request to the specified path.
|
|
232
|
+
"""Performs a DELETE request to the specified path.
|
|
225
233
|
|
|
226
234
|
Args:
|
|
227
235
|
path (str): The API endpoint path to send the DELETE request to.
|
|
@@ -234,7 +242,6 @@ class BaseClient:
|
|
|
234
242
|
Union[dict, BaseModel]: If response_model is provided, returns an instance of that model.
|
|
235
243
|
Otherwise, returns the raw response data as a dictionary.
|
|
236
244
|
"""
|
|
237
|
-
|
|
238
245
|
if kwargs.get('data') and request_model:
|
|
239
246
|
kwargs['data'] = self._validate_request_body_with_pydantic_model(kwargs['data'], request_model)
|
|
240
247
|
response = self._request('delete', path, **kwargs)
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
---
|
|
2
|
+
id: agent
|
|
3
|
+
title: AgentClient
|
|
4
|
+
sidebar_position: 2
|
|
5
|
+
---
|
|
6
|
+
|
|
7
|
+
# AgentClient
|
|
8
|
+
|
|
9
|
+
Client for agent-specific operations and distributed execution.
|
|
10
|
+
|
|
11
|
+
## Overview
|
|
12
|
+
|
|
13
|
+
The `AgentClient` provides access to agent operations, including plugin execution, job management, and distributed computing integration.
|
|
14
|
+
|
|
15
|
+
## Constructor
|
|
16
|
+
|
|
17
|
+
```python
|
|
18
|
+
AgentClient(
|
|
19
|
+
base_url: str,
|
|
20
|
+
agent_token: str = None,
|
|
21
|
+
timeout: dict = None
|
|
22
|
+
)
|
|
23
|
+
```
|
|
24
|
+
|
|
25
|
+
## Usage
|
|
26
|
+
|
|
27
|
+
```python
|
|
28
|
+
from synapse_sdk.clients.agent import AgentClient
|
|
29
|
+
|
|
30
|
+
client = AgentClient(
|
|
31
|
+
base_url="https://api.synapse.sh",
|
|
32
|
+
agent_token="your-agent-token"
|
|
33
|
+
)
|
|
34
|
+
```
|
|
35
|
+
|
|
36
|
+
## Methods
|
|
37
|
+
|
|
38
|
+
Coming soon - detailed API documentation for AgentClient methods.
|
|
39
|
+
|
|
40
|
+
## See Also
|
|
41
|
+
|
|
42
|
+
- [BackendClient](./backend.md) - For backend operations
|
|
43
|
+
- [BaseClient](./base.md) - Base client implementation
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
---
|
|
2
|
+
id: backend
|
|
3
|
+
title: BackendClient
|
|
4
|
+
sidebar_position: 1
|
|
5
|
+
---
|
|
6
|
+
|
|
7
|
+
# BackendClient
|
|
8
|
+
|
|
9
|
+
Main client for interacting with the Synapse backend API.
|
|
10
|
+
|
|
11
|
+
## Overview
|
|
12
|
+
|
|
13
|
+
The `BackendClient` provides comprehensive access to all backend operations including data management, plugin execution, annotations, and machine learning workflows. It aggregates functionality from multiple specialized mixins.
|
|
14
|
+
|
|
15
|
+
## Constructor
|
|
16
|
+
|
|
17
|
+
```python
|
|
18
|
+
BackendClient(
|
|
19
|
+
base_url: str,
|
|
20
|
+
api_token: str = None,
|
|
21
|
+
agent_token: str = None,
|
|
22
|
+
timeout: dict = None
|
|
23
|
+
)
|
|
24
|
+
```
|
|
25
|
+
|
|
26
|
+
### Parameters
|
|
27
|
+
|
|
28
|
+
- **base_url** (`str`): The base URL of the Synapse backend API
|
|
29
|
+
- **api_token** (`str`, optional): API authentication token. Can also be set via `SYNAPSE_API_TOKEN` environment variable
|
|
30
|
+
- **agent_token** (`str`, optional): Agent authentication token. Can also be set via `SYNAPSE_AGENT_TOKEN` environment variable
|
|
31
|
+
- **timeout** (`dict`, optional): Custom timeout settings. Defaults to `{'connect': 5, 'read': 30}`
|
|
32
|
+
|
|
33
|
+
### Example
|
|
34
|
+
|
|
35
|
+
```python
|
|
36
|
+
from synapse_sdk.clients.backend import BackendClient
|
|
37
|
+
|
|
38
|
+
# Create client with explicit token
|
|
39
|
+
client = BackendClient(
|
|
40
|
+
base_url="https://api.synapse.sh",
|
|
41
|
+
api_token="your-api-token"
|
|
42
|
+
)
|
|
43
|
+
|
|
44
|
+
# Or use environment variables
|
|
45
|
+
import os
|
|
46
|
+
os.environ['SYNAPSE_API_TOKEN'] = "your-api-token"
|
|
47
|
+
client = BackendClient(base_url="https://api.synapse.sh")
|
|
48
|
+
```
|
|
49
|
+
|
|
50
|
+
## See Also
|
|
51
|
+
|
|
52
|
+
- [AgentClient](./agent.md) - For agent-specific operations
|
|
53
|
+
- [BaseClient](./base.md) - Base client implementation
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
---
|
|
2
|
+
id: base
|
|
3
|
+
title: BaseClient
|
|
4
|
+
sidebar_position: 3
|
|
5
|
+
---
|
|
6
|
+
|
|
7
|
+
# BaseClient
|
|
8
|
+
|
|
9
|
+
Base class for all Synapse SDK clients.
|
|
10
|
+
|
|
11
|
+
## Overview
|
|
12
|
+
|
|
13
|
+
The `BaseClient` provides common functionality for HTTP operations, error handling, and request management used by all other clients.
|
|
14
|
+
|
|
15
|
+
## Features
|
|
16
|
+
|
|
17
|
+
- HTTP request handling with retry logic
|
|
18
|
+
- Automatic timeout management
|
|
19
|
+
- File upload/download capabilities
|
|
20
|
+
- Pydantic model validation
|
|
21
|
+
- Connection pooling
|
|
22
|
+
|
|
23
|
+
## Usage
|
|
24
|
+
|
|
25
|
+
```python
|
|
26
|
+
from synapse_sdk.clients.base import BaseClient
|
|
27
|
+
|
|
28
|
+
# BaseClient is typically not used directly
|
|
29
|
+
# Use BackendClient or AgentClient instead
|
|
30
|
+
```
|
|
31
|
+
|
|
32
|
+
## See Also
|
|
33
|
+
|
|
34
|
+
- [BackendClient](./backend.md) - Main client implementation
|
|
35
|
+
- [AgentClient](./agent.md) - Agent-specific operations
|