synapse-sdk 1.0.0a11__py3-none-any.whl → 2026.1.1b2__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/__init__.py +24 -0
- synapse_sdk/cli/__init__.py +9 -8
- synapse_sdk/cli/agent/__init__.py +25 -0
- synapse_sdk/cli/agent/config.py +104 -0
- synapse_sdk/cli/agent/select.py +197 -0
- synapse_sdk/cli/auth.py +104 -0
- synapse_sdk/cli/main.py +1025 -0
- synapse_sdk/cli/plugin/__init__.py +58 -0
- synapse_sdk/cli/plugin/create.py +566 -0
- synapse_sdk/cli/plugin/job.py +196 -0
- synapse_sdk/cli/plugin/publish.py +322 -0
- synapse_sdk/cli/plugin/run.py +131 -0
- synapse_sdk/cli/plugin/test.py +200 -0
- synapse_sdk/clients/README.md +239 -0
- synapse_sdk/clients/__init__.py +5 -0
- synapse_sdk/clients/_template.py +266 -0
- synapse_sdk/clients/agent/__init__.py +84 -29
- synapse_sdk/clients/agent/async_ray.py +289 -0
- synapse_sdk/clients/agent/container.py +83 -0
- synapse_sdk/clients/agent/plugin.py +101 -0
- synapse_sdk/clients/agent/ray.py +296 -39
- synapse_sdk/clients/backend/__init__.py +152 -12
- synapse_sdk/clients/backend/annotation.py +164 -22
- synapse_sdk/clients/backend/core.py +101 -0
- synapse_sdk/clients/backend/data_collection.py +292 -0
- synapse_sdk/clients/backend/hitl.py +87 -0
- synapse_sdk/clients/backend/integration.py +374 -46
- synapse_sdk/clients/backend/ml.py +134 -22
- synapse_sdk/clients/backend/models.py +247 -0
- synapse_sdk/clients/base.py +538 -59
- synapse_sdk/clients/exceptions.py +35 -7
- synapse_sdk/clients/pipeline/__init__.py +5 -0
- synapse_sdk/clients/pipeline/client.py +636 -0
- synapse_sdk/clients/protocols.py +178 -0
- synapse_sdk/clients/utils.py +86 -8
- synapse_sdk/clients/validation.py +58 -0
- synapse_sdk/enums.py +76 -0
- synapse_sdk/exceptions.py +168 -0
- synapse_sdk/integrations/__init__.py +74 -0
- synapse_sdk/integrations/_base.py +119 -0
- synapse_sdk/integrations/_context.py +53 -0
- synapse_sdk/integrations/ultralytics/__init__.py +78 -0
- synapse_sdk/integrations/ultralytics/_callbacks.py +126 -0
- synapse_sdk/integrations/ultralytics/_patches.py +124 -0
- synapse_sdk/loggers.py +476 -95
- synapse_sdk/mcp/MCP.md +69 -0
- synapse_sdk/mcp/__init__.py +48 -0
- synapse_sdk/mcp/__main__.py +6 -0
- synapse_sdk/mcp/config.py +349 -0
- synapse_sdk/mcp/prompts/__init__.py +4 -0
- synapse_sdk/mcp/resources/__init__.py +4 -0
- synapse_sdk/mcp/server.py +1352 -0
- synapse_sdk/mcp/tools/__init__.py +6 -0
- synapse_sdk/plugins/__init__.py +133 -9
- synapse_sdk/plugins/action.py +229 -0
- synapse_sdk/plugins/actions/__init__.py +82 -0
- synapse_sdk/plugins/actions/dataset/__init__.py +37 -0
- synapse_sdk/plugins/actions/dataset/action.py +471 -0
- synapse_sdk/plugins/actions/export/__init__.py +55 -0
- synapse_sdk/plugins/actions/export/action.py +183 -0
- synapse_sdk/plugins/actions/export/context.py +59 -0
- synapse_sdk/plugins/actions/inference/__init__.py +84 -0
- synapse_sdk/plugins/actions/inference/action.py +285 -0
- synapse_sdk/plugins/actions/inference/context.py +81 -0
- synapse_sdk/plugins/actions/inference/deployment.py +322 -0
- synapse_sdk/plugins/actions/inference/serve.py +252 -0
- synapse_sdk/plugins/actions/train/__init__.py +54 -0
- synapse_sdk/plugins/actions/train/action.py +326 -0
- synapse_sdk/plugins/actions/train/context.py +57 -0
- synapse_sdk/plugins/actions/upload/__init__.py +49 -0
- synapse_sdk/plugins/actions/upload/action.py +165 -0
- synapse_sdk/plugins/actions/upload/context.py +61 -0
- synapse_sdk/plugins/config.py +98 -0
- synapse_sdk/plugins/context/__init__.py +109 -0
- synapse_sdk/plugins/context/env.py +113 -0
- synapse_sdk/plugins/datasets/__init__.py +113 -0
- synapse_sdk/plugins/datasets/converters/__init__.py +76 -0
- synapse_sdk/plugins/datasets/converters/base.py +347 -0
- synapse_sdk/plugins/datasets/converters/yolo/__init__.py +9 -0
- synapse_sdk/plugins/datasets/converters/yolo/from_dm.py +468 -0
- synapse_sdk/plugins/datasets/converters/yolo/to_dm.py +381 -0
- synapse_sdk/plugins/datasets/formats/__init__.py +82 -0
- synapse_sdk/plugins/datasets/formats/dm.py +351 -0
- synapse_sdk/plugins/datasets/formats/yolo.py +240 -0
- synapse_sdk/plugins/decorators.py +83 -0
- synapse_sdk/plugins/discovery.py +790 -0
- synapse_sdk/plugins/docs/ACTION_DEV_GUIDE.md +933 -0
- synapse_sdk/plugins/docs/ARCHITECTURE.md +1225 -0
- synapse_sdk/plugins/docs/LOGGING_SYSTEM.md +683 -0
- synapse_sdk/plugins/docs/OVERVIEW.md +531 -0
- synapse_sdk/plugins/docs/PIPELINE_GUIDE.md +145 -0
- synapse_sdk/plugins/docs/README.md +513 -0
- synapse_sdk/plugins/docs/STEP.md +656 -0
- synapse_sdk/plugins/enums.py +70 -10
- synapse_sdk/plugins/errors.py +92 -0
- synapse_sdk/plugins/executors/__init__.py +43 -0
- synapse_sdk/plugins/executors/local.py +99 -0
- synapse_sdk/plugins/executors/ray/__init__.py +18 -0
- synapse_sdk/plugins/executors/ray/base.py +282 -0
- synapse_sdk/plugins/executors/ray/job.py +298 -0
- synapse_sdk/plugins/executors/ray/jobs_api.py +511 -0
- synapse_sdk/plugins/executors/ray/packaging.py +137 -0
- synapse_sdk/plugins/executors/ray/pipeline.py +792 -0
- synapse_sdk/plugins/executors/ray/task.py +257 -0
- synapse_sdk/plugins/models/__init__.py +26 -0
- synapse_sdk/plugins/models/logger.py +173 -0
- synapse_sdk/plugins/models/pipeline.py +25 -0
- synapse_sdk/plugins/pipelines/__init__.py +81 -0
- synapse_sdk/plugins/pipelines/action_pipeline.py +417 -0
- synapse_sdk/plugins/pipelines/context.py +107 -0
- synapse_sdk/plugins/pipelines/display.py +311 -0
- synapse_sdk/plugins/runner.py +114 -0
- synapse_sdk/plugins/schemas/__init__.py +19 -0
- synapse_sdk/plugins/schemas/results.py +152 -0
- synapse_sdk/plugins/steps/__init__.py +63 -0
- synapse_sdk/plugins/steps/base.py +128 -0
- synapse_sdk/plugins/steps/context.py +90 -0
- synapse_sdk/plugins/steps/orchestrator.py +128 -0
- synapse_sdk/plugins/steps/registry.py +103 -0
- synapse_sdk/plugins/steps/utils/__init__.py +20 -0
- synapse_sdk/plugins/steps/utils/logging.py +85 -0
- synapse_sdk/plugins/steps/utils/timing.py +71 -0
- synapse_sdk/plugins/steps/utils/validation.py +68 -0
- synapse_sdk/plugins/templates/__init__.py +50 -0
- synapse_sdk/plugins/templates/base/.gitignore.j2 +26 -0
- synapse_sdk/plugins/templates/base/.synapseignore.j2 +11 -0
- synapse_sdk/plugins/templates/base/README.md.j2 +26 -0
- synapse_sdk/plugins/templates/base/plugin/__init__.py.j2 +1 -0
- synapse_sdk/plugins/templates/base/pyproject.toml.j2 +14 -0
- synapse_sdk/plugins/templates/base/requirements.txt.j2 +1 -0
- synapse_sdk/plugins/templates/custom/plugin/main.py.j2 +18 -0
- synapse_sdk/plugins/templates/data_validation/plugin/validate.py.j2 +32 -0
- synapse_sdk/plugins/templates/export/plugin/export.py.j2 +36 -0
- synapse_sdk/plugins/templates/neural_net/plugin/inference.py.j2 +36 -0
- synapse_sdk/plugins/templates/neural_net/plugin/train.py.j2 +33 -0
- synapse_sdk/plugins/templates/post_annotation/plugin/post_annotate.py.j2 +32 -0
- synapse_sdk/plugins/templates/pre_annotation/plugin/pre_annotate.py.j2 +32 -0
- synapse_sdk/plugins/templates/smart_tool/plugin/auto_label.py.j2 +44 -0
- synapse_sdk/plugins/templates/upload/plugin/upload.py.j2 +35 -0
- synapse_sdk/plugins/testing/__init__.py +25 -0
- synapse_sdk/plugins/testing/sample_actions.py +98 -0
- synapse_sdk/plugins/types.py +206 -0
- synapse_sdk/plugins/upload.py +595 -64
- synapse_sdk/plugins/utils.py +325 -37
- synapse_sdk/shared/__init__.py +25 -0
- synapse_sdk/utils/__init__.py +1 -0
- synapse_sdk/utils/auth.py +74 -0
- synapse_sdk/utils/file/__init__.py +58 -0
- synapse_sdk/utils/file/archive.py +449 -0
- synapse_sdk/utils/file/checksum.py +167 -0
- synapse_sdk/utils/file/download.py +286 -0
- synapse_sdk/utils/file/io.py +129 -0
- synapse_sdk/utils/file/requirements.py +36 -0
- synapse_sdk/utils/network.py +168 -0
- synapse_sdk/utils/storage/__init__.py +238 -0
- synapse_sdk/utils/storage/config.py +188 -0
- synapse_sdk/utils/storage/errors.py +52 -0
- synapse_sdk/utils/storage/providers/__init__.py +13 -0
- synapse_sdk/utils/storage/providers/base.py +76 -0
- synapse_sdk/utils/storage/providers/gcs.py +168 -0
- synapse_sdk/utils/storage/providers/http.py +250 -0
- synapse_sdk/utils/storage/providers/local.py +126 -0
- synapse_sdk/utils/storage/providers/s3.py +177 -0
- synapse_sdk/utils/storage/providers/sftp.py +208 -0
- synapse_sdk/utils/storage/registry.py +125 -0
- synapse_sdk/utils/websocket.py +99 -0
- synapse_sdk-2026.1.1b2.dist-info/METADATA +715 -0
- synapse_sdk-2026.1.1b2.dist-info/RECORD +172 -0
- {synapse_sdk-1.0.0a11.dist-info → synapse_sdk-2026.1.1b2.dist-info}/WHEEL +1 -1
- synapse_sdk-2026.1.1b2.dist-info/licenses/LICENSE +201 -0
- locale/en/LC_MESSAGES/messages.mo +0 -0
- locale/en/LC_MESSAGES/messages.po +0 -39
- locale/ko/LC_MESSAGES/messages.mo +0 -0
- locale/ko/LC_MESSAGES/messages.po +0 -34
- synapse_sdk/cli/create_plugin.py +0 -10
- synapse_sdk/clients/agent/core.py +0 -7
- synapse_sdk/clients/agent/service.py +0 -15
- synapse_sdk/clients/backend/dataset.py +0 -51
- synapse_sdk/clients/ray/__init__.py +0 -6
- synapse_sdk/clients/ray/core.py +0 -22
- synapse_sdk/clients/ray/serve.py +0 -20
- synapse_sdk/i18n.py +0 -35
- synapse_sdk/plugins/categories/__init__.py +0 -0
- synapse_sdk/plugins/categories/base.py +0 -235
- synapse_sdk/plugins/categories/data_validation/__init__.py +0 -0
- synapse_sdk/plugins/categories/data_validation/actions/__init__.py +0 -0
- synapse_sdk/plugins/categories/data_validation/actions/validation.py +0 -10
- synapse_sdk/plugins/categories/data_validation/templates/config.yaml +0 -3
- synapse_sdk/plugins/categories/data_validation/templates/plugin/__init__.py +0 -0
- synapse_sdk/plugins/categories/data_validation/templates/plugin/validation.py +0 -5
- synapse_sdk/plugins/categories/decorators.py +0 -13
- synapse_sdk/plugins/categories/export/__init__.py +0 -0
- synapse_sdk/plugins/categories/export/actions/__init__.py +0 -0
- synapse_sdk/plugins/categories/export/actions/export.py +0 -10
- synapse_sdk/plugins/categories/import/__init__.py +0 -0
- synapse_sdk/plugins/categories/import/actions/__init__.py +0 -0
- synapse_sdk/plugins/categories/import/actions/import.py +0 -10
- synapse_sdk/plugins/categories/neural_net/__init__.py +0 -0
- synapse_sdk/plugins/categories/neural_net/actions/__init__.py +0 -0
- synapse_sdk/plugins/categories/neural_net/actions/deployment.py +0 -45
- synapse_sdk/plugins/categories/neural_net/actions/inference.py +0 -18
- synapse_sdk/plugins/categories/neural_net/actions/test.py +0 -10
- synapse_sdk/plugins/categories/neural_net/actions/train.py +0 -143
- synapse_sdk/plugins/categories/neural_net/templates/config.yaml +0 -12
- synapse_sdk/plugins/categories/neural_net/templates/plugin/__init__.py +0 -0
- synapse_sdk/plugins/categories/neural_net/templates/plugin/inference.py +0 -4
- synapse_sdk/plugins/categories/neural_net/templates/plugin/test.py +0 -2
- synapse_sdk/plugins/categories/neural_net/templates/plugin/train.py +0 -14
- synapse_sdk/plugins/categories/post_annotation/__init__.py +0 -0
- synapse_sdk/plugins/categories/post_annotation/actions/__init__.py +0 -0
- synapse_sdk/plugins/categories/post_annotation/actions/post_annotation.py +0 -10
- synapse_sdk/plugins/categories/post_annotation/templates/config.yaml +0 -3
- synapse_sdk/plugins/categories/post_annotation/templates/plugin/__init__.py +0 -0
- synapse_sdk/plugins/categories/post_annotation/templates/plugin/post_annotation.py +0 -3
- synapse_sdk/plugins/categories/pre_annotation/__init__.py +0 -0
- synapse_sdk/plugins/categories/pre_annotation/actions/__init__.py +0 -0
- synapse_sdk/plugins/categories/pre_annotation/actions/pre_annotation.py +0 -10
- synapse_sdk/plugins/categories/pre_annotation/templates/config.yaml +0 -3
- synapse_sdk/plugins/categories/pre_annotation/templates/plugin/__init__.py +0 -0
- synapse_sdk/plugins/categories/pre_annotation/templates/plugin/pre_annotation.py +0 -3
- synapse_sdk/plugins/categories/registry.py +0 -16
- synapse_sdk/plugins/categories/smart_tool/__init__.py +0 -0
- synapse_sdk/plugins/categories/smart_tool/actions/__init__.py +0 -0
- synapse_sdk/plugins/categories/smart_tool/actions/auto_label.py +0 -37
- synapse_sdk/plugins/categories/smart_tool/templates/config.yaml +0 -7
- synapse_sdk/plugins/categories/smart_tool/templates/plugin/__init__.py +0 -0
- synapse_sdk/plugins/categories/smart_tool/templates/plugin/auto_label.py +0 -11
- synapse_sdk/plugins/categories/templates.py +0 -32
- synapse_sdk/plugins/cli/__init__.py +0 -21
- synapse_sdk/plugins/cli/publish.py +0 -37
- synapse_sdk/plugins/cli/run.py +0 -67
- synapse_sdk/plugins/exceptions.py +0 -22
- synapse_sdk/plugins/models.py +0 -121
- synapse_sdk/plugins/templates/cookiecutter.json +0 -11
- synapse_sdk/plugins/templates/hooks/post_gen_project.py +0 -3
- synapse_sdk/plugins/templates/hooks/pre_prompt.py +0 -21
- synapse_sdk/plugins/templates/synapse-{{cookiecutter.plugin_code}}-plugin/.env +0 -24
- synapse_sdk/plugins/templates/synapse-{{cookiecutter.plugin_code}}-plugin/.env.dist +0 -24
- synapse_sdk/plugins/templates/synapse-{{cookiecutter.plugin_code}}-plugin/.gitignore +0 -27
- synapse_sdk/plugins/templates/synapse-{{cookiecutter.plugin_code}}-plugin/.pre-commit-config.yaml +0 -7
- synapse_sdk/plugins/templates/synapse-{{cookiecutter.plugin_code}}-plugin/README.md +0 -5
- synapse_sdk/plugins/templates/synapse-{{cookiecutter.plugin_code}}-plugin/config.yaml +0 -6
- synapse_sdk/plugins/templates/synapse-{{cookiecutter.plugin_code}}-plugin/main.py +0 -4
- synapse_sdk/plugins/templates/synapse-{{cookiecutter.plugin_code}}-plugin/plugin/__init__.py +0 -0
- synapse_sdk/plugins/templates/synapse-{{cookiecutter.plugin_code}}-plugin/pyproject.toml +0 -13
- synapse_sdk/plugins/templates/synapse-{{cookiecutter.plugin_code}}-plugin/requirements.txt +0 -1
- synapse_sdk/shared/enums.py +0 -8
- synapse_sdk/utils/debug.py +0 -5
- synapse_sdk/utils/file.py +0 -87
- synapse_sdk/utils/module_loading.py +0 -29
- synapse_sdk/utils/pydantic/__init__.py +0 -0
- synapse_sdk/utils/pydantic/config.py +0 -4
- synapse_sdk/utils/pydantic/errors.py +0 -33
- synapse_sdk/utils/pydantic/validators.py +0 -7
- synapse_sdk/utils/storage.py +0 -91
- synapse_sdk/utils/string.py +0 -11
- synapse_sdk-1.0.0a11.dist-info/LICENSE +0 -21
- synapse_sdk-1.0.0a11.dist-info/METADATA +0 -43
- synapse_sdk-1.0.0a11.dist-info/RECORD +0 -111
- {synapse_sdk-1.0.0a11.dist-info → synapse_sdk-2026.1.1b2.dist-info}/entry_points.txt +0 -0
- {synapse_sdk-1.0.0a11.dist-info → synapse_sdk-2026.1.1b2.dist-info}/top_level.txt +0 -0
|
@@ -0,0 +1,715 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: synapse-sdk
|
|
3
|
+
Version: 2026.1.1b2
|
|
4
|
+
Summary: synapse sdk
|
|
5
|
+
Author-email: datamaker <developer@datamaker.io>
|
|
6
|
+
License: Apache License
|
|
7
|
+
Version 2.0, January 2004
|
|
8
|
+
http://www.apache.org/licenses/
|
|
9
|
+
|
|
10
|
+
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
|
|
11
|
+
|
|
12
|
+
1. Definitions.
|
|
13
|
+
|
|
14
|
+
"License" shall mean the terms and conditions for use, reproduction,
|
|
15
|
+
and distribution as defined by Sections 1 through 9 of this document.
|
|
16
|
+
|
|
17
|
+
"Licensor" shall mean the copyright owner or entity authorized by
|
|
18
|
+
the copyright owner that is granting the License.
|
|
19
|
+
|
|
20
|
+
"Legal Entity" shall mean the union of the acting entity and all
|
|
21
|
+
other entities that control, are controlled by, or are under common
|
|
22
|
+
control with that entity. For the purposes of this definition,
|
|
23
|
+
"control" means (i) the power, direct or indirect, to cause the
|
|
24
|
+
direction or management of such entity, whether by contract or
|
|
25
|
+
otherwise, or (ii) ownership of fifty percent (50%) or more of the
|
|
26
|
+
outstanding shares, or (iii) beneficial ownership of such entity.
|
|
27
|
+
|
|
28
|
+
"You" (or "Your") shall mean an individual or Legal Entity
|
|
29
|
+
exercising permissions granted by this License.
|
|
30
|
+
|
|
31
|
+
"Source" form shall mean the preferred form for making modifications,
|
|
32
|
+
including but not limited to software source code, documentation
|
|
33
|
+
source, and configuration files.
|
|
34
|
+
|
|
35
|
+
"Object" form shall mean any form resulting from mechanical
|
|
36
|
+
transformation or translation of a Source form, including but
|
|
37
|
+
not limited to compiled object code, generated documentation,
|
|
38
|
+
and conversions to other media types.
|
|
39
|
+
|
|
40
|
+
"Work" shall mean the work of authorship, whether in Source or
|
|
41
|
+
Object form, made available under the License, as indicated by a
|
|
42
|
+
copyright notice that is included in or attached to the work
|
|
43
|
+
(an example is provided in the Appendix below).
|
|
44
|
+
|
|
45
|
+
"Derivative Works" shall mean any work, whether in Source or Object
|
|
46
|
+
form, that is based on (or derived from) the Work and for which the
|
|
47
|
+
editorial revisions, annotations, elaborations, or other modifications
|
|
48
|
+
represent, as a whole, an original work of authorship. For the purposes
|
|
49
|
+
of this License, Derivative Works shall not include works that remain
|
|
50
|
+
separable from, or merely link (or bind by name) to the interfaces of,
|
|
51
|
+
the Work and Derivative Works thereof.
|
|
52
|
+
|
|
53
|
+
"Contribution" shall mean any work of authorship, including
|
|
54
|
+
the original version of the Work and any modifications or additions
|
|
55
|
+
to that Work or Derivative Works thereof, that is intentionally
|
|
56
|
+
submitted to Licensor for inclusion in the Work by the copyright owner
|
|
57
|
+
or by an individual or Legal Entity authorized to submit on behalf of
|
|
58
|
+
the copyright owner. For the purposes of this definition, "submitted"
|
|
59
|
+
means any form of electronic, verbal, or written communication sent
|
|
60
|
+
to the Licensor or its representatives, including but not limited to
|
|
61
|
+
communication on electronic mailing lists, source code control systems,
|
|
62
|
+
and issue tracking systems that are managed by, or on behalf of, the
|
|
63
|
+
Licensor for the purpose of discussing and improving the Work, but
|
|
64
|
+
excluding communication that is conspicuously marked or otherwise
|
|
65
|
+
designated in writing by the copyright owner as "Not a Contribution."
|
|
66
|
+
|
|
67
|
+
"Contributor" shall mean Licensor and any individual or Legal Entity
|
|
68
|
+
on behalf of whom a Contribution has been received by Licensor and
|
|
69
|
+
subsequently incorporated within the Work.
|
|
70
|
+
|
|
71
|
+
2. Grant of Copyright License. Subject to the terms and conditions of
|
|
72
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
73
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
74
|
+
copyright license to reproduce, prepare Derivative Works of,
|
|
75
|
+
publicly display, publicly perform, sublicense, and distribute the
|
|
76
|
+
Work and such Derivative Works in Source or Object form.
|
|
77
|
+
|
|
78
|
+
3. Grant of Patent License. Subject to the terms and conditions of
|
|
79
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
80
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
81
|
+
(except as stated in this section) patent license to make, have made,
|
|
82
|
+
use, offer to sell, sell, import, and otherwise transfer the Work,
|
|
83
|
+
where such license applies only to those patent claims licensable
|
|
84
|
+
by such Contributor that are necessarily infringed by their
|
|
85
|
+
Contribution(s) alone or by combination of their Contribution(s)
|
|
86
|
+
with the Work to which such Contribution(s) was submitted. If You
|
|
87
|
+
institute patent litigation against any entity (including a
|
|
88
|
+
cross-claim or counterclaim in a lawsuit) alleging that the Work
|
|
89
|
+
or a Contribution incorporated within the Work constitutes direct
|
|
90
|
+
or contributory patent infringement, then any patent licenses
|
|
91
|
+
granted to You under this License for that Work shall terminate
|
|
92
|
+
as of the date such litigation is filed.
|
|
93
|
+
|
|
94
|
+
4. Redistribution. You may reproduce and distribute copies of the
|
|
95
|
+
Work or Derivative Works thereof in any medium, with or without
|
|
96
|
+
modifications, and in Source or Object form, provided that You
|
|
97
|
+
meet the following conditions:
|
|
98
|
+
|
|
99
|
+
(a) You must give any other recipients of the Work or
|
|
100
|
+
Derivative Works a copy of this License; and
|
|
101
|
+
|
|
102
|
+
(b) You must cause any modified files to carry prominent notices
|
|
103
|
+
stating that You changed the files; and
|
|
104
|
+
|
|
105
|
+
(c) You must retain, in the Source form of any Derivative Works
|
|
106
|
+
that You distribute, all copyright, patent, trademark, and
|
|
107
|
+
attribution notices from the Source form of the Work,
|
|
108
|
+
excluding those notices that do not pertain to any part of
|
|
109
|
+
the Derivative Works; and
|
|
110
|
+
|
|
111
|
+
(d) If the Work includes a "NOTICE" text file as part of its
|
|
112
|
+
distribution, then any Derivative Works that You distribute must
|
|
113
|
+
include a readable copy of the attribution notices contained
|
|
114
|
+
within such NOTICE file, excluding those notices that do not
|
|
115
|
+
pertain to any part of the Derivative Works, in at least one
|
|
116
|
+
of the following places: within a NOTICE text file distributed
|
|
117
|
+
as part of the Derivative Works; within the Source form or
|
|
118
|
+
documentation, if provided along with the Derivative Works; or,
|
|
119
|
+
within a display generated by the Derivative Works, if and
|
|
120
|
+
wherever such third-party notices normally appear. The contents
|
|
121
|
+
of the NOTICE file are for informational purposes only and
|
|
122
|
+
do not modify the License. You may add Your own attribution
|
|
123
|
+
notices within Derivative Works that You distribute, alongside
|
|
124
|
+
or as an addendum to the NOTICE text from the Work, provided
|
|
125
|
+
that such additional attribution notices cannot be construed
|
|
126
|
+
as modifying the License.
|
|
127
|
+
|
|
128
|
+
You may add Your own copyright statement to Your modifications and
|
|
129
|
+
may provide additional or different license terms and conditions
|
|
130
|
+
for use, reproduction, or distribution of Your modifications, or
|
|
131
|
+
for any such Derivative Works as a whole, provided Your use,
|
|
132
|
+
reproduction, and distribution of the Work otherwise complies with
|
|
133
|
+
the conditions stated in this License.
|
|
134
|
+
|
|
135
|
+
5. Submission of Contributions. Unless You explicitly state otherwise,
|
|
136
|
+
any Contribution intentionally submitted for inclusion in the Work
|
|
137
|
+
by You to the Licensor shall be under the terms and conditions of
|
|
138
|
+
this License, without any additional terms or conditions.
|
|
139
|
+
Notwithstanding the above, nothing herein shall supersede or modify
|
|
140
|
+
the terms of any separate license agreement you may have executed
|
|
141
|
+
with Licensor regarding such Contributions.
|
|
142
|
+
|
|
143
|
+
6. Trademarks. This License does not grant permission to use the trade
|
|
144
|
+
names, trademarks, service marks, or product names of the Licensor,
|
|
145
|
+
except as required for reasonable and customary use in describing the
|
|
146
|
+
origin of the Work and reproducing the content of the NOTICE file.
|
|
147
|
+
|
|
148
|
+
7. Disclaimer of Warranty. Unless required by applicable law or
|
|
149
|
+
agreed to in writing, Licensor provides the Work (and each
|
|
150
|
+
Contributor provides its Contributions) on an "AS IS" BASIS,
|
|
151
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
|
|
152
|
+
implied, including, without limitation, any warranties or conditions
|
|
153
|
+
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
|
|
154
|
+
PARTICULAR PURPOSE. You are solely responsible for determining the
|
|
155
|
+
appropriateness of using or redistributing the Work and assume any
|
|
156
|
+
risks associated with Your exercise of permissions under this License.
|
|
157
|
+
|
|
158
|
+
8. Limitation of Liability. In no event and under no legal theory,
|
|
159
|
+
whether in tort (including negligence), contract, or otherwise,
|
|
160
|
+
unless required by applicable law (such as deliberate and grossly
|
|
161
|
+
negligent acts) or agreed to in writing, shall any Contributor be
|
|
162
|
+
liable to You for damages, including any direct, indirect, special,
|
|
163
|
+
incidental, or consequential damages of any character arising as a
|
|
164
|
+
result of this License or out of the use or inability to use the
|
|
165
|
+
Work (including but not limited to damages for loss of goodwill,
|
|
166
|
+
work stoppage, computer failure or malfunction, or any and all
|
|
167
|
+
other commercial damages or losses), even if such Contributor
|
|
168
|
+
has been advised of the possibility of such damages.
|
|
169
|
+
|
|
170
|
+
9. Accepting Warranty or Additional Liability. While redistributing
|
|
171
|
+
the Work or Derivative Works thereof, You may choose to offer,
|
|
172
|
+
and charge a fee for, acceptance of support, warranty, indemnity,
|
|
173
|
+
or other liability obligations and/or rights consistent with this
|
|
174
|
+
License. However, in accepting such obligations, You may act only
|
|
175
|
+
on Your own behalf and on Your sole responsibility, not on behalf
|
|
176
|
+
of any other Contributor, and only if You agree to indemnify,
|
|
177
|
+
defend, and hold each Contributor harmless for any liability
|
|
178
|
+
incurred by, or claims asserted against, such Contributor by reason
|
|
179
|
+
of your accepting any such warranty or additional liability.
|
|
180
|
+
|
|
181
|
+
END OF TERMS AND CONDITIONS
|
|
182
|
+
|
|
183
|
+
APPENDIX: How to apply the Apache License to your work.
|
|
184
|
+
|
|
185
|
+
To apply the Apache License to your work, attach the following
|
|
186
|
+
boilerplate notice, with the fields enclosed by brackets "[]"
|
|
187
|
+
replaced with your own identifying information. (Don't include
|
|
188
|
+
the brackets!) The text should be enclosed in the appropriate
|
|
189
|
+
comment syntax for the file format. We also recommend that a
|
|
190
|
+
file or class name and description of purpose be included on the
|
|
191
|
+
same "printed page" as the copyright notice for easier
|
|
192
|
+
identification within third-party archives.
|
|
193
|
+
|
|
194
|
+
Copyright [yyyy] [name of copyright owner]
|
|
195
|
+
|
|
196
|
+
Licensed under the Apache License, Version 2.0 (the "License");
|
|
197
|
+
you may not use this file except in compliance with the License.
|
|
198
|
+
You may obtain a copy of the License at
|
|
199
|
+
|
|
200
|
+
http://www.apache.org/licenses/LICENSE-2.0
|
|
201
|
+
|
|
202
|
+
Unless required by applicable law or agreed to in writing, software
|
|
203
|
+
distributed under the License is distributed on an "AS IS" BASIS,
|
|
204
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
205
|
+
See the License for the specific language governing permissions and
|
|
206
|
+
limitations under the License.
|
|
207
|
+
|
|
208
|
+
Classifier: Programming Language :: Python :: 3
|
|
209
|
+
Requires-Python: >=3.12
|
|
210
|
+
Description-Content-Type: text/markdown
|
|
211
|
+
License-File: LICENSE
|
|
212
|
+
Requires-Dist: pydantic>=2.0.0
|
|
213
|
+
Requires-Dist: requests>=2.28.0
|
|
214
|
+
Requires-Dist: httpx>=0.27.0
|
|
215
|
+
Requires-Dist: aiohttp>=3.8.0
|
|
216
|
+
Requires-Dist: pyyaml>=6.0.0
|
|
217
|
+
Requires-Dist: websocket-client>=1.6.0
|
|
218
|
+
Requires-Dist: websockets>=12.0
|
|
219
|
+
Requires-Dist: typer>=0.15.0
|
|
220
|
+
Requires-Dist: rich>=14.0.0
|
|
221
|
+
Requires-Dist: questionary>=2.1.0
|
|
222
|
+
Provides-Extra: all
|
|
223
|
+
Requires-Dist: ray[all]==2.50.0; extra == "all"
|
|
224
|
+
Requires-Dist: universal-pathlib>=0.3.7; extra == "all"
|
|
225
|
+
Requires-Dist: s3fs>=2024.0.0; extra == "all"
|
|
226
|
+
Requires-Dist: gcsfs>=2024.0.0; extra == "all"
|
|
227
|
+
Requires-Dist: sshfs>=2024.0.0; extra == "all"
|
|
228
|
+
Requires-Dist: mcp>=1.25.0; extra == "all"
|
|
229
|
+
Provides-Extra: test
|
|
230
|
+
Requires-Dist: pytest>=7.0.0; extra == "test"
|
|
231
|
+
Requires-Dist: pytest-asyncio>=0.21.0; extra == "test"
|
|
232
|
+
Requires-Dist: pytest-cov>=4.0.0; extra == "test"
|
|
233
|
+
Requires-Dist: pytest-mock>=3.10.0; extra == "test"
|
|
234
|
+
Requires-Dist: pytest-timeout>=2.1.0; extra == "test"
|
|
235
|
+
Requires-Dist: pytest-xdist>=3.0.0; extra == "test"
|
|
236
|
+
Requires-Dist: pytest-html>=3.1.0; extra == "test"
|
|
237
|
+
Requires-Dist: pytest-json-report>=1.5.0; extra == "test"
|
|
238
|
+
Requires-Dist: requests-mock>=1.10.0; extra == "test"
|
|
239
|
+
Requires-Dist: responses>=0.25.0; extra == "test"
|
|
240
|
+
Requires-Dist: respx>=0.20.0; extra == "test"
|
|
241
|
+
Provides-Extra: dev
|
|
242
|
+
Requires-Dist: pre-commit; extra == "dev"
|
|
243
|
+
Requires-Dist: ruff>=0.8.0; extra == "dev"
|
|
244
|
+
Provides-Extra: docs
|
|
245
|
+
Requires-Dist: pydoc-markdown>=4.8.0; extra == "docs"
|
|
246
|
+
Dynamic: license-file
|
|
247
|
+
|
|
248
|
+
# Synapse SDK v2
|
|
249
|
+
|
|
250
|
+
> To be merged into [synapse-sdk](https://github.com/datamaker-kr/synapse-sdk) after development
|
|
251
|
+
|
|
252
|
+
## Table of Contents
|
|
253
|
+
|
|
254
|
+
- [Installation](#installation)
|
|
255
|
+
- [Migration Guide](#migration-guide)
|
|
256
|
+
- [Plugin Utils](#plugin-utils)
|
|
257
|
+
- [Plugin Types](#plugin-types)
|
|
258
|
+
- [Plugin Discovery](#plugin-discovery)
|
|
259
|
+
- [Storage Utils](#storage-utils)
|
|
260
|
+
- [API Reference](#api-reference)
|
|
261
|
+
- [get_plugin_actions](#get_plugin_actions)
|
|
262
|
+
- [get_action_method](#get_action_method)
|
|
263
|
+
- [get_action_config](#get_action_config)
|
|
264
|
+
- [read_requirements](#read_requirements)
|
|
265
|
+
- [run_plugin](#run_plugin)
|
|
266
|
+
- [PluginDiscovery](#plugindiscovery)
|
|
267
|
+
- [Storage](#storage)
|
|
268
|
+
- [Action Base Classes](#action-base-classes)
|
|
269
|
+
- [BaseTrainAction](#basetrainaction)
|
|
270
|
+
- [BaseExportAction](#baseexportaction)
|
|
271
|
+
- [BaseUploadAction](#baseuploadaction)
|
|
272
|
+
- [Agent Client Streaming](#agent-client-streaming)
|
|
273
|
+
|
|
274
|
+
---
|
|
275
|
+
|
|
276
|
+
## Installation
|
|
277
|
+
|
|
278
|
+
```bash
|
|
279
|
+
pip install synapse-sdk
|
|
280
|
+
```
|
|
281
|
+
|
|
282
|
+
---
|
|
283
|
+
|
|
284
|
+
## Migration Guide
|
|
285
|
+
|
|
286
|
+
### Plugin Utils
|
|
287
|
+
|
|
288
|
+
**Old (synapse-sdk v1):**
|
|
289
|
+
```python
|
|
290
|
+
from synapse_sdk.plugins.utils import get_action_class, get_plugin_actions, read_requirements
|
|
291
|
+
|
|
292
|
+
# Get run method by loading the action class
|
|
293
|
+
action_method = get_action_class(config['category'], action).method
|
|
294
|
+
```
|
|
295
|
+
|
|
296
|
+
**New (synapse-sdk v2):**
|
|
297
|
+
```python
|
|
298
|
+
from synapse_sdk.plugins.utils import get_action_method, get_plugin_actions, read_requirements
|
|
299
|
+
|
|
300
|
+
# Get run method directly from config (no class loading needed)
|
|
301
|
+
action_method = get_action_method(config, action)
|
|
302
|
+
```
|
|
303
|
+
|
|
304
|
+
### Plugin Types
|
|
305
|
+
|
|
306
|
+
**Old:**
|
|
307
|
+
```python
|
|
308
|
+
from synapse_sdk.plugins.enums import PluginCategory
|
|
309
|
+
from synapse_sdk.plugins.base import RunMethod
|
|
310
|
+
```
|
|
311
|
+
|
|
312
|
+
**New:**
|
|
313
|
+
```python
|
|
314
|
+
from synapse_sdk.plugins.enums import PluginCategory, RunMethod
|
|
315
|
+
```
|
|
316
|
+
|
|
317
|
+
**Provider renames:**
|
|
318
|
+
- `file_system` -> `local` (alias `file_system` still works)
|
|
319
|
+
- `FileSystemStorage` -> `LocalStorage`
|
|
320
|
+
- `GCPStorage` -> `GCSStorage`
|
|
321
|
+
|
|
322
|
+
---
|
|
323
|
+
|
|
324
|
+
## API Reference
|
|
325
|
+
|
|
326
|
+
### get_plugin_actions
|
|
327
|
+
|
|
328
|
+
Extract action names from plugin configuration.
|
|
329
|
+
|
|
330
|
+
```python
|
|
331
|
+
from synapse_sdk.plugins.utils import get_plugin_actions
|
|
332
|
+
|
|
333
|
+
# From dict
|
|
334
|
+
actions = get_plugin_actions({'actions': {'train': {}, 'export': {}}})
|
|
335
|
+
# Returns: ['train', 'export']
|
|
336
|
+
|
|
337
|
+
# From PluginConfig
|
|
338
|
+
actions = get_plugin_actions(plugin_config)
|
|
339
|
+
|
|
340
|
+
# From path
|
|
341
|
+
actions = get_plugin_actions('/path/to/plugin') # reads config.yaml
|
|
342
|
+
```
|
|
343
|
+
|
|
344
|
+
### get_action_method
|
|
345
|
+
|
|
346
|
+
Get the execution method (job/task/serve_application) for an action.
|
|
347
|
+
|
|
348
|
+
```python
|
|
349
|
+
from synapse_sdk.plugins.utils import get_action_method
|
|
350
|
+
from synapse_sdk.plugins.enums import RunMethod
|
|
351
|
+
|
|
352
|
+
method = get_action_method(config, 'train')
|
|
353
|
+
if method == RunMethod.JOB:
|
|
354
|
+
# Create job record, run async
|
|
355
|
+
pass
|
|
356
|
+
elif method == RunMethod.TASK:
|
|
357
|
+
# Run as Ray task
|
|
358
|
+
pass
|
|
359
|
+
```
|
|
360
|
+
|
|
361
|
+
### get_action_config
|
|
362
|
+
|
|
363
|
+
Get full configuration for a specific action.
|
|
364
|
+
|
|
365
|
+
```python
|
|
366
|
+
from synapse_sdk.plugins.utils import get_action_config
|
|
367
|
+
|
|
368
|
+
config = get_action_config(plugin_config, 'train')
|
|
369
|
+
# Returns: {'name': 'train', 'method': 'job', 'entrypoint': '...', ...}
|
|
370
|
+
```
|
|
371
|
+
|
|
372
|
+
### read_requirements
|
|
373
|
+
|
|
374
|
+
Parse a requirements.txt file.
|
|
375
|
+
|
|
376
|
+
```python
|
|
377
|
+
from synapse_sdk.plugins.utils import read_requirements
|
|
378
|
+
|
|
379
|
+
reqs = read_requirements('/path/to/requirements.txt')
|
|
380
|
+
# Returns: ['numpy>=1.20', 'torch>=2.0'] or None if file doesn't exist
|
|
381
|
+
```
|
|
382
|
+
|
|
383
|
+
### run_plugin
|
|
384
|
+
|
|
385
|
+
Execute plugin actions with automatic discovery.
|
|
386
|
+
|
|
387
|
+
```python
|
|
388
|
+
from synapse_sdk.plugins.runner import run_plugin
|
|
389
|
+
|
|
390
|
+
# Auto-discover from Python module path
|
|
391
|
+
result = run_plugin('plugins.yolov8', 'train', {'epochs': 10})
|
|
392
|
+
|
|
393
|
+
# Auto-discover from config.yaml path
|
|
394
|
+
result = run_plugin('/path/to/plugin', 'train', {'epochs': 10})
|
|
395
|
+
|
|
396
|
+
# Execution modes
|
|
397
|
+
result = run_plugin('plugin', 'train', params, mode='local') # Current process (default)
|
|
398
|
+
result = run_plugin('plugin', 'train', params, mode='task') # Ray Actor (fast startup)
|
|
399
|
+
job_id = run_plugin('plugin', 'train', params, mode='job') # Ray Job API (async)
|
|
400
|
+
|
|
401
|
+
# Explicit action class (skips discovery)
|
|
402
|
+
result = run_plugin('yolov8', 'train', {'epochs': 10}, action_cls=TrainAction)
|
|
403
|
+
```
|
|
404
|
+
|
|
405
|
+
**Option 1: Define actions with `@action` decorator (recommended for Python modules):**
|
|
406
|
+
|
|
407
|
+
```python
|
|
408
|
+
# plugins/yolov8.py
|
|
409
|
+
from synapse_sdk.plugins.decorators import action
|
|
410
|
+
from pydantic import BaseModel
|
|
411
|
+
|
|
412
|
+
class TrainParams(BaseModel):
|
|
413
|
+
epochs: int = 10
|
|
414
|
+
batch_size: int = 32
|
|
415
|
+
|
|
416
|
+
@action(name='train', description='Train YOLOv8 model', params=TrainParams)
|
|
417
|
+
def train(params: TrainParams, ctx):
|
|
418
|
+
# Training logic here
|
|
419
|
+
return {'accuracy': 0.95}
|
|
420
|
+
|
|
421
|
+
@action(name='infer')
|
|
422
|
+
def infer(params, ctx):
|
|
423
|
+
# Inference logic
|
|
424
|
+
return {'predictions': [...]}
|
|
425
|
+
|
|
426
|
+
# Run it:
|
|
427
|
+
# run_plugin('plugins.yolov8', 'train', {'epochs': 20})
|
|
428
|
+
```
|
|
429
|
+
|
|
430
|
+
**Option 2: Define actions with `BaseAction` class:**
|
|
431
|
+
|
|
432
|
+
```python
|
|
433
|
+
# plugins/yolov8.py
|
|
434
|
+
from synapse_sdk.plugins.action import BaseAction
|
|
435
|
+
from pydantic import BaseModel
|
|
436
|
+
|
|
437
|
+
class TrainParams(BaseModel):
|
|
438
|
+
epochs: int = 10
|
|
439
|
+
|
|
440
|
+
class TrainAction(BaseAction[TrainParams]):
|
|
441
|
+
action_name = 'train'
|
|
442
|
+
params_model = TrainParams
|
|
443
|
+
|
|
444
|
+
def execute(self):
|
|
445
|
+
# self.params contains validated TrainParams
|
|
446
|
+
# self.ctx contains RuntimeContext (logger, env, job_id)
|
|
447
|
+
return {'accuracy': 0.95}
|
|
448
|
+
|
|
449
|
+
# Run it:
|
|
450
|
+
# run_plugin('plugins.yolov8', 'train', {'epochs': 20})
|
|
451
|
+
```
|
|
452
|
+
|
|
453
|
+
**Option 3: Define actions with `config.yaml` (recommended for packaged plugins):**
|
|
454
|
+
|
|
455
|
+
```yaml
|
|
456
|
+
# plugin/config.yaml
|
|
457
|
+
name: YOLOv8 Plugin
|
|
458
|
+
code: yolov8
|
|
459
|
+
version: 1.0.0
|
|
460
|
+
category: neural_net
|
|
461
|
+
description: YOLOv8 object detection plugin
|
|
462
|
+
|
|
463
|
+
actions:
|
|
464
|
+
train:
|
|
465
|
+
entrypoint: plugin.train.TrainAction # or plugin.train:TrainAction
|
|
466
|
+
method: job
|
|
467
|
+
description: Train YOLOv8 model
|
|
468
|
+
|
|
469
|
+
infer:
|
|
470
|
+
entrypoint: plugin.inference.InferAction
|
|
471
|
+
method: task
|
|
472
|
+
description: Run inference
|
|
473
|
+
|
|
474
|
+
export:
|
|
475
|
+
entrypoint: plugin.export.export_model
|
|
476
|
+
method: task
|
|
477
|
+
```
|
|
478
|
+
|
|
479
|
+
```python
|
|
480
|
+
# Run from config path:
|
|
481
|
+
run_plugin('/path/to/plugin', 'train', {'epochs': 20})
|
|
482
|
+
```
|
|
483
|
+
|
|
484
|
+
**Entrypoint formats:**
|
|
485
|
+
- Dot notation: `plugin.train.TrainAction` (module.submodule.ClassName)
|
|
486
|
+
- Colon notation: `plugin.train:TrainAction` (module.submodule:ClassName)
|
|
487
|
+
|
|
488
|
+
### PluginDiscovery
|
|
489
|
+
|
|
490
|
+
Comprehensive plugin introspection.
|
|
491
|
+
|
|
492
|
+
```python
|
|
493
|
+
from synapse_sdk.plugins.discovery import PluginDiscovery
|
|
494
|
+
|
|
495
|
+
# Load from config.yaml
|
|
496
|
+
discovery = PluginDiscovery.from_path('/path/to/plugin')
|
|
497
|
+
|
|
498
|
+
# Or introspect a Python module
|
|
499
|
+
discovery = PluginDiscovery.from_module(my_module)
|
|
500
|
+
|
|
501
|
+
# Available methods
|
|
502
|
+
discovery.list_actions() # ['train', 'export']
|
|
503
|
+
discovery.has_action('train') # True
|
|
504
|
+
discovery.get_action_method('train') # RunMethod.JOB
|
|
505
|
+
discovery.get_action_config('train') # ActionConfig instance
|
|
506
|
+
discovery.get_action_class('train') # Loads class from entrypoint
|
|
507
|
+
```
|
|
508
|
+
|
|
509
|
+
### Storage
|
|
510
|
+
|
|
511
|
+
Storage utilities for working with different storage backends.
|
|
512
|
+
|
|
513
|
+
**Installation for cloud providers:**
|
|
514
|
+
```bash
|
|
515
|
+
pip install synapse-sdk[all] # Includes S3, GCS, SFTP support + Ray
|
|
516
|
+
```
|
|
517
|
+
|
|
518
|
+
**Available providers:**
|
|
519
|
+
- `local` / `file_system` - Local filesystem
|
|
520
|
+
- `s3` / `amazon_s3` / `minio` - S3-compatible storage
|
|
521
|
+
- `gcs` / `gs` / `gcp` - Google Cloud Storage
|
|
522
|
+
- `sftp` - SFTP servers
|
|
523
|
+
- `http` / `https` - HTTP file servers
|
|
524
|
+
|
|
525
|
+
**Basic usage:**
|
|
526
|
+
```python
|
|
527
|
+
from synapse_sdk.utils.storage import (
|
|
528
|
+
get_storage,
|
|
529
|
+
get_pathlib,
|
|
530
|
+
get_path_file_count,
|
|
531
|
+
get_path_total_size,
|
|
532
|
+
)
|
|
533
|
+
|
|
534
|
+
# Get storage instance
|
|
535
|
+
storage = get_storage({
|
|
536
|
+
'provider': 'local',
|
|
537
|
+
'configuration': {'location': '/data'}
|
|
538
|
+
})
|
|
539
|
+
|
|
540
|
+
# Upload a file
|
|
541
|
+
url = storage.upload(Path('/tmp/file.txt'), 'uploads/file.txt')
|
|
542
|
+
|
|
543
|
+
# Check existence
|
|
544
|
+
exists = storage.exists('uploads/file.txt')
|
|
545
|
+
|
|
546
|
+
# Get pathlib object for path operations
|
|
547
|
+
path = get_pathlib(config, '/uploads')
|
|
548
|
+
for file in path.rglob('*.txt'):
|
|
549
|
+
print(file)
|
|
550
|
+
|
|
551
|
+
# Get file count and total size
|
|
552
|
+
count = get_path_file_count(config, '/uploads')
|
|
553
|
+
size = get_path_total_size(config, '/uploads')
|
|
554
|
+
```
|
|
555
|
+
|
|
556
|
+
**Provider configurations:**
|
|
557
|
+
|
|
558
|
+
```python
|
|
559
|
+
# Local filesystem
|
|
560
|
+
{'provider': 'local', 'configuration': {'location': '/data'}}
|
|
561
|
+
|
|
562
|
+
# S3/MinIO
|
|
563
|
+
{'provider': 's3', 'configuration': {
|
|
564
|
+
'bucket_name': 'my-bucket',
|
|
565
|
+
'access_key': 'AKIAIOSFODNN7EXAMPLE',
|
|
566
|
+
'secret_key': 'wJalrXUtnFEMI/K7MDENG/bPxRfiCYEXAMPLEKEY',
|
|
567
|
+
'region_name': 'us-east-1',
|
|
568
|
+
'endpoint_url': 'http://minio:9000', # optional, for MinIO
|
|
569
|
+
}}
|
|
570
|
+
|
|
571
|
+
# Google Cloud Storage
|
|
572
|
+
{'provider': 'gcs', 'configuration': {
|
|
573
|
+
'bucket_name': 'my-bucket',
|
|
574
|
+
'credentials': '/path/to/service-account.json',
|
|
575
|
+
}}
|
|
576
|
+
|
|
577
|
+
# SFTP
|
|
578
|
+
{'provider': 'sftp', 'configuration': {
|
|
579
|
+
'host': 'sftp.example.com',
|
|
580
|
+
'username': 'user',
|
|
581
|
+
'password': 'secret', # or 'private_key': '/path/to/id_rsa'
|
|
582
|
+
'root_path': '/data',
|
|
583
|
+
}}
|
|
584
|
+
|
|
585
|
+
# HTTP
|
|
586
|
+
{'provider': 'http', 'configuration': {
|
|
587
|
+
'base_url': 'https://files.example.com/uploads/',
|
|
588
|
+
'timeout': 60,
|
|
589
|
+
}}
|
|
590
|
+
```
|
|
591
|
+
|
|
592
|
+
---
|
|
593
|
+
|
|
594
|
+
## Changes from v1
|
|
595
|
+
|
|
596
|
+
### Breaking Changes
|
|
597
|
+
|
|
598
|
+
These changes **require code updates** when migrating from v1:
|
|
599
|
+
|
|
600
|
+
| v1 | v2 | Migration |
|
|
601
|
+
|----|----|----|
|
|
602
|
+
| `get_action_class(category, action)` | `get_action_method(config, action)` | Pass config dict instead of category string |
|
|
603
|
+
| `action_class.method` | `get_action_method(config, action)` | Method is now read from config, not class attribute |
|
|
604
|
+
| `@register_action` decorator | Removed | Define actions in `config.yaml` or use `PluginDiscovery.from_module()` |
|
|
605
|
+
| `_REGISTERED_ACTIONS` global | Removed | Use `PluginDiscovery` for action introspection |
|
|
606
|
+
| `get_storage('s3://...')` URL strings | Dict-only config | Use `get_storage({'provider': 's3', 'configuration': {...}})` |
|
|
607
|
+
| `from ... import FileSystemStorage` | `from ... import LocalStorage` | Class renamed |
|
|
608
|
+
| `from ... import GCPStorage` | `from ... import GCSStorage` | Class renamed |
|
|
609
|
+
| Subclassing `BaseStorage` ABC | Implement `StorageProtocol` | Use structural typing (duck typing) instead of inheritance |
|
|
610
|
+
|
|
611
|
+
### Non-Breaking Changes
|
|
612
|
+
|
|
613
|
+
These changes are **backwards compatible** - existing code continues to work:
|
|
614
|
+
|
|
615
|
+
| Feature | Notes |
|
|
616
|
+
|---------|-------|
|
|
617
|
+
| Provider alias `file_system` | Still works, maps to `LocalStorage` |
|
|
618
|
+
| Provider aliases `gcp`, `gs` | Still work, map to `GCSStorage` |
|
|
619
|
+
| `get_plugin_actions()` | Same API |
|
|
620
|
+
| `read_requirements()` | Same API |
|
|
621
|
+
| `get_pathlib()` | Same API |
|
|
622
|
+
| `get_path_file_count()` | Same API |
|
|
623
|
+
| `get_path_total_size()` | Same API |
|
|
624
|
+
|
|
625
|
+
### New Features in v2
|
|
626
|
+
|
|
627
|
+
| Feature | Description |
|
|
628
|
+
|---------|-------------|
|
|
629
|
+
| `PluginDiscovery` | Discover actions from config files or Python modules |
|
|
630
|
+
| `PluginDiscovery.from_module()` | Auto-discover `@action` decorators and `BaseAction` subclasses |
|
|
631
|
+
| `StorageProtocol` | Protocol-based interface for custom storage implementations |
|
|
632
|
+
| `HTTPStorage` provider | New provider for HTTP file servers |
|
|
633
|
+
| Plugin Upload utilities | `archive_and_upload()`, `build_and_upload()`, `download_and_upload()` |
|
|
634
|
+
| File utilities | `calculate_checksum()`, `create_archive()`, `create_archive_from_git()` |
|
|
635
|
+
| `AsyncAgentClient` | Async client with WebSocket/HTTP streaming for job logs |
|
|
636
|
+
| `tail_job_logs()` | Stream job logs with protocol auto-selection |
|
|
637
|
+
| `BaseTrainAction` | Training base class with dataset/model helpers |
|
|
638
|
+
| `BaseExportAction` | Export base class with filtered results helper |
|
|
639
|
+
| `BaseUploadAction` | Upload base class with step-based workflow and rollback |
|
|
640
|
+
|
|
641
|
+
---
|
|
642
|
+
|
|
643
|
+
## Action Base Classes
|
|
644
|
+
|
|
645
|
+
Category-specific base classes that provide helper methods and progress tracking for common workflows.
|
|
646
|
+
|
|
647
|
+
### BaseTrainAction
|
|
648
|
+
|
|
649
|
+
For training workflows with dataset/model helpers.
|
|
650
|
+
|
|
651
|
+
```python
|
|
652
|
+
from synapse_sdk.plugins import BaseTrainAction, TrainProgressCategories
|
|
653
|
+
from pydantic import BaseModel
|
|
654
|
+
|
|
655
|
+
class TrainParams(BaseModel):
|
|
656
|
+
dataset_id: int
|
|
657
|
+
epochs: int = 10
|
|
658
|
+
|
|
659
|
+
class MyTrainAction(BaseTrainAction[TrainParams]):
|
|
660
|
+
action_name = 'train'
|
|
661
|
+
params_model = TrainParams
|
|
662
|
+
|
|
663
|
+
def execute(self) -> dict:
|
|
664
|
+
# Helper methods use self.client (from RuntimeContext)
|
|
665
|
+
dataset = self.get_dataset() # Uses params.dataset_id
|
|
666
|
+
self.set_progress(1, 3, self.progress.DATASET)
|
|
667
|
+
|
|
668
|
+
model_path = self._train(dataset)
|
|
669
|
+
self.set_progress(2, 3, self.progress.TRAIN)
|
|
670
|
+
|
|
671
|
+
model = self.create_model(model_path, name='my-model')
|
|
672
|
+
self.set_progress(3, 3, self.progress.MODEL_UPLOAD)
|
|
673
|
+
|
|
674
|
+
return {'model_id': model['id']}
|
|
675
|
+
```
|
|
676
|
+
|
|
677
|
+
**Progress categories:** `DATASET`, `TRAIN`, `MODEL_UPLOAD`
|
|
678
|
+
|
|
679
|
+
**Helper methods:**
|
|
680
|
+
- `get_dataset()` - Fetch dataset using `params.dataset_id`
|
|
681
|
+
- `create_model(path, **kwargs)` - Upload trained model
|
|
682
|
+
- `get_model(model_id)` - Retrieve existing model
|
|
683
|
+
|
|
684
|
+
### BaseExportAction
|
|
685
|
+
|
|
686
|
+
For export workflows with filtered data retrieval.
|
|
687
|
+
|
|
688
|
+
```python
|
|
689
|
+
from typing import Any
|
|
690
|
+
|
|
691
|
+
from synapse_sdk.plugins import BaseExportAction, ExportProgressCategories
|
|
692
|
+
from pydantic import BaseModel
|
|
693
|
+
|
|
694
|
+
class ExportParams(BaseModel):
|
|
695
|
+
filter: dict
|
|
696
|
+
output_path: str
|
|
697
|
+
|
|
698
|
+
class MyExportAction(BaseExportAction[ExportParams]):
|
|
699
|
+
action_name = 'export'
|
|
700
|
+
params_model = ExportParams
|
|
701
|
+
|
|
702
|
+
def get_filtered_results(self, filters: dict) -> tuple[Any, int]:
|
|
703
|
+
# Override for your target type
|
|
704
|
+
return self.client.get_assignments(filters)
|
|
705
|
+
|
|
706
|
+
def execute(self) -> dict:
|
|
707
|
+
results, count = self.get_filtered_results(self.params.filter)
|
|
708
|
+
self.set_progress(0, count, self.progress.DATASET_CONVERSION)
|
|
709
|
+
|
|
710
|
+
for i, item in enumerate(results, 1):
|
|
711
|
+
# Process and export item
|
|
712
|
+
self.set_progress(i, count, self.progress.DATASET_CONVERSION)
|
|
713
|
+
|
|
714
|
+
return {'exported': count}
|
|
715
|
+
```
|