synapse-sdk 1.0.0b13__py3-none-any.whl → 1.0.0b14__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.
- locale/ko/LC_MESSAGES/messages.mo +0 -0
- 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.0b14.dist-info}/METADATA +1 -1
- {synapse_sdk-1.0.0b13.dist-info → synapse_sdk-1.0.0b14.dist-info}/RECORD +85 -19
- {synapse_sdk-1.0.0b13.dist-info → synapse_sdk-1.0.0b14.dist-info}/WHEEL +0 -0
- {synapse_sdk-1.0.0b13.dist-info → synapse_sdk-1.0.0b14.dist-info}/entry_points.txt +0 -0
- {synapse_sdk-1.0.0b13.dist-info → synapse_sdk-1.0.0b14.dist-info}/licenses/LICENSE +0 -0
- {synapse_sdk-1.0.0b13.dist-info → synapse_sdk-1.0.0b14.dist-info}/top_level.txt +0 -0
|
@@ -0,0 +1,509 @@
|
|
|
1
|
+
---
|
|
2
|
+
id: plugins
|
|
3
|
+
title: Plugin System
|
|
4
|
+
sidebar_position: 2
|
|
5
|
+
---
|
|
6
|
+
|
|
7
|
+
# Plugin System
|
|
8
|
+
|
|
9
|
+
The Synapse SDK provides a comprehensive plugin system for building and managing ML plugins across different categories and execution methods. The plugin system enables modular, reusable components that can be distributed and executed in various environments.
|
|
10
|
+
|
|
11
|
+
## Overview
|
|
12
|
+
|
|
13
|
+
The plugin system is built around the concept of **actions** - discrete operations that can be packaged, distributed, and executed in different contexts. Each plugin belongs to a specific category and can support multiple actions.
|
|
14
|
+
|
|
15
|
+
### Key Features
|
|
16
|
+
|
|
17
|
+
- **🔌 Modular Architecture**: Plugins are self-contained with their own dependencies and configuration
|
|
18
|
+
- **⚡ Multiple Execution Methods**: Support for Jobs, Tasks, and REST API endpoints
|
|
19
|
+
- **📦 Distributed Execution**: Built for scalable, distributed computing
|
|
20
|
+
- **🛠️ Template System**: Cookiecutter-based scaffolding for rapid plugin development
|
|
21
|
+
- **📊 Progress Tracking**: Built-in logging, metrics, and progress monitoring
|
|
22
|
+
- **🔄 Dynamic Loading**: Runtime plugin discovery and registration
|
|
23
|
+
|
|
24
|
+
## Plugin Categories
|
|
25
|
+
|
|
26
|
+
The SDK organizes plugins into specific categories, each designed for different aspects of ML workflows:
|
|
27
|
+
|
|
28
|
+
### 1. Neural Networks (`neural_net`)
|
|
29
|
+
|
|
30
|
+
ML model training, inference, and deployment operations.
|
|
31
|
+
|
|
32
|
+
**Available Actions:**
|
|
33
|
+
- `deployment` - Deploy models to production environments
|
|
34
|
+
- `gradio` - Create interactive web interfaces for models
|
|
35
|
+
- `inference` - Run model predictions on data
|
|
36
|
+
- `test` - Validate model performance and accuracy
|
|
37
|
+
- `train` - Train ML models with custom datasets
|
|
38
|
+
- `tune` - Hyperparameter optimization and model tuning
|
|
39
|
+
|
|
40
|
+
**Use Cases:**
|
|
41
|
+
- Training computer vision models
|
|
42
|
+
- Deploying models as web services
|
|
43
|
+
- Running batch inference on datasets
|
|
44
|
+
- Creating interactive model demos
|
|
45
|
+
|
|
46
|
+
### 2. Export (`export`)
|
|
47
|
+
|
|
48
|
+
Data export and transformation operations.
|
|
49
|
+
|
|
50
|
+
**Available Actions:**
|
|
51
|
+
- `export` - Export data in various formats and destinations
|
|
52
|
+
|
|
53
|
+
**Use Cases:**
|
|
54
|
+
- Converting datasets to different formats
|
|
55
|
+
- Exporting processed data to cloud storage
|
|
56
|
+
- Creating data packages for distribution
|
|
57
|
+
|
|
58
|
+
### 3. Upload (`upload`)
|
|
59
|
+
|
|
60
|
+
File and data upload functionality with support for various storage backends.
|
|
61
|
+
|
|
62
|
+
**Available Actions:**
|
|
63
|
+
- `upload` - Upload files to storage providers
|
|
64
|
+
|
|
65
|
+
**Use Cases:**
|
|
66
|
+
- Uploading datasets to cloud storage
|
|
67
|
+
- Backing up processed data
|
|
68
|
+
- Sharing data between team members
|
|
69
|
+
|
|
70
|
+
### 4. Smart Tools (`smart_tool`)
|
|
71
|
+
|
|
72
|
+
Intelligent automation tools powered by AI.
|
|
73
|
+
|
|
74
|
+
**Available Actions:**
|
|
75
|
+
- `auto_label` - Automated data labeling and annotation
|
|
76
|
+
|
|
77
|
+
**Use Cases:**
|
|
78
|
+
- Pre-labeling datasets with AI models
|
|
79
|
+
- Quality assurance for manual annotations
|
|
80
|
+
- Accelerating annotation workflows
|
|
81
|
+
|
|
82
|
+
### 5. Pre-annotation (`pre_annotation`)
|
|
83
|
+
|
|
84
|
+
Data preparation and processing before annotation.
|
|
85
|
+
|
|
86
|
+
**Available Actions:**
|
|
87
|
+
- `pre_annotation` - Prepare data for annotation workflows
|
|
88
|
+
- `to_task` - Convert data to annotation tasks
|
|
89
|
+
|
|
90
|
+
**Use Cases:**
|
|
91
|
+
- Data preprocessing and filtering
|
|
92
|
+
- Creating annotation tasks from raw data
|
|
93
|
+
- Setting up annotation workflows
|
|
94
|
+
|
|
95
|
+
### 6. Post-annotation (`post_annotation`)
|
|
96
|
+
|
|
97
|
+
Data processing and validation after annotation.
|
|
98
|
+
|
|
99
|
+
**Available Actions:**
|
|
100
|
+
- `post_annotation` - Process completed annotations
|
|
101
|
+
|
|
102
|
+
**Use Cases:**
|
|
103
|
+
- Validating annotation quality
|
|
104
|
+
- Post-processing annotated data
|
|
105
|
+
- Generating training datasets from annotations
|
|
106
|
+
|
|
107
|
+
### 7. Data Validation (`data_validation`)
|
|
108
|
+
|
|
109
|
+
Data quality checks and validation operations.
|
|
110
|
+
|
|
111
|
+
**Available Actions:**
|
|
112
|
+
- `validation` - Perform data quality and integrity checks
|
|
113
|
+
|
|
114
|
+
**Use Cases:**
|
|
115
|
+
- Validating dataset integrity
|
|
116
|
+
- Checking annotation consistency
|
|
117
|
+
- Quality assurance workflows
|
|
118
|
+
|
|
119
|
+
## Execution Methods
|
|
120
|
+
|
|
121
|
+
Plugins support three different execution methods depending on the use case:
|
|
122
|
+
|
|
123
|
+
### Job Execution
|
|
124
|
+
|
|
125
|
+
**Job-based execution** for long-running, distributed processing tasks.
|
|
126
|
+
|
|
127
|
+
- Best for: Training models, processing large datasets
|
|
128
|
+
- Features: Distributed execution, resource management, fault tolerance
|
|
129
|
+
- Monitoring: Full job lifecycle tracking and logging
|
|
130
|
+
|
|
131
|
+
### Task Execution
|
|
132
|
+
|
|
133
|
+
**Task-based execution** for simple, short-running operations.
|
|
134
|
+
|
|
135
|
+
- Best for: Quick data processing, validation checks
|
|
136
|
+
- Features: Lightweight execution, fast startup
|
|
137
|
+
- Monitoring: Basic progress tracking
|
|
138
|
+
|
|
139
|
+
### REST API Execution
|
|
140
|
+
|
|
141
|
+
**Serve-based execution** for web API endpoints.
|
|
142
|
+
|
|
143
|
+
- Best for: Real-time inference, interactive applications
|
|
144
|
+
- Features: HTTP endpoints, auto-scaling, load balancing
|
|
145
|
+
- Monitoring: Request/response logging, performance metrics
|
|
146
|
+
|
|
147
|
+
## Plugin Architecture
|
|
148
|
+
|
|
149
|
+
### Core Components
|
|
150
|
+
|
|
151
|
+
#### Plugin Models
|
|
152
|
+
|
|
153
|
+
**PluginRelease Class** (`synapse_sdk/plugins/models.py:14`)
|
|
154
|
+
- Manages plugin metadata and configuration
|
|
155
|
+
- Handles versioning and checksums
|
|
156
|
+
- Provides runtime environment setup
|
|
157
|
+
|
|
158
|
+
**Run Class** (`synapse_sdk/plugins/models.py:98`)
|
|
159
|
+
- Manages plugin execution instances
|
|
160
|
+
- Provides logging and progress tracking
|
|
161
|
+
- Handles backend communication
|
|
162
|
+
|
|
163
|
+
#### Action Base Class
|
|
164
|
+
|
|
165
|
+
**Action Class** (`synapse_sdk/plugins/categories/base.py:19`)
|
|
166
|
+
- Unified interface for all plugin actions
|
|
167
|
+
- Parameter validation with Pydantic models
|
|
168
|
+
- Built-in logging and error handling
|
|
169
|
+
- Runtime environment management
|
|
170
|
+
|
|
171
|
+
#### Template System
|
|
172
|
+
|
|
173
|
+
**Cookiecutter Templates** (`synapse_sdk/plugins/templates/`)
|
|
174
|
+
- Standardized plugin scaffolding
|
|
175
|
+
- Category-specific templates
|
|
176
|
+
- Automated project setup with proper structure
|
|
177
|
+
|
|
178
|
+
### Plugin Structure
|
|
179
|
+
|
|
180
|
+
Each plugin follows a standardized structure:
|
|
181
|
+
|
|
182
|
+
```
|
|
183
|
+
synapse-{plugin-code}-plugin/
|
|
184
|
+
├── config.yaml # Plugin metadata and configuration
|
|
185
|
+
├── plugin/ # Source code directory
|
|
186
|
+
│ ├── __init__.py
|
|
187
|
+
│ ├── {action1}.py # Action implementations
|
|
188
|
+
│ └── {action2}.py
|
|
189
|
+
├── requirements.txt # Python dependencies
|
|
190
|
+
├── pyproject.toml # Package configuration
|
|
191
|
+
└── README.md # Plugin documentation
|
|
192
|
+
```
|
|
193
|
+
|
|
194
|
+
### Configuration File (`config.yaml`)
|
|
195
|
+
|
|
196
|
+
```yaml
|
|
197
|
+
# Plugin metadata
|
|
198
|
+
code: "my-plugin"
|
|
199
|
+
name: "My Custom Plugin"
|
|
200
|
+
version: "1.0.0"
|
|
201
|
+
category: "neural_net"
|
|
202
|
+
description: "A custom ML plugin"
|
|
203
|
+
|
|
204
|
+
# Package management
|
|
205
|
+
package_manager: "pip" # or "uv"
|
|
206
|
+
|
|
207
|
+
# Action definitions
|
|
208
|
+
actions:
|
|
209
|
+
train:
|
|
210
|
+
entrypoint: "plugin.train.TrainAction"
|
|
211
|
+
method: "job"
|
|
212
|
+
inference:
|
|
213
|
+
entrypoint: "plugin.inference.InferenceAction"
|
|
214
|
+
method: "restapi"
|
|
215
|
+
```
|
|
216
|
+
|
|
217
|
+
## Creating Plugins
|
|
218
|
+
|
|
219
|
+
### 1. Generate Plugin Template
|
|
220
|
+
|
|
221
|
+
Use the CLI to create a new plugin from templates:
|
|
222
|
+
|
|
223
|
+
```bash
|
|
224
|
+
synapse plugin create
|
|
225
|
+
```
|
|
226
|
+
|
|
227
|
+
This will prompt for:
|
|
228
|
+
- Plugin code (unique identifier)
|
|
229
|
+
- Plugin name and description
|
|
230
|
+
- Category selection
|
|
231
|
+
- Required actions
|
|
232
|
+
|
|
233
|
+
### 2. Implement Actions
|
|
234
|
+
|
|
235
|
+
Each action inherits from the base `Action` class:
|
|
236
|
+
|
|
237
|
+
```python
|
|
238
|
+
# plugin/train.py
|
|
239
|
+
from synapse_sdk.plugins.categories.neural_net import TrainAction as BaseTrainAction
|
|
240
|
+
from pydantic import BaseModel
|
|
241
|
+
|
|
242
|
+
class TrainParams(BaseModel):
|
|
243
|
+
dataset_path: str
|
|
244
|
+
epochs: int = 10
|
|
245
|
+
learning_rate: float = 0.001
|
|
246
|
+
|
|
247
|
+
class TrainAction(BaseTrainAction):
|
|
248
|
+
name = "train"
|
|
249
|
+
params_model = TrainParams
|
|
250
|
+
|
|
251
|
+
def start(self):
|
|
252
|
+
# Access validated parameters
|
|
253
|
+
dataset_path = self.params['dataset_path']
|
|
254
|
+
epochs = self.params['epochs']
|
|
255
|
+
|
|
256
|
+
# Log progress
|
|
257
|
+
self.run.log_message("Starting training...")
|
|
258
|
+
|
|
259
|
+
# Your training logic here
|
|
260
|
+
for epoch in range(epochs):
|
|
261
|
+
# Update progress
|
|
262
|
+
self.run.set_progress(epoch + 1, epochs, "training")
|
|
263
|
+
|
|
264
|
+
# Training step
|
|
265
|
+
loss = train_epoch(dataset_path)
|
|
266
|
+
|
|
267
|
+
# Log metrics
|
|
268
|
+
self.run.set_metrics({"loss": loss}, "training")
|
|
269
|
+
|
|
270
|
+
self.run.log_message("Training completed!")
|
|
271
|
+
return {"status": "success", "final_loss": loss}
|
|
272
|
+
```
|
|
273
|
+
|
|
274
|
+
### 3. Configure Actions
|
|
275
|
+
|
|
276
|
+
Define actions in `config.yaml`:
|
|
277
|
+
|
|
278
|
+
```yaml
|
|
279
|
+
actions:
|
|
280
|
+
train:
|
|
281
|
+
entrypoint: "plugin.train.TrainAction"
|
|
282
|
+
method: "job"
|
|
283
|
+
description: "Train a neural network model"
|
|
284
|
+
```
|
|
285
|
+
|
|
286
|
+
### 4. Package and Publish
|
|
287
|
+
|
|
288
|
+
```bash
|
|
289
|
+
# Test locally
|
|
290
|
+
synapse plugin run train --debug
|
|
291
|
+
|
|
292
|
+
# Package for distribution
|
|
293
|
+
synapse plugin publish
|
|
294
|
+
```
|
|
295
|
+
|
|
296
|
+
## Running Plugins
|
|
297
|
+
|
|
298
|
+
### Command Line Interface
|
|
299
|
+
|
|
300
|
+
```bash
|
|
301
|
+
# Run a plugin action
|
|
302
|
+
synapse plugin run {action} {params}
|
|
303
|
+
|
|
304
|
+
# With specific plugin
|
|
305
|
+
synapse plugin run train '{"dataset_path": "/data/images", "epochs": 20}' --plugin my-plugin@1.0.0
|
|
306
|
+
|
|
307
|
+
# Debug mode (use local code)
|
|
308
|
+
synapse plugin run train '{"dataset_path": "/data/images"}' --debug
|
|
309
|
+
|
|
310
|
+
# Background job
|
|
311
|
+
synapse plugin run train '{"dataset_path": "/data/images"}' --job-id my-training-job
|
|
312
|
+
```
|
|
313
|
+
|
|
314
|
+
### Programmatic Usage
|
|
315
|
+
|
|
316
|
+
```python
|
|
317
|
+
from synapse_sdk.plugins.utils import get_action_class
|
|
318
|
+
|
|
319
|
+
# Get action class by category and name
|
|
320
|
+
ActionClass = get_action_class("neural_net", "train")
|
|
321
|
+
|
|
322
|
+
# Create and run action
|
|
323
|
+
action = ActionClass(
|
|
324
|
+
params={"dataset_path": "/data/images", "epochs": 10},
|
|
325
|
+
plugin_config=plugin_config,
|
|
326
|
+
envs=env_vars
|
|
327
|
+
)
|
|
328
|
+
|
|
329
|
+
result = action.run_action()
|
|
330
|
+
```
|
|
331
|
+
|
|
332
|
+
## Development Workflow
|
|
333
|
+
|
|
334
|
+
### 1. Local Development
|
|
335
|
+
|
|
336
|
+
```bash
|
|
337
|
+
# Create plugin
|
|
338
|
+
synapse plugin create
|
|
339
|
+
|
|
340
|
+
# Develop and test locally
|
|
341
|
+
cd synapse-my-plugin-plugin
|
|
342
|
+
synapse plugin run action-name --debug
|
|
343
|
+
|
|
344
|
+
# Use development server for REST APIs
|
|
345
|
+
synapse plugin run serve --debug
|
|
346
|
+
```
|
|
347
|
+
|
|
348
|
+
### 2. Testing
|
|
349
|
+
|
|
350
|
+
```bash
|
|
351
|
+
# Run plugin tests
|
|
352
|
+
pytest plugin/test_*.py
|
|
353
|
+
|
|
354
|
+
# Integration testing with distributed computing
|
|
355
|
+
synapse plugin run action-name --debug --job-id test-job
|
|
356
|
+
```
|
|
357
|
+
|
|
358
|
+
### 3. Deployment
|
|
359
|
+
|
|
360
|
+
```bash
|
|
361
|
+
# Package plugin
|
|
362
|
+
synapse plugin publish
|
|
363
|
+
|
|
364
|
+
# Deploy to cluster
|
|
365
|
+
synapse plugin run action-name --job-id production-job
|
|
366
|
+
```
|
|
367
|
+
|
|
368
|
+
## Advanced Features
|
|
369
|
+
|
|
370
|
+
### Custom Progress Categories
|
|
371
|
+
|
|
372
|
+
```python
|
|
373
|
+
class MyAction(Action):
|
|
374
|
+
progress_categories = {
|
|
375
|
+
"preprocessing": "Data preprocessing",
|
|
376
|
+
"training": "Model training",
|
|
377
|
+
"validation": "Model validation"
|
|
378
|
+
}
|
|
379
|
+
|
|
380
|
+
def start(self):
|
|
381
|
+
# Update different progress categories
|
|
382
|
+
self.run.set_progress(50, 100, "preprocessing")
|
|
383
|
+
self.run.set_progress(10, 50, "training")
|
|
384
|
+
```
|
|
385
|
+
|
|
386
|
+
### Custom Metrics
|
|
387
|
+
|
|
388
|
+
```python
|
|
389
|
+
def start(self):
|
|
390
|
+
# Log custom metrics
|
|
391
|
+
self.run.set_metrics({
|
|
392
|
+
"accuracy": 0.95,
|
|
393
|
+
"loss": 0.1,
|
|
394
|
+
"f1_score": 0.92
|
|
395
|
+
}, "validation")
|
|
396
|
+
```
|
|
397
|
+
|
|
398
|
+
### Runtime Environment Customization
|
|
399
|
+
|
|
400
|
+
```python
|
|
401
|
+
def get_runtime_env(self):
|
|
402
|
+
env = super().get_runtime_env()
|
|
403
|
+
|
|
404
|
+
# Add custom environment variables
|
|
405
|
+
env['env_vars']['CUSTOM_VAR'] = 'value'
|
|
406
|
+
|
|
407
|
+
# Add additional packages
|
|
408
|
+
env['pip']['packages'].append('custom-package==1.0.0')
|
|
409
|
+
|
|
410
|
+
return env
|
|
411
|
+
```
|
|
412
|
+
|
|
413
|
+
### Parameter Validation
|
|
414
|
+
|
|
415
|
+
```python
|
|
416
|
+
from pydantic import BaseModel, validator
|
|
417
|
+
from typing import Literal
|
|
418
|
+
|
|
419
|
+
class TrainParams(BaseModel):
|
|
420
|
+
model_type: Literal["cnn", "transformer", "resnet"]
|
|
421
|
+
dataset_path: str
|
|
422
|
+
batch_size: int = 32
|
|
423
|
+
|
|
424
|
+
@validator('batch_size')
|
|
425
|
+
def validate_batch_size(cls, v):
|
|
426
|
+
if v <= 0 or v > 512:
|
|
427
|
+
raise ValueError('Batch size must be between 1 and 512')
|
|
428
|
+
return v
|
|
429
|
+
```
|
|
430
|
+
|
|
431
|
+
## Best Practices
|
|
432
|
+
|
|
433
|
+
### 1. Plugin Design
|
|
434
|
+
|
|
435
|
+
- **Single Responsibility**: Each action should have a clear, focused purpose
|
|
436
|
+
- **Parameterization**: Make actions configurable through parameters
|
|
437
|
+
- **Error Handling**: Implement robust error handling and validation
|
|
438
|
+
- **Documentation**: Provide clear documentation and examples
|
|
439
|
+
|
|
440
|
+
### 2. Performance
|
|
441
|
+
|
|
442
|
+
- **Resource Management**: Use appropriate resource allocation for jobs
|
|
443
|
+
- **Progress Tracking**: Provide meaningful progress updates for long operations
|
|
444
|
+
- **Logging**: Log important events and errors for debugging
|
|
445
|
+
- **Memory Management**: Handle large datasets efficiently
|
|
446
|
+
|
|
447
|
+
### 3. Testing
|
|
448
|
+
|
|
449
|
+
- **Unit Tests**: Test individual action logic
|
|
450
|
+
- **Integration Tests**: Test with distributed execution environment
|
|
451
|
+
- **Parameter Validation**: Test edge cases and error conditions
|
|
452
|
+
- **Performance Tests**: Validate execution time and resource usage
|
|
453
|
+
|
|
454
|
+
### 4. Security
|
|
455
|
+
|
|
456
|
+
- **Input Validation**: Validate all parameters and inputs
|
|
457
|
+
- **File Access**: Restrict file system access appropriately
|
|
458
|
+
- **Dependencies**: Keep dependencies updated and secure
|
|
459
|
+
- **Secrets**: Never log sensitive information
|
|
460
|
+
|
|
461
|
+
## Monitoring and Debugging
|
|
462
|
+
|
|
463
|
+
### Plugin Execution Logs
|
|
464
|
+
|
|
465
|
+
```python
|
|
466
|
+
# In your action
|
|
467
|
+
self.run.log_message("Processing started", "INFO")
|
|
468
|
+
self.run.log_message("Warning: low memory", "WARNING")
|
|
469
|
+
self.run.log_message("Error occurred", "ERROR")
|
|
470
|
+
|
|
471
|
+
# With structured data
|
|
472
|
+
self.run.log("model_checkpoint", {
|
|
473
|
+
"epoch": 10,
|
|
474
|
+
"accuracy": 0.95,
|
|
475
|
+
"checkpoint_path": "/models/checkpoint_10.pth"
|
|
476
|
+
})
|
|
477
|
+
```
|
|
478
|
+
|
|
479
|
+
### Progress Monitoring
|
|
480
|
+
|
|
481
|
+
```python
|
|
482
|
+
# Simple progress
|
|
483
|
+
self.run.set_progress(current=50, total=100)
|
|
484
|
+
|
|
485
|
+
# Categorized progress
|
|
486
|
+
self.run.set_progress(current=30, total=100, category="training")
|
|
487
|
+
self.run.set_progress(current=20, total=50, category="validation")
|
|
488
|
+
```
|
|
489
|
+
|
|
490
|
+
### Metrics Collection
|
|
491
|
+
|
|
492
|
+
```python
|
|
493
|
+
# Training metrics
|
|
494
|
+
self.run.set_metrics({
|
|
495
|
+
"epoch": 10,
|
|
496
|
+
"train_loss": 0.1,
|
|
497
|
+
"train_accuracy": 0.95,
|
|
498
|
+
"learning_rate": 0.001
|
|
499
|
+
}, "training")
|
|
500
|
+
|
|
501
|
+
# Performance metrics
|
|
502
|
+
self.run.set_metrics({
|
|
503
|
+
"inference_time": 0.05,
|
|
504
|
+
"throughput": 200,
|
|
505
|
+
"memory_usage": 1024
|
|
506
|
+
}, "performance")
|
|
507
|
+
```
|
|
508
|
+
|
|
509
|
+
The plugin system provides a powerful foundation for building scalable, distributed ML workflows. By following the established patterns and best practices, you can create robust plugins that integrate seamlessly with the Synapse ecosystem.
|
|
@@ -0,0 +1,94 @@
|
|
|
1
|
+
---
|
|
2
|
+
id: installation
|
|
3
|
+
title: Installation & Setup
|
|
4
|
+
sidebar_position: 2
|
|
5
|
+
---
|
|
6
|
+
|
|
7
|
+
# Installation & Setup
|
|
8
|
+
|
|
9
|
+
Get started with Synapse SDK in minutes.
|
|
10
|
+
|
|
11
|
+
## Prerequisites
|
|
12
|
+
|
|
13
|
+
Before installing Synapse SDK, ensure you have:
|
|
14
|
+
|
|
15
|
+
- **Python 3.10 or higher** installed
|
|
16
|
+
|
|
17
|
+
## Installation Methods
|
|
18
|
+
|
|
19
|
+
### Install from PyPI
|
|
20
|
+
|
|
21
|
+
The easiest way to install Synapse SDK is via pip:
|
|
22
|
+
|
|
23
|
+
```bash
|
|
24
|
+
pip install synapse-sdk
|
|
25
|
+
```
|
|
26
|
+
|
|
27
|
+
### Install with Optional Dependencies
|
|
28
|
+
|
|
29
|
+
For additional features, install with extras:
|
|
30
|
+
|
|
31
|
+
```bash
|
|
32
|
+
# Install with all dependencies (distributed computing, optimization libraries)
|
|
33
|
+
pip install synapse-sdk[all]
|
|
34
|
+
|
|
35
|
+
# Install with dashboard dependencies (FastAPI, Uvicorn)
|
|
36
|
+
pip install synapse-sdk[devtools]
|
|
37
|
+
|
|
38
|
+
# Install both
|
|
39
|
+
pip install "synapse-sdk[all,devtools]"
|
|
40
|
+
```
|
|
41
|
+
|
|
42
|
+
### Install from Source
|
|
43
|
+
|
|
44
|
+
To get the latest development version:
|
|
45
|
+
|
|
46
|
+
```bash
|
|
47
|
+
git clone https://github.com/datamaker/synapse-sdk.git
|
|
48
|
+
cd synapse-sdk
|
|
49
|
+
pip install -e .
|
|
50
|
+
|
|
51
|
+
# With optional dependencies
|
|
52
|
+
pip install -e ".[all,devtools]"
|
|
53
|
+
```
|
|
54
|
+
|
|
55
|
+
## Verify Installation
|
|
56
|
+
|
|
57
|
+
After installation, verify everything is working:
|
|
58
|
+
|
|
59
|
+
```bash
|
|
60
|
+
# Check version
|
|
61
|
+
synapse --version
|
|
62
|
+
|
|
63
|
+
# Run interactive CLI
|
|
64
|
+
synapse
|
|
65
|
+
|
|
66
|
+
# Run with devtools
|
|
67
|
+
synapse --dev-tools
|
|
68
|
+
```
|
|
69
|
+
|
|
70
|
+
## Troubleshooting
|
|
71
|
+
|
|
72
|
+
### Common Issues
|
|
73
|
+
|
|
74
|
+
1. **ImportError: No module named 'synapse_sdk'**
|
|
75
|
+
- Ensure you've activated your virtual environment
|
|
76
|
+
- Check Python path: `python -c "import sys; print(sys.path)"`
|
|
77
|
+
|
|
78
|
+
2. **Connection timeout to backend**
|
|
79
|
+
- Verify your API token is correct
|
|
80
|
+
- Check network connectivity
|
|
81
|
+
- Ensure backend URL is accessible
|
|
82
|
+
|
|
83
|
+
### Getting Help
|
|
84
|
+
|
|
85
|
+
If you encounter issues:
|
|
86
|
+
|
|
87
|
+
1. Check the [Troubleshooting Guide](./troubleshooting.md)
|
|
88
|
+
2. Search [GitHub Issues](https://github.com/datamaker/synapse-sdk/issues)
|
|
89
|
+
3. Join our [Discord Community](https://discord.gg/synapse-sdk)
|
|
90
|
+
|
|
91
|
+
## Next Steps
|
|
92
|
+
|
|
93
|
+
- Follow the [Quickstart Guide](./quickstart.md)
|
|
94
|
+
- Learn about [Core Concepts](./concepts/index.md)
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
---
|
|
2
|
+
id: introduction
|
|
3
|
+
title: Introduction
|
|
4
|
+
sidebar_position: 1
|
|
5
|
+
---
|
|
6
|
+
|
|
7
|
+
# Synapse SDK
|
|
8
|
+
|
|
9
|
+
Build ML and data processing plugins.
|
|
10
|
+
|
|
11
|
+
## Overview
|
|
12
|
+
|
|
13
|
+
Synapse SDK is..
|
|
14
|
+
|
|
15
|
+
### Key Features
|
|
16
|
+
|
|
17
|
+
- **🚀 Plugin Development and Testing**: Develop modular, reusable components organized by categories for Synapse
|
|
18
|
+
- **⚡ Distributed Computing**: Built for scalable, distributed execution
|
|
19
|
+
- **🔧 Multiple Execution Modes**: Support for Jobs, Tasks, and REST APIs
|
|
20
|
+
- **📦 Isolated Runtime Environments**: Each plugin runs in its own environment with dependency management
|
|
21
|
+
- **📊 Progress Tracking**: Built-in progress monitoring and metrics reporting
|
|
22
|
+
|
|
23
|
+
### Plugin Categories
|
|
24
|
+
|
|
25
|
+
The SDK organizes plugins into specific categories:
|
|
26
|
+
|
|
27
|
+
1. **Neural Network** (`NEURAL_NET`): ML model training, inference, and deployment
|
|
28
|
+
2. **Export** (`EXPORT`): Data export and transformation operations
|
|
29
|
+
3. **Upload** (`UPLOAD`): File and data upload functionality
|
|
30
|
+
4. **Smart Tools** (`SMART_TOOL`): Intelligent automation tools
|
|
31
|
+
5. **Post-Annotation** (`POST_ANNOTATION`): Post-processing after data annotation
|
|
32
|
+
6. **Pre-Annotation** (`PRE_ANNOTATION`): Pre-processing before data annotation
|
|
33
|
+
7. **Data Validation** (`DATA_VALIDATION`): Data quality and validation checks
|
|
34
|
+
|
|
35
|
+
## Getting Started
|
|
36
|
+
|
|
37
|
+
To get started with the Synapse SDK:
|
|
38
|
+
|
|
39
|
+
1. [Install the SDK](./installation.md)
|
|
40
|
+
2. [Follow the Quickstart Guide](./quickstart.md)
|
|
41
|
+
3. [Explore the API Reference](./api/index.md)
|
|
42
|
+
4. [Check out Examples](./examples/index.md)
|
|
43
|
+
|
|
44
|
+
## Next Steps
|
|
45
|
+
|
|
46
|
+
- Learn about [Core Concepts](./concepts/index.md)
|
|
47
|
+
- Configure [Backend Connection](./configuration.md)
|