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.

Files changed (261) hide show
  1. synapse_sdk/__init__.py +24 -0
  2. synapse_sdk/cli/__init__.py +9 -8
  3. synapse_sdk/cli/agent/__init__.py +25 -0
  4. synapse_sdk/cli/agent/config.py +104 -0
  5. synapse_sdk/cli/agent/select.py +197 -0
  6. synapse_sdk/cli/auth.py +104 -0
  7. synapse_sdk/cli/main.py +1025 -0
  8. synapse_sdk/cli/plugin/__init__.py +58 -0
  9. synapse_sdk/cli/plugin/create.py +566 -0
  10. synapse_sdk/cli/plugin/job.py +196 -0
  11. synapse_sdk/cli/plugin/publish.py +322 -0
  12. synapse_sdk/cli/plugin/run.py +131 -0
  13. synapse_sdk/cli/plugin/test.py +200 -0
  14. synapse_sdk/clients/README.md +239 -0
  15. synapse_sdk/clients/__init__.py +5 -0
  16. synapse_sdk/clients/_template.py +266 -0
  17. synapse_sdk/clients/agent/__init__.py +84 -29
  18. synapse_sdk/clients/agent/async_ray.py +289 -0
  19. synapse_sdk/clients/agent/container.py +83 -0
  20. synapse_sdk/clients/agent/plugin.py +101 -0
  21. synapse_sdk/clients/agent/ray.py +296 -39
  22. synapse_sdk/clients/backend/__init__.py +152 -12
  23. synapse_sdk/clients/backend/annotation.py +164 -22
  24. synapse_sdk/clients/backend/core.py +101 -0
  25. synapse_sdk/clients/backend/data_collection.py +292 -0
  26. synapse_sdk/clients/backend/hitl.py +87 -0
  27. synapse_sdk/clients/backend/integration.py +374 -46
  28. synapse_sdk/clients/backend/ml.py +134 -22
  29. synapse_sdk/clients/backend/models.py +247 -0
  30. synapse_sdk/clients/base.py +538 -59
  31. synapse_sdk/clients/exceptions.py +35 -7
  32. synapse_sdk/clients/pipeline/__init__.py +5 -0
  33. synapse_sdk/clients/pipeline/client.py +636 -0
  34. synapse_sdk/clients/protocols.py +178 -0
  35. synapse_sdk/clients/utils.py +86 -8
  36. synapse_sdk/clients/validation.py +58 -0
  37. synapse_sdk/enums.py +76 -0
  38. synapse_sdk/exceptions.py +168 -0
  39. synapse_sdk/integrations/__init__.py +74 -0
  40. synapse_sdk/integrations/_base.py +119 -0
  41. synapse_sdk/integrations/_context.py +53 -0
  42. synapse_sdk/integrations/ultralytics/__init__.py +78 -0
  43. synapse_sdk/integrations/ultralytics/_callbacks.py +126 -0
  44. synapse_sdk/integrations/ultralytics/_patches.py +124 -0
  45. synapse_sdk/loggers.py +476 -95
  46. synapse_sdk/mcp/MCP.md +69 -0
  47. synapse_sdk/mcp/__init__.py +48 -0
  48. synapse_sdk/mcp/__main__.py +6 -0
  49. synapse_sdk/mcp/config.py +349 -0
  50. synapse_sdk/mcp/prompts/__init__.py +4 -0
  51. synapse_sdk/mcp/resources/__init__.py +4 -0
  52. synapse_sdk/mcp/server.py +1352 -0
  53. synapse_sdk/mcp/tools/__init__.py +6 -0
  54. synapse_sdk/plugins/__init__.py +133 -9
  55. synapse_sdk/plugins/action.py +229 -0
  56. synapse_sdk/plugins/actions/__init__.py +82 -0
  57. synapse_sdk/plugins/actions/dataset/__init__.py +37 -0
  58. synapse_sdk/plugins/actions/dataset/action.py +471 -0
  59. synapse_sdk/plugins/actions/export/__init__.py +55 -0
  60. synapse_sdk/plugins/actions/export/action.py +183 -0
  61. synapse_sdk/plugins/actions/export/context.py +59 -0
  62. synapse_sdk/plugins/actions/inference/__init__.py +84 -0
  63. synapse_sdk/plugins/actions/inference/action.py +285 -0
  64. synapse_sdk/plugins/actions/inference/context.py +81 -0
  65. synapse_sdk/plugins/actions/inference/deployment.py +322 -0
  66. synapse_sdk/plugins/actions/inference/serve.py +252 -0
  67. synapse_sdk/plugins/actions/train/__init__.py +54 -0
  68. synapse_sdk/plugins/actions/train/action.py +326 -0
  69. synapse_sdk/plugins/actions/train/context.py +57 -0
  70. synapse_sdk/plugins/actions/upload/__init__.py +49 -0
  71. synapse_sdk/plugins/actions/upload/action.py +165 -0
  72. synapse_sdk/plugins/actions/upload/context.py +61 -0
  73. synapse_sdk/plugins/config.py +98 -0
  74. synapse_sdk/plugins/context/__init__.py +109 -0
  75. synapse_sdk/plugins/context/env.py +113 -0
  76. synapse_sdk/plugins/datasets/__init__.py +113 -0
  77. synapse_sdk/plugins/datasets/converters/__init__.py +76 -0
  78. synapse_sdk/plugins/datasets/converters/base.py +347 -0
  79. synapse_sdk/plugins/datasets/converters/yolo/__init__.py +9 -0
  80. synapse_sdk/plugins/datasets/converters/yolo/from_dm.py +468 -0
  81. synapse_sdk/plugins/datasets/converters/yolo/to_dm.py +381 -0
  82. synapse_sdk/plugins/datasets/formats/__init__.py +82 -0
  83. synapse_sdk/plugins/datasets/formats/dm.py +351 -0
  84. synapse_sdk/plugins/datasets/formats/yolo.py +240 -0
  85. synapse_sdk/plugins/decorators.py +83 -0
  86. synapse_sdk/plugins/discovery.py +790 -0
  87. synapse_sdk/plugins/docs/ACTION_DEV_GUIDE.md +933 -0
  88. synapse_sdk/plugins/docs/ARCHITECTURE.md +1225 -0
  89. synapse_sdk/plugins/docs/LOGGING_SYSTEM.md +683 -0
  90. synapse_sdk/plugins/docs/OVERVIEW.md +531 -0
  91. synapse_sdk/plugins/docs/PIPELINE_GUIDE.md +145 -0
  92. synapse_sdk/plugins/docs/README.md +513 -0
  93. synapse_sdk/plugins/docs/STEP.md +656 -0
  94. synapse_sdk/plugins/enums.py +70 -10
  95. synapse_sdk/plugins/errors.py +92 -0
  96. synapse_sdk/plugins/executors/__init__.py +43 -0
  97. synapse_sdk/plugins/executors/local.py +99 -0
  98. synapse_sdk/plugins/executors/ray/__init__.py +18 -0
  99. synapse_sdk/plugins/executors/ray/base.py +282 -0
  100. synapse_sdk/plugins/executors/ray/job.py +298 -0
  101. synapse_sdk/plugins/executors/ray/jobs_api.py +511 -0
  102. synapse_sdk/plugins/executors/ray/packaging.py +137 -0
  103. synapse_sdk/plugins/executors/ray/pipeline.py +792 -0
  104. synapse_sdk/plugins/executors/ray/task.py +257 -0
  105. synapse_sdk/plugins/models/__init__.py +26 -0
  106. synapse_sdk/plugins/models/logger.py +173 -0
  107. synapse_sdk/plugins/models/pipeline.py +25 -0
  108. synapse_sdk/plugins/pipelines/__init__.py +81 -0
  109. synapse_sdk/plugins/pipelines/action_pipeline.py +417 -0
  110. synapse_sdk/plugins/pipelines/context.py +107 -0
  111. synapse_sdk/plugins/pipelines/display.py +311 -0
  112. synapse_sdk/plugins/runner.py +114 -0
  113. synapse_sdk/plugins/schemas/__init__.py +19 -0
  114. synapse_sdk/plugins/schemas/results.py +152 -0
  115. synapse_sdk/plugins/steps/__init__.py +63 -0
  116. synapse_sdk/plugins/steps/base.py +128 -0
  117. synapse_sdk/plugins/steps/context.py +90 -0
  118. synapse_sdk/plugins/steps/orchestrator.py +128 -0
  119. synapse_sdk/plugins/steps/registry.py +103 -0
  120. synapse_sdk/plugins/steps/utils/__init__.py +20 -0
  121. synapse_sdk/plugins/steps/utils/logging.py +85 -0
  122. synapse_sdk/plugins/steps/utils/timing.py +71 -0
  123. synapse_sdk/plugins/steps/utils/validation.py +68 -0
  124. synapse_sdk/plugins/templates/__init__.py +50 -0
  125. synapse_sdk/plugins/templates/base/.gitignore.j2 +26 -0
  126. synapse_sdk/plugins/templates/base/.synapseignore.j2 +11 -0
  127. synapse_sdk/plugins/templates/base/README.md.j2 +26 -0
  128. synapse_sdk/plugins/templates/base/plugin/__init__.py.j2 +1 -0
  129. synapse_sdk/plugins/templates/base/pyproject.toml.j2 +14 -0
  130. synapse_sdk/plugins/templates/base/requirements.txt.j2 +1 -0
  131. synapse_sdk/plugins/templates/custom/plugin/main.py.j2 +18 -0
  132. synapse_sdk/plugins/templates/data_validation/plugin/validate.py.j2 +32 -0
  133. synapse_sdk/plugins/templates/export/plugin/export.py.j2 +36 -0
  134. synapse_sdk/plugins/templates/neural_net/plugin/inference.py.j2 +36 -0
  135. synapse_sdk/plugins/templates/neural_net/plugin/train.py.j2 +33 -0
  136. synapse_sdk/plugins/templates/post_annotation/plugin/post_annotate.py.j2 +32 -0
  137. synapse_sdk/plugins/templates/pre_annotation/plugin/pre_annotate.py.j2 +32 -0
  138. synapse_sdk/plugins/templates/smart_tool/plugin/auto_label.py.j2 +44 -0
  139. synapse_sdk/plugins/templates/upload/plugin/upload.py.j2 +35 -0
  140. synapse_sdk/plugins/testing/__init__.py +25 -0
  141. synapse_sdk/plugins/testing/sample_actions.py +98 -0
  142. synapse_sdk/plugins/types.py +206 -0
  143. synapse_sdk/plugins/upload.py +595 -64
  144. synapse_sdk/plugins/utils.py +325 -37
  145. synapse_sdk/shared/__init__.py +25 -0
  146. synapse_sdk/utils/__init__.py +1 -0
  147. synapse_sdk/utils/auth.py +74 -0
  148. synapse_sdk/utils/file/__init__.py +58 -0
  149. synapse_sdk/utils/file/archive.py +449 -0
  150. synapse_sdk/utils/file/checksum.py +167 -0
  151. synapse_sdk/utils/file/download.py +286 -0
  152. synapse_sdk/utils/file/io.py +129 -0
  153. synapse_sdk/utils/file/requirements.py +36 -0
  154. synapse_sdk/utils/network.py +168 -0
  155. synapse_sdk/utils/storage/__init__.py +238 -0
  156. synapse_sdk/utils/storage/config.py +188 -0
  157. synapse_sdk/utils/storage/errors.py +52 -0
  158. synapse_sdk/utils/storage/providers/__init__.py +13 -0
  159. synapse_sdk/utils/storage/providers/base.py +76 -0
  160. synapse_sdk/utils/storage/providers/gcs.py +168 -0
  161. synapse_sdk/utils/storage/providers/http.py +250 -0
  162. synapse_sdk/utils/storage/providers/local.py +126 -0
  163. synapse_sdk/utils/storage/providers/s3.py +177 -0
  164. synapse_sdk/utils/storage/providers/sftp.py +208 -0
  165. synapse_sdk/utils/storage/registry.py +125 -0
  166. synapse_sdk/utils/websocket.py +99 -0
  167. synapse_sdk-2026.1.1b2.dist-info/METADATA +715 -0
  168. synapse_sdk-2026.1.1b2.dist-info/RECORD +172 -0
  169. {synapse_sdk-1.0.0a11.dist-info → synapse_sdk-2026.1.1b2.dist-info}/WHEEL +1 -1
  170. synapse_sdk-2026.1.1b2.dist-info/licenses/LICENSE +201 -0
  171. locale/en/LC_MESSAGES/messages.mo +0 -0
  172. locale/en/LC_MESSAGES/messages.po +0 -39
  173. locale/ko/LC_MESSAGES/messages.mo +0 -0
  174. locale/ko/LC_MESSAGES/messages.po +0 -34
  175. synapse_sdk/cli/create_plugin.py +0 -10
  176. synapse_sdk/clients/agent/core.py +0 -7
  177. synapse_sdk/clients/agent/service.py +0 -15
  178. synapse_sdk/clients/backend/dataset.py +0 -51
  179. synapse_sdk/clients/ray/__init__.py +0 -6
  180. synapse_sdk/clients/ray/core.py +0 -22
  181. synapse_sdk/clients/ray/serve.py +0 -20
  182. synapse_sdk/i18n.py +0 -35
  183. synapse_sdk/plugins/categories/__init__.py +0 -0
  184. synapse_sdk/plugins/categories/base.py +0 -235
  185. synapse_sdk/plugins/categories/data_validation/__init__.py +0 -0
  186. synapse_sdk/plugins/categories/data_validation/actions/__init__.py +0 -0
  187. synapse_sdk/plugins/categories/data_validation/actions/validation.py +0 -10
  188. synapse_sdk/plugins/categories/data_validation/templates/config.yaml +0 -3
  189. synapse_sdk/plugins/categories/data_validation/templates/plugin/__init__.py +0 -0
  190. synapse_sdk/plugins/categories/data_validation/templates/plugin/validation.py +0 -5
  191. synapse_sdk/plugins/categories/decorators.py +0 -13
  192. synapse_sdk/plugins/categories/export/__init__.py +0 -0
  193. synapse_sdk/plugins/categories/export/actions/__init__.py +0 -0
  194. synapse_sdk/plugins/categories/export/actions/export.py +0 -10
  195. synapse_sdk/plugins/categories/import/__init__.py +0 -0
  196. synapse_sdk/plugins/categories/import/actions/__init__.py +0 -0
  197. synapse_sdk/plugins/categories/import/actions/import.py +0 -10
  198. synapse_sdk/plugins/categories/neural_net/__init__.py +0 -0
  199. synapse_sdk/plugins/categories/neural_net/actions/__init__.py +0 -0
  200. synapse_sdk/plugins/categories/neural_net/actions/deployment.py +0 -45
  201. synapse_sdk/plugins/categories/neural_net/actions/inference.py +0 -18
  202. synapse_sdk/plugins/categories/neural_net/actions/test.py +0 -10
  203. synapse_sdk/plugins/categories/neural_net/actions/train.py +0 -143
  204. synapse_sdk/plugins/categories/neural_net/templates/config.yaml +0 -12
  205. synapse_sdk/plugins/categories/neural_net/templates/plugin/__init__.py +0 -0
  206. synapse_sdk/plugins/categories/neural_net/templates/plugin/inference.py +0 -4
  207. synapse_sdk/plugins/categories/neural_net/templates/plugin/test.py +0 -2
  208. synapse_sdk/plugins/categories/neural_net/templates/plugin/train.py +0 -14
  209. synapse_sdk/plugins/categories/post_annotation/__init__.py +0 -0
  210. synapse_sdk/plugins/categories/post_annotation/actions/__init__.py +0 -0
  211. synapse_sdk/plugins/categories/post_annotation/actions/post_annotation.py +0 -10
  212. synapse_sdk/plugins/categories/post_annotation/templates/config.yaml +0 -3
  213. synapse_sdk/plugins/categories/post_annotation/templates/plugin/__init__.py +0 -0
  214. synapse_sdk/plugins/categories/post_annotation/templates/plugin/post_annotation.py +0 -3
  215. synapse_sdk/plugins/categories/pre_annotation/__init__.py +0 -0
  216. synapse_sdk/plugins/categories/pre_annotation/actions/__init__.py +0 -0
  217. synapse_sdk/plugins/categories/pre_annotation/actions/pre_annotation.py +0 -10
  218. synapse_sdk/plugins/categories/pre_annotation/templates/config.yaml +0 -3
  219. synapse_sdk/plugins/categories/pre_annotation/templates/plugin/__init__.py +0 -0
  220. synapse_sdk/plugins/categories/pre_annotation/templates/plugin/pre_annotation.py +0 -3
  221. synapse_sdk/plugins/categories/registry.py +0 -16
  222. synapse_sdk/plugins/categories/smart_tool/__init__.py +0 -0
  223. synapse_sdk/plugins/categories/smart_tool/actions/__init__.py +0 -0
  224. synapse_sdk/plugins/categories/smart_tool/actions/auto_label.py +0 -37
  225. synapse_sdk/plugins/categories/smart_tool/templates/config.yaml +0 -7
  226. synapse_sdk/plugins/categories/smart_tool/templates/plugin/__init__.py +0 -0
  227. synapse_sdk/plugins/categories/smart_tool/templates/plugin/auto_label.py +0 -11
  228. synapse_sdk/plugins/categories/templates.py +0 -32
  229. synapse_sdk/plugins/cli/__init__.py +0 -21
  230. synapse_sdk/plugins/cli/publish.py +0 -37
  231. synapse_sdk/plugins/cli/run.py +0 -67
  232. synapse_sdk/plugins/exceptions.py +0 -22
  233. synapse_sdk/plugins/models.py +0 -121
  234. synapse_sdk/plugins/templates/cookiecutter.json +0 -11
  235. synapse_sdk/plugins/templates/hooks/post_gen_project.py +0 -3
  236. synapse_sdk/plugins/templates/hooks/pre_prompt.py +0 -21
  237. synapse_sdk/plugins/templates/synapse-{{cookiecutter.plugin_code}}-plugin/.env +0 -24
  238. synapse_sdk/plugins/templates/synapse-{{cookiecutter.plugin_code}}-plugin/.env.dist +0 -24
  239. synapse_sdk/plugins/templates/synapse-{{cookiecutter.plugin_code}}-plugin/.gitignore +0 -27
  240. synapse_sdk/plugins/templates/synapse-{{cookiecutter.plugin_code}}-plugin/.pre-commit-config.yaml +0 -7
  241. synapse_sdk/plugins/templates/synapse-{{cookiecutter.plugin_code}}-plugin/README.md +0 -5
  242. synapse_sdk/plugins/templates/synapse-{{cookiecutter.plugin_code}}-plugin/config.yaml +0 -6
  243. synapse_sdk/plugins/templates/synapse-{{cookiecutter.plugin_code}}-plugin/main.py +0 -4
  244. synapse_sdk/plugins/templates/synapse-{{cookiecutter.plugin_code}}-plugin/plugin/__init__.py +0 -0
  245. synapse_sdk/plugins/templates/synapse-{{cookiecutter.plugin_code}}-plugin/pyproject.toml +0 -13
  246. synapse_sdk/plugins/templates/synapse-{{cookiecutter.plugin_code}}-plugin/requirements.txt +0 -1
  247. synapse_sdk/shared/enums.py +0 -8
  248. synapse_sdk/utils/debug.py +0 -5
  249. synapse_sdk/utils/file.py +0 -87
  250. synapse_sdk/utils/module_loading.py +0 -29
  251. synapse_sdk/utils/pydantic/__init__.py +0 -0
  252. synapse_sdk/utils/pydantic/config.py +0 -4
  253. synapse_sdk/utils/pydantic/errors.py +0 -33
  254. synapse_sdk/utils/pydantic/validators.py +0 -7
  255. synapse_sdk/utils/storage.py +0 -91
  256. synapse_sdk/utils/string.py +0 -11
  257. synapse_sdk-1.0.0a11.dist-info/LICENSE +0 -21
  258. synapse_sdk-1.0.0a11.dist-info/METADATA +0 -43
  259. synapse_sdk-1.0.0a11.dist-info/RECORD +0 -111
  260. {synapse_sdk-1.0.0a11.dist-info → synapse_sdk-2026.1.1b2.dist-info}/entry_points.txt +0 -0
  261. {synapse_sdk-1.0.0a11.dist-info → synapse_sdk-2026.1.1b2.dist-info}/top_level.txt +0 -0
@@ -0,0 +1,50 @@
1
+ """Plugin templates for synapse plugin create."""
2
+
3
+ from __future__ import annotations
4
+
5
+ from importlib.resources import files
6
+ from pathlib import Path
7
+
8
+
9
+ def _get_templates_dir() -> Path:
10
+ """Get the templates directory path.
11
+
12
+ Uses importlib.resources for reliable access to package data,
13
+ falling back to __file__ for editable installs.
14
+ """
15
+ try:
16
+ # Try importlib.resources first (works with installed packages)
17
+ package_files = files('synapse_sdk.plugins.templates')
18
+ # For filesystem-based packages, this will have a real path
19
+ # joinpath returns a Traversable that we can use
20
+ base = package_files / 'base'
21
+ # Check if config.yaml.j2 exists to verify path is valid
22
+ if (base / 'config.yaml.j2').is_file():
23
+ # Get the actual path - package_files should be a Path-like for installed packages
24
+ return Path(str(package_files))
25
+ except (TypeError, AttributeError, FileNotFoundError):
26
+ pass
27
+
28
+ # Fall back to __file__ for editable installs or if above fails
29
+ return Path(__file__).parent
30
+
31
+
32
+ # Cache the result to avoid repeated calls
33
+ TEMPLATES_DIR = _get_templates_dir()
34
+
35
+
36
+ def get_template_dir(category: str | None = None) -> Path:
37
+ """Get template directory for a category.
38
+
39
+ Args:
40
+ category: Plugin category. If None, returns base template directory.
41
+
42
+ Returns:
43
+ Path to template directory.
44
+ """
45
+ if category:
46
+ return TEMPLATES_DIR / category
47
+ return TEMPLATES_DIR / 'base'
48
+
49
+
50
+ __all__ = ['TEMPLATES_DIR', 'get_template_dir']
@@ -0,0 +1,26 @@
1
+ # Python
2
+ __pycache__/
3
+ *.py[cod]
4
+ *$py.class
5
+ *.so
6
+ .Python
7
+ .venv/
8
+ venv/
9
+ *.egg-info/
10
+ dist/
11
+ build/
12
+
13
+ # IDE
14
+ .idea/
15
+ .vscode/
16
+ *.swp
17
+ *.swo
18
+
19
+ # Testing
20
+ .pytest_cache/
21
+ .coverage
22
+ htmlcov/
23
+
24
+ # Misc
25
+ .DS_Store
26
+ *.log
@@ -0,0 +1,11 @@
1
+ # Files to exclude from plugin archive
2
+ .git
3
+ .venv
4
+ venv
5
+ __pycache__
6
+ *.pyc
7
+ .pytest_cache
8
+ .ruff_cache
9
+ *.egg-info
10
+ dist
11
+ build
@@ -0,0 +1,26 @@
1
+ # {{ name }}
2
+
3
+ {{ description }}
4
+
5
+ ## Category
6
+
7
+ {{ category }}
8
+
9
+ ## Installation
10
+
11
+ ```bash
12
+ uv sync
13
+ ```
14
+
15
+ ## Development
16
+
17
+ ```bash
18
+ # Run locally
19
+ synapse run <action_name>
20
+ ```
21
+
22
+ ## Publishing
23
+
24
+ ```bash
25
+ synapse plugin publish
26
+ ```
@@ -0,0 +1 @@
1
+ """{{ name }} plugin."""
@@ -0,0 +1,14 @@
1
+ [project]
2
+ name = "{{ code }}"
3
+ version = "{{ version }}"
4
+ description = "{{ description }}"
5
+ requires-python = ">=3.10"
6
+ dependencies = [
7
+ "synapse-sdk",
8
+ ]
9
+
10
+ [tool.uv]
11
+ dev-dependencies = [
12
+ "pytest>=8.0",
13
+ "ruff>=0.8",
14
+ ]
@@ -0,0 +1 @@
1
+ synapse-sdk
@@ -0,0 +1,18 @@
1
+ """Main action for {{ name }}."""
2
+
3
+ from __future__ import annotations
4
+
5
+ from typing import Any
6
+
7
+
8
+ def run(**kwargs: Any) -> Any:
9
+ """Run the plugin.
10
+
11
+ Args:
12
+ **kwargs: Plugin arguments.
13
+
14
+ Returns:
15
+ Plugin result.
16
+ """
17
+ # TODO: Implement your plugin logic here
18
+ return {'result': 'success'}
@@ -0,0 +1,32 @@
1
+ """Validation action for {{ name }}."""
2
+
3
+ from __future__ import annotations
4
+
5
+ from typing import Any
6
+
7
+
8
+ class Validator:
9
+ """Validator class for {{ name }}.
10
+
11
+ This class handles data validation before annotation.
12
+ """
13
+
14
+ def __init__(self, **kwargs: Any) -> None:
15
+ """Initialize the validator.
16
+
17
+ Args:
18
+ **kwargs: Configuration options.
19
+ """
20
+ self.strict_mode = kwargs.get('strict_mode', False)
21
+
22
+ def validate(self, data: Any) -> dict[str, Any]:
23
+ """Validate data.
24
+
25
+ Args:
26
+ data: Data to validate.
27
+
28
+ Returns:
29
+ Validation result with 'valid' bool and optional 'errors' list.
30
+ """
31
+ # TODO: Implement your validation logic here
32
+ return {'valid': True, 'errors': []}
@@ -0,0 +1,36 @@
1
+ """Export action for {{ name }}."""
2
+
3
+ from __future__ import annotations
4
+
5
+ from pathlib import Path
6
+ from typing import Any
7
+
8
+
9
+ class Exporter:
10
+ """Exporter class for {{ name }}.
11
+
12
+ This class handles data export to custom formats.
13
+ """
14
+
15
+ def __init__(self, output_path: str | Path, **kwargs: Any) -> None:
16
+ """Initialize the exporter.
17
+
18
+ Args:
19
+ output_path: Path to write exported data.
20
+ **kwargs: Additional configuration options.
21
+ """
22
+ self.output_path = Path(output_path)
23
+
24
+ def export(self, data: Any) -> Path:
25
+ """Export data to custom format.
26
+
27
+ Args:
28
+ data: Data to export.
29
+
30
+ Returns:
31
+ Path to exported file.
32
+ """
33
+ # TODO: Implement your export logic here
34
+ output_file = self.output_path / 'export.json'
35
+ output_file.write_text('{}')
36
+ return output_file
@@ -0,0 +1,36 @@
1
+ """Inference action for {{ name }}."""
2
+
3
+ from __future__ import annotations
4
+
5
+ from typing import Any
6
+
7
+
8
+ class Inference:
9
+ """Inference class for {{ name }}.
10
+
11
+ This class handles model loading and prediction.
12
+ """
13
+
14
+ def __init__(self, model_path: str | None = None, **kwargs: Any) -> None:
15
+ """Initialize the inference class.
16
+
17
+ Args:
18
+ model_path: Path to trained model weights.
19
+ **kwargs: Additional configuration options.
20
+ """
21
+ self.model_path = model_path
22
+ self.model = None
23
+ # TODO: Load your model here
24
+ # self.model = load_model(model_path)
25
+
26
+ def predict(self, data: Any) -> Any:
27
+ """Run prediction on input data.
28
+
29
+ Args:
30
+ data: Input data for prediction.
31
+
32
+ Returns:
33
+ Prediction results.
34
+ """
35
+ # TODO: Implement your prediction logic here
36
+ return {'result': 'prediction'}
@@ -0,0 +1,33 @@
1
+ """Training action for {{ name }}."""
2
+
3
+ from __future__ import annotations
4
+
5
+
6
+ def train(run, dataset, hyperparameter, checkpoint=None):
7
+ """Train the model.
8
+
9
+ Args:
10
+ run: Run context for logging metrics and progress.
11
+ dataset: Training dataset.
12
+ hyperparameter: Training hyperparameters.
13
+ checkpoint: Optional checkpoint to resume from.
14
+
15
+ Returns:
16
+ Path to saved model weights.
17
+ """
18
+ epochs = hyperparameter.get('epochs', 10)
19
+ batch_size = hyperparameter.get('batch_size', 32)
20
+ learning_rate = hyperparameter.get('learning_rate', 0.001)
21
+
22
+ run.set_progress(0, epochs, category='train')
23
+
24
+ for epoch in range(1, epochs + 1):
25
+ # TODO: Implement your training loop here
26
+ loss = 1.0 / epoch # Placeholder
27
+ accuracy = epoch / epochs # Placeholder
28
+
29
+ run.log_metric('epoch', epoch, loss=loss, accuracy=accuracy)
30
+ run.set_progress(epoch, epochs, category='train')
31
+
32
+ # Return path to saved model
33
+ return './'
@@ -0,0 +1,32 @@
1
+ """Post-annotation action for {{ name }}."""
2
+
3
+ from __future__ import annotations
4
+
5
+ from typing import Any
6
+
7
+
8
+ class PostAnnotator:
9
+ """Post-annotator class for {{ name }}.
10
+
11
+ This class handles post-processing after human annotation.
12
+ """
13
+
14
+ def __init__(self, **kwargs: Any) -> None:
15
+ """Initialize the post-annotator.
16
+
17
+ Args:
18
+ **kwargs: Configuration options.
19
+ """
20
+ self.auto_correct = kwargs.get('auto_correct', False)
21
+
22
+ def post_annotate(self, data: Any) -> dict[str, Any]:
23
+ """Process annotations.
24
+
25
+ Args:
26
+ data: Annotated data to process.
27
+
28
+ Returns:
29
+ Post-processing results.
30
+ """
31
+ # TODO: Implement your post-annotation logic here
32
+ return {'processed': True}
@@ -0,0 +1,32 @@
1
+ """Pre-annotation action for {{ name }}."""
2
+
3
+ from __future__ import annotations
4
+
5
+ from typing import Any
6
+
7
+
8
+ class PreAnnotator:
9
+ """Pre-annotator class for {{ name }}.
10
+
11
+ This class handles pre-annotation before human annotation.
12
+ """
13
+
14
+ def __init__(self, **kwargs: Any) -> None:
15
+ """Initialize the pre-annotator.
16
+
17
+ Args:
18
+ **kwargs: Configuration options.
19
+ """
20
+ self.auto_detect = kwargs.get('auto_detect', True)
21
+
22
+ def pre_annotate(self, data: Any) -> dict[str, Any]:
23
+ """Generate pre-annotations.
24
+
25
+ Args:
26
+ data: Data to pre-annotate.
27
+
28
+ Returns:
29
+ Pre-annotation results.
30
+ """
31
+ # TODO: Implement your pre-annotation logic here
32
+ return {'annotations': []}
@@ -0,0 +1,44 @@
1
+ """Auto-label action for {{ name }}."""
2
+
3
+ from __future__ import annotations
4
+
5
+ from typing import Any
6
+
7
+
8
+ class AutoLabel:
9
+ """Auto-label class for {{ name }}.
10
+
11
+ This class handles input/output transformation for smart tools.
12
+ """
13
+
14
+ def __init__(self, **kwargs: Any) -> None:
15
+ """Initialize the auto-label class.
16
+
17
+ Args:
18
+ **kwargs: Configuration options.
19
+ """
20
+ pass
21
+
22
+ def handle_input(self, input_data: Any) -> Any:
23
+ """Transform smart tool input to model input format.
24
+
25
+ Args:
26
+ input_data: Input data from smart tool.
27
+
28
+ Returns:
29
+ Transformed data for model.
30
+ """
31
+ # TODO: Transform input for your model
32
+ return input_data
33
+
34
+ def handle_output(self, output_data: Any) -> Any:
35
+ """Transform model output to smart tool output format.
36
+
37
+ Args:
38
+ output_data: Output data from model.
39
+
40
+ Returns:
41
+ Transformed data for smart tool.
42
+ """
43
+ # TODO: Transform output for smart tool
44
+ return output_data
@@ -0,0 +1,35 @@
1
+ """Upload action for {{ name }}."""
2
+
3
+ from __future__ import annotations
4
+
5
+ from pathlib import Path
6
+ from typing import Any, Iterator
7
+
8
+
9
+ class Uploader:
10
+ """Uploader class for {{ name }}.
11
+
12
+ This class handles data upload from external sources.
13
+ """
14
+
15
+ def __init__(self, source_path: str | Path, **kwargs: Any) -> None:
16
+ """Initialize the uploader.
17
+
18
+ Args:
19
+ source_path: Path to source data.
20
+ **kwargs: Additional configuration options.
21
+ """
22
+ self.source_path = Path(source_path)
23
+
24
+ def upload(self) -> Iterator[dict[str, Any]]:
25
+ """Upload data from source.
26
+
27
+ Yields:
28
+ Data items to upload.
29
+ """
30
+ # TODO: Implement your upload logic here
31
+ # Each yielded item should be a dict with file info
32
+ yield {
33
+ 'file': self.source_path / 'example.jpg',
34
+ 'metadata': {},
35
+ }
@@ -0,0 +1,25 @@
1
+ """Testing utilities for Synapse SDK plugins."""
2
+
3
+ from synapse_sdk.plugins.testing.sample_actions import (
4
+ ConvertAction,
5
+ DownloadAction,
6
+ Step1Params,
7
+ Step1Result,
8
+ Step2Params,
9
+ Step2Result,
10
+ Step3Params,
11
+ Step3Result,
12
+ TrainAction,
13
+ )
14
+
15
+ __all__ = [
16
+ 'Step1Params',
17
+ 'Step1Result',
18
+ 'Step2Params',
19
+ 'Step2Result',
20
+ 'Step3Params',
21
+ 'Step3Result',
22
+ 'DownloadAction',
23
+ 'ConvertAction',
24
+ 'TrainAction',
25
+ ]
@@ -0,0 +1,98 @@
1
+ """Sample actions for integration testing."""
2
+
3
+ import time
4
+
5
+ from pydantic import BaseModel
6
+
7
+ from synapse_sdk.plugins.action import BaseAction
8
+
9
+
10
+ # Sample parameter/result models
11
+ class Step1Params(BaseModel):
12
+ dataset_id: int
13
+
14
+
15
+ class Step1Result(BaseModel):
16
+ dataset_id: int
17
+ dataset_path: str
18
+
19
+
20
+ class Step2Params(BaseModel):
21
+ dataset_path: str
22
+
23
+
24
+ class Step2Result(BaseModel):
25
+ dataset_path: str
26
+ converted_path: str
27
+
28
+
29
+ class Step3Params(BaseModel):
30
+ converted_path: str
31
+ epochs: int = 5
32
+
33
+
34
+ class Step3Result(BaseModel):
35
+ model_path: str
36
+ metrics: dict[str, float]
37
+
38
+
39
+ # Sample actions
40
+ class DownloadAction(BaseAction[Step1Params]):
41
+ """Simulates downloading a dataset."""
42
+
43
+ action_name = 'download'
44
+ params_model = Step1Params
45
+ result_model = Step1Result
46
+
47
+ def execute(self) -> Step1Result:
48
+ self.ctx.logger.info(f'Downloading dataset {self.params.dataset_id}...')
49
+ time.sleep(1) # Simulate work
50
+ return Step1Result(
51
+ dataset_id=self.params.dataset_id,
52
+ dataset_path=f'/tmp/datasets/{self.params.dataset_id}',
53
+ )
54
+
55
+
56
+ class ConvertAction(BaseAction[Step2Params]):
57
+ """Simulates converting a dataset."""
58
+
59
+ action_name = 'convert'
60
+ params_model = Step2Params
61
+ result_model = Step2Result
62
+
63
+ def execute(self) -> Step2Result:
64
+ self.ctx.logger.info(f'Converting dataset at {self.params.dataset_path}...')
65
+ time.sleep(1) # Simulate work
66
+ return Step2Result(
67
+ dataset_path=self.params.dataset_path,
68
+ converted_path=f'{self.params.dataset_path}/yolo',
69
+ )
70
+
71
+
72
+ class TrainAction(BaseAction[Step3Params]):
73
+ """Simulates training a model."""
74
+
75
+ action_name = 'train'
76
+ params_model = Step3Params
77
+ result_model = Step3Result
78
+
79
+ def execute(self) -> Step3Result:
80
+ self.ctx.logger.info(f'Training on {self.params.converted_path} for {self.params.epochs} epochs...')
81
+ time.sleep(2) # Simulate work
82
+ return Step3Result(
83
+ model_path='/tmp/models/best.pt',
84
+ metrics={'mAP50': 0.85, 'mAP50-95': 0.72},
85
+ )
86
+
87
+
88
+ __all__ = [
89
+ 'Step1Params',
90
+ 'Step1Result',
91
+ 'Step2Params',
92
+ 'Step2Result',
93
+ 'Step3Params',
94
+ 'Step3Result',
95
+ 'DownloadAction',
96
+ 'ConvertAction',
97
+ 'TrainAction',
98
+ ]