synapse-sdk 1.0.0a0__tar.gz → 1.0.0a1__tar.gz

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 (77) hide show
  1. {synapse_sdk-1.0.0a0 → synapse_sdk-1.0.0a1}/PKG-INFO +2 -1
  2. {synapse_sdk-1.0.0a0 → synapse_sdk-1.0.0a1}/pyproject.toml +1 -0
  3. {synapse_sdk-1.0.0a0 → synapse_sdk-1.0.0a1}/requirements.txt +1 -0
  4. {synapse_sdk-1.0.0a0/synapse → synapse_sdk-1.0.0a1/synapse_sdk}/client/__init__.py +6 -6
  5. synapse_sdk-1.0.0a1/synapse_sdk/client/mixins/integration.py +29 -0
  6. {synapse_sdk-1.0.0a0/synapse → synapse_sdk-1.0.0a1/synapse_sdk}/loggers.py +1 -1
  7. synapse_sdk-1.0.0a1/synapse_sdk/plugins/__init__.py +13 -0
  8. {synapse_sdk-1.0.0a0/synapse → synapse_sdk-1.0.0a1/synapse_sdk}/plugins/categories/base.py +21 -28
  9. synapse_sdk-1.0.0a1/synapse_sdk/plugins/categories/data_validation/actions/validation.py +10 -0
  10. {synapse_sdk-1.0.0a0/synapse → synapse_sdk-1.0.0a1/synapse_sdk}/plugins/categories/decorators.py +2 -2
  11. synapse_sdk-1.0.0a1/synapse_sdk/plugins/categories/export/actions/export.py +10 -0
  12. synapse_sdk-1.0.0a1/synapse_sdk/plugins/categories/import/actions/import.py +10 -0
  13. {synapse_sdk-1.0.0a0/synapse → synapse_sdk-1.0.0a1/synapse_sdk}/plugins/categories/neural_net/actions/deployment.py +3 -3
  14. synapse_sdk-1.0.0a1/synapse_sdk/plugins/categories/neural_net/actions/inference.py +10 -0
  15. synapse_sdk-1.0.0a1/synapse_sdk/plugins/categories/neural_net/actions/test.py +10 -0
  16. {synapse_sdk-1.0.0a0/synapse → synapse_sdk-1.0.0a1/synapse_sdk}/plugins/categories/neural_net/actions/train.py +5 -5
  17. synapse_sdk-1.0.0a1/synapse_sdk/plugins/categories/post_annotation/actions/post_annotation.py +10 -0
  18. synapse_sdk-1.0.0a1/synapse_sdk/plugins/categories/pre_annotation/actions/pre_annotation.py +10 -0
  19. {synapse_sdk-1.0.0a0/synapse → synapse_sdk-1.0.0a1/synapse_sdk}/plugins/categories/registry.py +2 -2
  20. synapse_sdk-1.0.0a1/synapse_sdk/plugins/cli/__init__.py +19 -0
  21. synapse_sdk-1.0.0a1/synapse_sdk/plugins/cli/publish.py +24 -0
  22. synapse_sdk-1.0.0a1/synapse_sdk/plugins/cli/run.py +18 -0
  23. synapse_sdk-1.0.0a1/synapse_sdk/plugins/upload.py +72 -0
  24. {synapse_sdk-1.0.0a0/synapse → synapse_sdk-1.0.0a1/synapse_sdk}/plugins/utils.py +8 -4
  25. {synapse_sdk-1.0.0a0/synapse → synapse_sdk-1.0.0a1/synapse_sdk}/utils/file.py +13 -1
  26. synapse_sdk-1.0.0a1/synapse_sdk/utils/storage.py +92 -0
  27. {synapse_sdk-1.0.0a0/synapse → synapse_sdk-1.0.0a1/synapse_sdk}/utils/string.py +4 -0
  28. {synapse_sdk-1.0.0a0 → synapse_sdk-1.0.0a1}/synapse_sdk.egg-info/PKG-INFO +2 -1
  29. synapse_sdk-1.0.0a1/synapse_sdk.egg-info/SOURCES.txt +63 -0
  30. {synapse_sdk-1.0.0a0 → synapse_sdk-1.0.0a1}/synapse_sdk.egg-info/requires.txt +1 -0
  31. synapse_sdk-1.0.0a1/synapse_sdk.egg-info/top_level.txt +1 -0
  32. synapse_sdk-1.0.0a0/synapse/client/mixins/integration.py +0 -12
  33. synapse_sdk-1.0.0a0/synapse/plugins/__init__.py +0 -39
  34. synapse_sdk-1.0.0a0/synapse/plugins/categories/data_validation/actions/validation.py +0 -10
  35. synapse_sdk-1.0.0a0/synapse/plugins/categories/export/actions/export.py +0 -10
  36. synapse_sdk-1.0.0a0/synapse/plugins/categories/import/actions/import.py +0 -10
  37. synapse_sdk-1.0.0a0/synapse/plugins/categories/neural_net/actions/inference.py +0 -10
  38. synapse_sdk-1.0.0a0/synapse/plugins/categories/neural_net/actions/test.py +0 -10
  39. synapse_sdk-1.0.0a0/synapse/plugins/categories/post_annotation/actions/post_annotation.py +0 -10
  40. synapse_sdk-1.0.0a0/synapse/plugins/categories/pre_annotation/actions/pre_annotation.py +0 -10
  41. synapse_sdk-1.0.0a0/synapse/plugins/upload.py +0 -79
  42. synapse_sdk-1.0.0a0/synapse_sdk.egg-info/SOURCES.txt +0 -59
  43. synapse_sdk-1.0.0a0/synapse_sdk.egg-info/top_level.txt +0 -1
  44. {synapse_sdk-1.0.0a0 → synapse_sdk-1.0.0a1}/.github/workflows/lint.yml +0 -0
  45. {synapse_sdk-1.0.0a0 → synapse_sdk-1.0.0a1}/.github/workflows/pypi-publish.yml +0 -0
  46. {synapse_sdk-1.0.0a0 → synapse_sdk-1.0.0a1}/.gitignore +0 -0
  47. {synapse_sdk-1.0.0a0 → synapse_sdk-1.0.0a1}/.pre-commit-config.yaml +0 -0
  48. {synapse_sdk-1.0.0a0 → synapse_sdk-1.0.0a1}/LICENSE +0 -0
  49. {synapse_sdk-1.0.0a0 → synapse_sdk-1.0.0a1}/README.md +0 -0
  50. {synapse_sdk-1.0.0a0 → synapse_sdk-1.0.0a1}/setup.cfg +0 -0
  51. {synapse_sdk-1.0.0a0/synapse → synapse_sdk-1.0.0a1/synapse_sdk}/__init__.py +0 -0
  52. {synapse_sdk-1.0.0a0/synapse → synapse_sdk-1.0.0a1/synapse_sdk}/client/exceptions.py +0 -0
  53. {synapse_sdk-1.0.0a0/synapse → synapse_sdk-1.0.0a1/synapse_sdk}/client/mixins/__init__.py +0 -0
  54. {synapse_sdk-1.0.0a0/synapse → synapse_sdk-1.0.0a1/synapse_sdk}/client/mixins/annotation.py +0 -0
  55. {synapse_sdk-1.0.0a0/synapse → synapse_sdk-1.0.0a1/synapse_sdk}/client/mixins/dataset.py +0 -0
  56. {synapse_sdk-1.0.0a0/synapse → synapse_sdk-1.0.0a1/synapse_sdk}/client/mixins/ml.py +0 -0
  57. {synapse_sdk-1.0.0a0/synapse → synapse_sdk-1.0.0a1/synapse_sdk}/client/utils.py +0 -0
  58. {synapse_sdk-1.0.0a0/synapse → synapse_sdk-1.0.0a1/synapse_sdk}/config.py +0 -0
  59. {synapse_sdk-1.0.0a0/synapse → synapse_sdk-1.0.0a1/synapse_sdk}/plugins/categories/__init__.py +0 -0
  60. {synapse_sdk-1.0.0a0/synapse → synapse_sdk-1.0.0a1/synapse_sdk}/plugins/categories/data_validation/__init__.py +0 -0
  61. {synapse_sdk-1.0.0a0/synapse → synapse_sdk-1.0.0a1/synapse_sdk}/plugins/categories/data_validation/actions/__init__.py +0 -0
  62. {synapse_sdk-1.0.0a0/synapse → synapse_sdk-1.0.0a1/synapse_sdk}/plugins/categories/export/__init__.py +0 -0
  63. {synapse_sdk-1.0.0a0/synapse → synapse_sdk-1.0.0a1/synapse_sdk}/plugins/categories/export/actions/__init__.py +0 -0
  64. {synapse_sdk-1.0.0a0/synapse → synapse_sdk-1.0.0a1/synapse_sdk}/plugins/categories/import/__init__.py +0 -0
  65. {synapse_sdk-1.0.0a0/synapse → synapse_sdk-1.0.0a1/synapse_sdk}/plugins/categories/import/actions/__init__.py +0 -0
  66. {synapse_sdk-1.0.0a0/synapse → synapse_sdk-1.0.0a1/synapse_sdk}/plugins/categories/neural_net/__init__.py +0 -0
  67. {synapse_sdk-1.0.0a0/synapse → synapse_sdk-1.0.0a1/synapse_sdk}/plugins/categories/neural_net/actions/__init__.py +0 -0
  68. {synapse_sdk-1.0.0a0/synapse → synapse_sdk-1.0.0a1/synapse_sdk}/plugins/categories/post_annotation/__init__.py +0 -0
  69. {synapse_sdk-1.0.0a0/synapse → synapse_sdk-1.0.0a1/synapse_sdk}/plugins/categories/post_annotation/actions/__init__.py +0 -0
  70. {synapse_sdk-1.0.0a0/synapse → synapse_sdk-1.0.0a1/synapse_sdk}/plugins/categories/pre_annotation/__init__.py +0 -0
  71. {synapse_sdk-1.0.0a0/synapse → synapse_sdk-1.0.0a1/synapse_sdk}/plugins/categories/pre_annotation/actions/__init__.py +0 -0
  72. {synapse_sdk-1.0.0a0/synapse → synapse_sdk-1.0.0a1/synapse_sdk}/plugins/enums.py +0 -0
  73. {synapse_sdk-1.0.0a0/synapse → synapse_sdk-1.0.0a1/synapse_sdk}/plugins/job.py +0 -0
  74. {synapse_sdk-1.0.0a0/synapse → synapse_sdk-1.0.0a1/synapse_sdk}/utils/__init__.py +0 -0
  75. {synapse_sdk-1.0.0a0/synapse → synapse_sdk-1.0.0a1/synapse_sdk}/utils/debug.py +0 -0
  76. {synapse_sdk-1.0.0a0/synapse → synapse_sdk-1.0.0a1/synapse_sdk}/utils/module_loading.py +0 -0
  77. {synapse_sdk-1.0.0a0 → synapse_sdk-1.0.0a1}/synapse_sdk.egg-info/dependency_links.txt +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: synapse-sdk
3
- Version: 1.0.0a0
3
+ Version: 1.0.0a1
4
4
  Summary: synapse sdk
5
5
  Author-email: datamaker <developer@datamaker.io>
6
6
  License: MIT
@@ -9,6 +9,7 @@ Requires-Python: >=3.11
9
9
  Description-Content-Type: text/markdown
10
10
  License-File: LICENSE
11
11
  Requires-Dist: boto3
12
+ Requires-Dist: click
12
13
  Requires-Dist: requests
13
14
  Requires-Dist: tqdm
14
15
  Requires-Dist: python-dotenv
@@ -14,6 +14,7 @@ classifiers = [
14
14
  ]
15
15
  dependencies = [
16
16
  'boto3',
17
+ 'click',
17
18
  'requests',
18
19
  'tqdm',
19
20
  'python-dotenv',
@@ -1,4 +1,5 @@
1
1
  boto3
2
+ click
2
3
  requests
3
4
  tqdm
4
5
  pyyaml
@@ -15,13 +15,13 @@ from ..utils.file import files_url_to_path_from_objs
15
15
  class Client(AnnotationClientMixin, DatasetClientMixin, IntegrationClientMixin, MLClientMixin):
16
16
  base_url = None
17
17
  token = None
18
- workspace_code = None
18
+ tenant = None
19
19
 
20
- def __init__(self, base_url, token, workspace_code=None):
20
+ def __init__(self, base_url, token, tenant=None):
21
21
  self.base_url = base_url
22
22
  self.token = token
23
- if workspace_code:
24
- self.workspace_code = workspace_code
23
+ if tenant:
24
+ self.tenant = tenant
25
25
  requests_session = requests.Session()
26
26
  self.requests_session = requests_session
27
27
 
@@ -32,8 +32,8 @@ class Client(AnnotationClientMixin, DatasetClientMixin, IntegrationClientMixin,
32
32
 
33
33
  def _get_headers(self):
34
34
  headers = {'Authorization': f'Token {self.token}'}
35
- if self.workspace_code:
36
- headers['DATAMAKER-Workspace'] = f'Token {self.workspace_code}'
35
+ if self.tenant:
36
+ headers['SYNAPSE-Tenant'] = f'Token {self.tenant}'
37
37
  return headers
38
38
 
39
39
  def _request(self, method, path, **kwargs):
@@ -0,0 +1,29 @@
1
+ class IntegrationClientMixin:
2
+ def get_plugin(self, pk):
3
+ path = f'plugins/{pk}/'
4
+ return self._get(path)
5
+
6
+ def create_plugin(self, data):
7
+ path = 'plugins/'
8
+ return self._post(path, payload=data)
9
+
10
+ def update_plugin(self, pk, data):
11
+ path = f'plugins/{pk}/'
12
+ return self._put(path, payload=data)
13
+
14
+ def get_plugin_release(self, pk, params=None):
15
+ path = f'plugin_releases/{pk}/'
16
+ return self._get(path, payload=params)
17
+
18
+ def create_plugin_release(self, data):
19
+ path = 'plugin_releases/'
20
+ files = {'file': data.pop('file')}
21
+ return self._post(path, payload=data, files=files)
22
+
23
+ def create_logs(self, data):
24
+ path = 'logs/'
25
+ return self._post(path, payload=data)
26
+
27
+ def create_task(self, data):
28
+ path = 'agent_tasks/'
29
+ return self._post(path, payload=data)
@@ -1,6 +1,6 @@
1
1
  import datetime
2
2
 
3
- from synapse.client import ClientError
3
+ from synapse_sdk.client import ClientError
4
4
 
5
5
 
6
6
  class BaseLogger:
@@ -0,0 +1,13 @@
1
+ import os
2
+
3
+ from dotenv import load_dotenv
4
+
5
+ from synapse_sdk.plugins.cli import cli
6
+
7
+
8
+ def init():
9
+ load_dotenv(os.path.join(os.getcwd(), '.env'))
10
+ cli(obj={}, auto_envvar_prefix='SYNAPSE_PLUGIN')
11
+
12
+
13
+ __all__ = ['init']
@@ -8,11 +8,11 @@ import ray
8
8
  import requests
9
9
  from ray.dashboard.modules.job.sdk import JobSubmissionClient
10
10
 
11
- from synapse.loggers import ConsoleLogger
12
- from synapse.plugins.enums import RunMethod
13
- from synapse.plugins.upload import upload_path, build_and_upload
14
- from synapse.plugins.utils import get_plugin_checksum
15
- from synapse.utils.module_loading import import_string
11
+ from synapse_sdk.loggers import ConsoleLogger
12
+ from synapse_sdk.plugins.enums import RunMethod
13
+ from synapse_sdk.plugins.upload import build_and_upload, archive_and_upload
14
+ from synapse_sdk.plugins.utils import get_plugin_checksum
15
+ from synapse_sdk.utils.module_loading import import_string
16
16
 
17
17
 
18
18
  class Action:
@@ -27,15 +27,12 @@ class Action:
27
27
  debug = False
28
28
 
29
29
  default_envs = [
30
+ 'RAY_DASHBOARD_URL',
30
31
  'RAY_SERVE_ADDRESS',
31
32
  'SYNAPSE_PLUGIN_URL',
32
33
  'SYNAPSE_PLUGIN_PATH',
33
34
  'SYNAPSE_PLUGIN_BASE_URL',
34
- 'SYNAPSE_PLUGIN_UPLOAD_S3_ENDPOINT_URL',
35
- 'SYNAPSE_PLUGIN_UPLOAD_S3_BUCKET_NAME',
36
- 'SYNAPSE_PLUGIN_UPLOAD_S3_ACCESS_KEY',
37
- 'SYNAPSE_PLUGIN_UPLOAD_S3_SECRET_KEY',
38
- 'SYNAPSE_PLUGIN_UPLOAD_S3_BASE_URL',
35
+ 'SYNAPSE_PLUGIN_STORAGE',
39
36
  'SYNAPSE_DEBUG_MODULES',
40
37
  ]
41
38
 
@@ -69,7 +66,10 @@ class Action:
69
66
  if self.debug:
70
67
  plugin_url = self.envs.get('SYNAPSE_PLUGIN_URL')
71
68
  if not plugin_url:
72
- plugin_url = upload_path(self.envs.get('SYNAPSE_PLUGIN_PATH', '.'), **self.get_kwargs_upload_path())
69
+ plugin_url = archive_and_upload(
70
+ self.envs.get('SYNAPSE_PLUGIN_PATH', '.'),
71
+ self.envs['SYNAPSE_PLUGIN_STORAGE'],
72
+ )
73
73
  self.envs['SYNAPSE_PLUGIN_URL'] = plugin_url
74
74
  return plugin_url
75
75
  base_url = self.envs['SYNAPSE_PLUGIN_BASE_URL']
@@ -79,16 +79,6 @@ class Action:
79
79
  def entrypoint(self):
80
80
  return import_string(self.config['entrypoint'])
81
81
 
82
- def get_kwargs_upload_path(self):
83
- # TODO upload 관련 env 단일화 후 제거
84
- return {
85
- 'endpoint_url': self.envs['SYNAPSE_PLUGIN_UPLOAD_S3_ENDPOINT_URL'],
86
- 'bucket_name': self.envs['SYNAPSE_PLUGIN_UPLOAD_S3_BUCKET_NAME'],
87
- 'access_key': self.envs['SYNAPSE_PLUGIN_UPLOAD_S3_ACCESS_KEY'],
88
- 'secret_key': self.envs['SYNAPSE_PLUGIN_UPLOAD_S3_SECRET_KEY'],
89
- 'base_url': self.envs['SYNAPSE_PLUGIN_UPLOAD_S3_BASE_URL'],
90
- }
91
-
92
82
  def get_default_envs(self):
93
83
  return {env: os.environ[env] for env in self.default_envs if env in os.environ}
94
84
 
@@ -98,7 +88,7 @@ class Action:
98
88
  if module_path.startswith('http'):
99
89
  module_url = module_path
100
90
  else:
101
- module_url = build_and_upload(module_path, **self.get_kwargs_upload_path())
91
+ module_url = build_and_upload(module_path, self.envs['SYNAPSE_PLUGIN_STORAGE'])
102
92
  debug_modules.append(module_url)
103
93
  self.envs['SYNAPSE_DEBUG_MODULES'] = ','.join(debug_modules)
104
94
  return debug_modules
@@ -112,8 +102,11 @@ class Action:
112
102
  if self.debug:
113
103
  runtime_env['pip'] += self.get_debug_modules()
114
104
 
105
+ # 맨 마지막에 진행되어야 함
115
106
  runtime_env['env_vars'] = self.envs
116
- pprint(runtime_env)
107
+
108
+ if self.debug:
109
+ pprint(runtime_env)
117
110
  return runtime_env
118
111
 
119
112
  def run(self):
@@ -130,7 +123,7 @@ class Action:
130
123
  def run_by_task(self):
131
124
  @ray.remote(runtime_env=self.get_runtime_env())
132
125
  def run_task(category, action, *args, **kwargs):
133
- from synapse.plugins.utils import get_action_class
126
+ from synapse_sdk.plugins.utils import get_action_class
134
127
 
135
128
  action = get_action_class(category, action)(*args, **kwargs)
136
129
  return action.run_action()
@@ -152,14 +145,14 @@ class Action:
152
145
  return ray.get(run_task.remote(self.category.value, self.name, *args, **kwargs))
153
146
 
154
147
  def run_by_job(self):
155
- entrypoint_args = [self.name, f'"{json.dumps(self.params)}"']
148
+ entrypoint_args = ['run', self.name, f'"{json.dumps(self.params)}"', '--direct']
156
149
  if self.debug:
157
- entrypoint_args.append('--debug')
150
+ entrypoint_args.insert(0, '--debug')
158
151
 
159
- client = JobSubmissionClient()
152
+ client = JobSubmissionClient(address=self.envs.get('RAY_DASHBOARD_URL'))
160
153
  return client.submit_job(
161
154
  submission_id=self.job_id,
162
- entrypoint=f'python main.py {" ".join(entrypoint_args)} --direct',
155
+ entrypoint=f'python main.py {" ".join(entrypoint_args)}',
163
156
  runtime_env=self.get_runtime_env(),
164
157
  )
165
158
 
@@ -0,0 +1,10 @@
1
+ from synapse_sdk.plugins.categories.base import Action
2
+ from synapse_sdk.plugins.categories.decorators import register_action
3
+ from synapse_sdk.plugins.enums import RunMethod, PluginCategory
4
+
5
+
6
+ @register_action
7
+ class ValidationAction(Action):
8
+ name = 'validation'
9
+ category = PluginCategory.DATA_VALIDATION
10
+ method = RunMethod.TASK
@@ -1,5 +1,5 @@
1
- from synapse.plugins.categories.base import Action
2
- from synapse.plugins.categories.registry import _REGISTERED_ACTIONS
1
+ from synapse_sdk.plugins.categories.base import Action
2
+ from synapse_sdk.plugins.categories.registry import _REGISTERED_ACTIONS
3
3
 
4
4
 
5
5
  def register_action(action_class):
@@ -0,0 +1,10 @@
1
+ from synapse_sdk.plugins.categories.base import Action
2
+ from synapse_sdk.plugins.categories.decorators import register_action
3
+ from synapse_sdk.plugins.enums import RunMethod, PluginCategory
4
+
5
+
6
+ @register_action
7
+ class ExportAction(Action):
8
+ name = 'export'
9
+ category = PluginCategory.EXPORT
10
+ method = RunMethod.JOB
@@ -0,0 +1,10 @@
1
+ from synapse_sdk.plugins.categories.base import Action
2
+ from synapse_sdk.plugins.categories.decorators import register_action
3
+ from synapse_sdk.plugins.enums import RunMethod, PluginCategory
4
+
5
+
6
+ @register_action
7
+ class ImportAction(Action):
8
+ name = 'import'
9
+ category = PluginCategory.IMPORT
10
+ method = RunMethod.JOB
@@ -1,8 +1,8 @@
1
1
  from ray import serve
2
2
 
3
- from synapse.plugins.categories.base import Action
4
- from synapse.plugins.categories.decorators import register_action
5
- from synapse.plugins.enums import PluginCategory, RunMethod
3
+ from synapse_sdk.plugins.categories.base import Action
4
+ from synapse_sdk.plugins.categories.decorators import register_action
5
+ from synapse_sdk.plugins.enums import PluginCategory, RunMethod
6
6
 
7
7
 
8
8
  @register_action
@@ -0,0 +1,10 @@
1
+ from synapse_sdk.plugins.categories.base import Action
2
+ from synapse_sdk.plugins.categories.decorators import register_action
3
+ from synapse_sdk.plugins.enums import RunMethod, PluginCategory
4
+
5
+
6
+ @register_action
7
+ class InferenceAction(Action):
8
+ name = 'inference'
9
+ category = PluginCategory.NEURAL_NET
10
+ method = RunMethod.RESTAPI
@@ -0,0 +1,10 @@
1
+ from synapse_sdk.plugins.categories.base import Action
2
+ from synapse_sdk.plugins.categories.decorators import register_action
3
+ from synapse_sdk.plugins.enums import RunMethod, PluginCategory
4
+
5
+
6
+ @register_action
7
+ class TestAction(Action):
8
+ name = 'test'
9
+ category = PluginCategory.NEURAL_NET
10
+ method = RunMethod.TASK
@@ -1,8 +1,8 @@
1
- from synapse.plugins.categories.base import Action
2
- from synapse.plugins.categories.decorators import register_action
3
- from synapse.plugins.enums import RunMethod, PluginCategory
4
- from synapse.utils.file import get_dict_from_file, files_url_to_path_from_objs
5
- from synapse.utils.module_loading import import_string
1
+ from synapse_sdk.plugins.categories.base import Action
2
+ from synapse_sdk.plugins.categories.decorators import register_action
3
+ from synapse_sdk.plugins.enums import RunMethod, PluginCategory
4
+ from synapse_sdk.utils.file import get_dict_from_file, files_url_to_path_from_objs
5
+ from synapse_sdk.utils.module_loading import import_string
6
6
 
7
7
 
8
8
  @register_action
@@ -0,0 +1,10 @@
1
+ from synapse_sdk.plugins.categories.base import Action
2
+ from synapse_sdk.plugins.categories.decorators import register_action
3
+ from synapse_sdk.plugins.enums import RunMethod, PluginCategory
4
+
5
+
6
+ @register_action
7
+ class PostAnnotationAction(Action):
8
+ name = 'post_annotation'
9
+ category = PluginCategory.POST_ANNOTATION
10
+ method = RunMethod.TASK
@@ -0,0 +1,10 @@
1
+ from synapse_sdk.plugins.categories.base import Action
2
+ from synapse_sdk.plugins.categories.decorators import register_action
3
+ from synapse_sdk.plugins.enums import RunMethod, PluginCategory
4
+
5
+
6
+ @register_action
7
+ class PreAnnotationAction(Action):
8
+ name = 'pre_annotation'
9
+ category = PluginCategory.PRE_ANNOTATION
10
+ method = RunMethod.TASK
@@ -1,7 +1,7 @@
1
1
  import pkgutil
2
2
  from importlib import import_module
3
3
 
4
- from synapse.plugins.enums import PluginCategory
4
+ from synapse_sdk.plugins.enums import PluginCategory
5
5
 
6
6
  _REGISTERED_ACTIONS = {}
7
7
 
@@ -9,7 +9,7 @@ _REGISTERED_ACTIONS = {}
9
9
  def register_actions():
10
10
  if not _REGISTERED_ACTIONS:
11
11
  for category in PluginCategory:
12
- plugin_category_module_name = f'synapse.plugins.categories.{category.value}.actions'
12
+ plugin_category_module_name = f'synapse_sdk.plugins.categories.{category.value}.actions'
13
13
  plugin_category_module = import_module(plugin_category_module_name)
14
14
  for _, action_name, _ in pkgutil.iter_modules(plugin_category_module.__path__):
15
15
  action_module_name = f'{plugin_category_module_name}.{action_name}'
@@ -0,0 +1,19 @@
1
+ import click
2
+
3
+ from .publish import publish
4
+ from .run import run
5
+
6
+
7
+ @click.group()
8
+ @click.option('--debug/--no-debug', default=False)
9
+ @click.pass_context
10
+ def cli(ctx, debug):
11
+ ctx.ensure_object(dict)
12
+ ctx.obj['DEBUG'] = debug
13
+
14
+ if debug:
15
+ click.echo('Debug mode is "on"')
16
+
17
+
18
+ cli.add_command(run)
19
+ cli.add_command(publish)
@@ -0,0 +1,24 @@
1
+ from pathlib import Path
2
+
3
+ import click
4
+
5
+ from synapse_sdk.client import Client
6
+ from synapse_sdk.plugins.utils import read_config
7
+
8
+ from ..upload import archive
9
+
10
+
11
+ @click.command()
12
+ @click.option('-h', '--host', required=True)
13
+ @click.option('-t', '--token', required=True)
14
+ @click.option('-w', '--workspace', required=True)
15
+ def publish(host, token, workspace):
16
+ client = Client(host, token, tenant=workspace)
17
+ config = read_config()
18
+
19
+ source_path = Path('./')
20
+ archive_path = source_path / 'dist' / 'archive.zip'
21
+ archive(source_path, archive_path)
22
+
23
+ data = {'plugin': config['code'], 'file': str(archive_path)}
24
+ client.create_plugin_release(data)
@@ -0,0 +1,18 @@
1
+ import click
2
+
3
+ from synapse_sdk.plugins.utils import get_action
4
+
5
+
6
+ @click.command()
7
+ @click.argument('action')
8
+ @click.argument('params')
9
+ @click.option('--direct/--no-direct', default=False)
10
+ @click.pass_context
11
+ def run(ctx, action, params, direct):
12
+ debug = ctx.obj['DEBUG']
13
+
14
+ action = get_action(action, params, direct=direct, debug=debug)
15
+ result = action.run_action()
16
+
17
+ if debug:
18
+ click.echo(result)
@@ -0,0 +1,72 @@
1
+ import re
2
+ import subprocess
3
+ from pathlib import Path
4
+
5
+ from synapse_sdk.utils.file import calculate_checksum
6
+ from synapse_sdk.utils.storage import get_storage
7
+
8
+
9
+ def archive(source_path, archive_path):
10
+ archive_path.parent.mkdir(parents=True, exist_ok=True)
11
+ command = f'git ls-files --others --exclude-standard --cached | zip -q --names-stdin {archive_path}'
12
+ subprocess.run(command, cwd=source_path, shell=True, check=True, stdout=subprocess.DEVNULL)
13
+
14
+
15
+ def archive_and_upload(source_path, url):
16
+ storage = get_storage(url)
17
+ dist_path = Path(source_path, 'dist')
18
+ archive_path = dist_path / 'archive.zip'
19
+
20
+ archive(source_path, archive_path)
21
+ checksum = calculate_checksum(archive_path, prefix='dev')
22
+ checksum_archive_path = dist_path / f'{checksum}.zip'
23
+
24
+ if checksum_archive_path.exists():
25
+ # TODO 실제 스토리지 있는지 확인
26
+ return storage.get_url(checksum_archive_path.name)
27
+
28
+ archive_path.rename(checksum_archive_path)
29
+ for file_path in dist_path.glob('*.zip'):
30
+ if file_path.name != checksum_archive_path.name:
31
+ file_path.unlink()
32
+ return storage.upload(str(checksum_archive_path), checksum_archive_path.name)
33
+
34
+
35
+ def build_and_upload(source_path, url, virtualenv_path='.venv'):
36
+ storage = get_storage(url)
37
+ dist_path = Path(source_path, 'dist')
38
+ archive_path = dist_path / 'archive.zip'
39
+
40
+ archive(source_path, archive_path)
41
+ checksum = calculate_checksum(archive_path, prefix='dev')
42
+ checksum_archive_path = dist_path / f'{checksum}.zip'
43
+
44
+ if checksum_archive_path.exists():
45
+ # TODO 실제 스토리지 있는지 확인
46
+ wheel_path = next(dist_path.glob('*.whl'), None)
47
+ return storage.get_url(wheel_path.name)
48
+
49
+ # wheel file 빌드 진행
50
+ for file_path in dist_path.glob('*.whl'):
51
+ file_path.unlink()
52
+
53
+ print(f'Building {Path(source_path).name}...')
54
+ subprocess.run(
55
+ f'{virtualenv_path}/bin/python -m build --wheel',
56
+ cwd=source_path,
57
+ shell=True,
58
+ check=True,
59
+ stdout=subprocess.DEVNULL,
60
+ )
61
+ wheel_path = next(dist_path.glob('*.whl'), None)
62
+
63
+ archive_path.rename(checksum_archive_path)
64
+ for file_path in dist_path.glob('*.zip'):
65
+ if file_path.name != checksum_archive_path.name:
66
+ file_path.unlink()
67
+ return storage.upload(str(wheel_path), wheel_path.name)
68
+
69
+
70
+ def change_whl_version(whl_name, new_version):
71
+ pattern = r'^(?P<distribution>.+?)-(?P<version>[\d\.\w]+(\+[\w\.]+)?)(?P<rest>-.+\.whl)$'
72
+ return re.sub(pattern, rf'\g<distribution>-{new_version}\g<rest>', whl_name)
@@ -1,8 +1,8 @@
1
1
  import json
2
2
 
3
- from synapse.plugins.categories.registry import _REGISTERED_ACTIONS, register_actions
4
- from synapse.utils.file import get_dict_from_file
5
- from synapse.utils.string import hash_text
3
+ from synapse_sdk.plugins.categories.registry import _REGISTERED_ACTIONS, register_actions
4
+ from synapse_sdk.utils.file import get_dict_from_file
5
+ from synapse_sdk.utils.string import hash_text
6
6
 
7
7
 
8
8
  def get_action(action, params_data, *args, **kwargs):
@@ -21,7 +21,7 @@ def get_action(action, params_data, *args, **kwargs):
21
21
  else:
22
22
  config = config_data
23
23
  else:
24
- config = get_dict_from_file('config.yaml')
24
+ config = read_config()
25
25
  category = config['category']
26
26
  return get_action_class(category, action)(params, config, *args, **kwargs)
27
27
 
@@ -38,3 +38,7 @@ def get_available_actions(category):
38
38
 
39
39
  def get_plugin_checksum(plugin_id):
40
40
  return hash_text(plugin_id)
41
+
42
+
43
+ def read_config():
44
+ return get_dict_from_file('config.yaml')
@@ -1,3 +1,4 @@
1
+ import hashlib
1
2
  import json
2
3
  import operator
3
4
  from functools import reduce
@@ -13,7 +14,7 @@ def download_file(url, path_download, name=None, coerce=None):
13
14
  else:
14
15
  name = Path(url).name
15
16
 
16
- path = path_download / name
17
+ path = Path(path_download) / name
17
18
  if not path.is_file():
18
19
  r = requests.get(url, allow_redirects=True)
19
20
  open(str(path), 'wb').write(r.content)
@@ -56,3 +57,14 @@ def get_dict_from_file(file_path):
56
57
  return yaml.safe_load(f)
57
58
  else:
58
59
  return json.load(f)
60
+
61
+
62
+ def calculate_checksum(file_path, prefix=''):
63
+ md5_hash = hashlib.md5()
64
+ with open(file_path, 'rb') as f:
65
+ for byte_block in iter(lambda: f.read(4096), b''):
66
+ md5_hash.update(byte_block)
67
+ checksum = md5_hash.hexdigest()
68
+ if prefix:
69
+ return f'dev-{checksum}'
70
+ return checksum
@@ -0,0 +1,92 @@
1
+ import os
2
+ from urllib.parse import urlparse, parse_qs
3
+
4
+ import boto3
5
+ from botocore.exceptions import ClientError
6
+
7
+
8
+ class BaseStorage:
9
+ url = None
10
+ options = None
11
+ OPTION_CASTS = {}
12
+
13
+ def __init__(self, url):
14
+ self.url = urlparse(url)
15
+ self.query_params = self.url_querystring_to_dict()
16
+ self.options = self.get_options()
17
+
18
+ def url_querystring_to_dict(self):
19
+ query_string = self.url.query
20
+
21
+ query_dict = parse_qs(query_string)
22
+
23
+ for key, value in query_dict.items():
24
+ if len(value) == 1:
25
+ query_dict[key] = value[0]
26
+
27
+ return {
28
+ key: self.OPTION_CASTS[key](value) if key in self.OPTION_CASTS else value
29
+ for key, value in query_dict.items()
30
+ }
31
+
32
+ def get_options(self):
33
+ return None
34
+
35
+ def upload(self, source, target):
36
+ raise NotImplementedError
37
+
38
+ def exists(self, target):
39
+ raise NotImplementedError
40
+
41
+ def get_url(self, target):
42
+ raise NotImplementedError
43
+
44
+
45
+ class S3Storage(BaseStorage):
46
+ def __init__(self, url):
47
+ super().__init__(url)
48
+ self.client = boto3.client(
49
+ 's3',
50
+ endpoint_url=self.options['endpoint_url'],
51
+ aws_access_key_id=self.options['access_key'],
52
+ aws_secret_access_key=self.options['secret_key'],
53
+ )
54
+
55
+ def get_options(self):
56
+ base_url = f'https://{self.url.hostname}'
57
+ local_endpoint = self.query_params.get('local_endpoint')
58
+ endpoint_url = f'http://{local_endpoint}' if local_endpoint else base_url
59
+ return {
60
+ 'base_url': base_url,
61
+ 'endpoint_url': endpoint_url,
62
+ 'bucket_name': self.url.path[1:],
63
+ 'access_key': self.url.username,
64
+ 'secret_key': self.url.password,
65
+ **self.query_params,
66
+ }
67
+
68
+ def upload(self, source, target):
69
+ object_name = os.path.join(self.options['location'], target)
70
+ self.client.upload_file(source, self.options['bucket_name'], object_name)
71
+ return self.get_url(target)
72
+
73
+ def exists(self, target):
74
+ try:
75
+ self.client.head_object(Bucket=self.options['bucket_name'], Key=target)
76
+ return True
77
+ except ClientError:
78
+ return False
79
+
80
+ def get_url(self, target):
81
+ object_name = os.path.join(self.options['location'], target)
82
+ return f'{self.options["base_url"]}/{self.options["bucket_name"]}/{object_name}'
83
+
84
+
85
+ STORAGE_STORAGES = {
86
+ 's3': S3Storage,
87
+ }
88
+
89
+
90
+ def get_storage(url):
91
+ storage_scheme = urlparse(url).scheme
92
+ return STORAGE_STORAGES[storage_scheme](url)
@@ -5,3 +5,7 @@ def hash_text(text):
5
5
  md5_hash = hashlib.md5()
6
6
  md5_hash.update(text.encode('utf-8'))
7
7
  return md5_hash.hexdigest()
8
+
9
+
10
+ def str_to_bool(value):
11
+ return value.lower() in ['true', '1', 'yes']
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: synapse-sdk
3
- Version: 1.0.0a0
3
+ Version: 1.0.0a1
4
4
  Summary: synapse sdk
5
5
  Author-email: datamaker <developer@datamaker.io>
6
6
  License: MIT
@@ -9,6 +9,7 @@ Requires-Python: >=3.11
9
9
  Description-Content-Type: text/markdown
10
10
  License-File: LICENSE
11
11
  Requires-Dist: boto3
12
+ Requires-Dist: click
12
13
  Requires-Dist: requests
13
14
  Requires-Dist: tqdm
14
15
  Requires-Dist: python-dotenv
@@ -0,0 +1,63 @@
1
+ .gitignore
2
+ .pre-commit-config.yaml
3
+ LICENSE
4
+ README.md
5
+ pyproject.toml
6
+ requirements.txt
7
+ .github/workflows/lint.yml
8
+ .github/workflows/pypi-publish.yml
9
+ synapse_sdk/__init__.py
10
+ synapse_sdk/config.py
11
+ synapse_sdk/loggers.py
12
+ synapse_sdk.egg-info/PKG-INFO
13
+ synapse_sdk.egg-info/SOURCES.txt
14
+ synapse_sdk.egg-info/dependency_links.txt
15
+ synapse_sdk.egg-info/requires.txt
16
+ synapse_sdk.egg-info/top_level.txt
17
+ synapse_sdk/client/__init__.py
18
+ synapse_sdk/client/exceptions.py
19
+ synapse_sdk/client/utils.py
20
+ synapse_sdk/client/mixins/__init__.py
21
+ synapse_sdk/client/mixins/annotation.py
22
+ synapse_sdk/client/mixins/dataset.py
23
+ synapse_sdk/client/mixins/integration.py
24
+ synapse_sdk/client/mixins/ml.py
25
+ synapse_sdk/plugins/__init__.py
26
+ synapse_sdk/plugins/enums.py
27
+ synapse_sdk/plugins/job.py
28
+ synapse_sdk/plugins/upload.py
29
+ synapse_sdk/plugins/utils.py
30
+ synapse_sdk/plugins/categories/__init__.py
31
+ synapse_sdk/plugins/categories/base.py
32
+ synapse_sdk/plugins/categories/decorators.py
33
+ synapse_sdk/plugins/categories/registry.py
34
+ synapse_sdk/plugins/categories/data_validation/__init__.py
35
+ synapse_sdk/plugins/categories/data_validation/actions/__init__.py
36
+ synapse_sdk/plugins/categories/data_validation/actions/validation.py
37
+ synapse_sdk/plugins/categories/export/__init__.py
38
+ synapse_sdk/plugins/categories/export/actions/__init__.py
39
+ synapse_sdk/plugins/categories/export/actions/export.py
40
+ synapse_sdk/plugins/categories/import/__init__.py
41
+ synapse_sdk/plugins/categories/import/actions/__init__.py
42
+ synapse_sdk/plugins/categories/import/actions/import.py
43
+ synapse_sdk/plugins/categories/neural_net/__init__.py
44
+ synapse_sdk/plugins/categories/neural_net/actions/__init__.py
45
+ synapse_sdk/plugins/categories/neural_net/actions/deployment.py
46
+ synapse_sdk/plugins/categories/neural_net/actions/inference.py
47
+ synapse_sdk/plugins/categories/neural_net/actions/test.py
48
+ synapse_sdk/plugins/categories/neural_net/actions/train.py
49
+ synapse_sdk/plugins/categories/post_annotation/__init__.py
50
+ synapse_sdk/plugins/categories/post_annotation/actions/__init__.py
51
+ synapse_sdk/plugins/categories/post_annotation/actions/post_annotation.py
52
+ synapse_sdk/plugins/categories/pre_annotation/__init__.py
53
+ synapse_sdk/plugins/categories/pre_annotation/actions/__init__.py
54
+ synapse_sdk/plugins/categories/pre_annotation/actions/pre_annotation.py
55
+ synapse_sdk/plugins/cli/__init__.py
56
+ synapse_sdk/plugins/cli/publish.py
57
+ synapse_sdk/plugins/cli/run.py
58
+ synapse_sdk/utils/__init__.py
59
+ synapse_sdk/utils/debug.py
60
+ synapse_sdk/utils/file.py
61
+ synapse_sdk/utils/module_loading.py
62
+ synapse_sdk/utils/storage.py
63
+ synapse_sdk/utils/string.py
@@ -1,4 +1,5 @@
1
1
  boto3
2
+ click
2
3
  requests
3
4
  tqdm
4
5
  python-dotenv
@@ -0,0 +1 @@
1
+ synapse_sdk
@@ -1,12 +0,0 @@
1
- class IntegrationClientMixin:
2
- def get_plugin(self, pk):
3
- path = f'plugins/{pk}/'
4
- return self._get(path)
5
-
6
- def create_logs(self, data):
7
- path = 'logs/'
8
- return self._post(path, payload=data)
9
-
10
- def create_task(self, data):
11
- path = 'agent_tasks/'
12
- return self._post(path, payload=data)
@@ -1,39 +0,0 @@
1
- import argparse
2
- import os
3
-
4
- from dotenv import load_dotenv
5
-
6
- from synapse.plugins.utils import get_action
7
-
8
-
9
- action = None
10
-
11
-
12
- def run():
13
- global action
14
- parser = argparse.ArgumentParser(description='synapse plugin runner')
15
-
16
- # Add arguments
17
- parser.add_argument('action', help='action to run on this plugin')
18
- parser.add_argument('params', help='parameter of the action')
19
- parser.add_argument('--direct', help='run without using ray', action='store_true')
20
- parser.add_argument('--debug', help='run with debug mode', action='store_true')
21
-
22
- # Parse arguments
23
- args = parser.parse_args()
24
-
25
- # Access parsed arguments
26
- action = args.action
27
- params = args.params
28
- direct = args.direct
29
- debug = args.debug
30
-
31
- load_dotenv(os.path.join(os.getcwd(), '.env'))
32
-
33
- action = get_action(action, params, direct=direct, debug=debug)
34
- result = action.run_action()
35
- if debug:
36
- print(result)
37
-
38
-
39
- __all__ = ['run']
@@ -1,10 +0,0 @@
1
- from synapse.plugins.categories.base import Action
2
- from synapse.plugins.categories.decorators import register_action
3
- from synapse.plugins.enums import RunMethod, PluginCategory
4
-
5
-
6
- @register_action
7
- class ValidationAction(Action):
8
- name = 'validation'
9
- category = PluginCategory.DATA_VALIDATION
10
- method = RunMethod.TASK
@@ -1,10 +0,0 @@
1
- from synapse.plugins.categories.base import Action
2
- from synapse.plugins.categories.decorators import register_action
3
- from synapse.plugins.enums import RunMethod, PluginCategory
4
-
5
-
6
- @register_action
7
- class ExportAction(Action):
8
- name = 'export'
9
- category = PluginCategory.EXPORT
10
- method = RunMethod.JOB
@@ -1,10 +0,0 @@
1
- from synapse.plugins.categories.base import Action
2
- from synapse.plugins.categories.decorators import register_action
3
- from synapse.plugins.enums import RunMethod, PluginCategory
4
-
5
-
6
- @register_action
7
- class ImportAction(Action):
8
- name = 'import'
9
- category = PluginCategory.IMPORT
10
- method = RunMethod.JOB
@@ -1,10 +0,0 @@
1
- from synapse.plugins.categories.base import Action
2
- from synapse.plugins.categories.decorators import register_action
3
- from synapse.plugins.enums import RunMethod, PluginCategory
4
-
5
-
6
- @register_action
7
- class InferenceAction(Action):
8
- name = 'inference'
9
- category = PluginCategory.NEURAL_NET
10
- method = RunMethod.RESTAPI
@@ -1,10 +0,0 @@
1
- from synapse.plugins.categories.base import Action
2
- from synapse.plugins.categories.decorators import register_action
3
- from synapse.plugins.enums import RunMethod, PluginCategory
4
-
5
-
6
- @register_action
7
- class TestAction(Action):
8
- name = 'test'
9
- category = PluginCategory.NEURAL_NET
10
- method = RunMethod.TASK
@@ -1,10 +0,0 @@
1
- from synapse.plugins.categories.base import Action
2
- from synapse.plugins.categories.decorators import register_action
3
- from synapse.plugins.enums import RunMethod, PluginCategory
4
-
5
-
6
- @register_action
7
- class PostAnnotationAction(Action):
8
- name = 'post_annotation'
9
- category = PluginCategory.POST_ANNOTATION
10
- method = RunMethod.TASK
@@ -1,10 +0,0 @@
1
- from synapse.plugins.categories.base import Action
2
- from synapse.plugins.categories.decorators import register_action
3
- from synapse.plugins.enums import RunMethod, PluginCategory
4
-
5
-
6
- @register_action
7
- class PreAnnotationAction(Action):
8
- name = 'pre_annotation'
9
- category = PluginCategory.PRE_ANNOTATION
10
- method = RunMethod.TASK
@@ -1,79 +0,0 @@
1
- import os
2
- import re
3
- import subprocess
4
- import tempfile
5
- import hashlib
6
- from pathlib import Path
7
-
8
- import boto3
9
-
10
-
11
- def calculate_checksum(file_path):
12
- md5_hash = hashlib.md5()
13
- with open(file_path, 'rb') as f:
14
- for byte_block in iter(lambda: f.read(4096), b''):
15
- md5_hash.update(byte_block)
16
- checksum = md5_hash.hexdigest()
17
- return f'dev-{checksum}'
18
-
19
-
20
- def upload_to_s3(file_path, bucket_name, object_name, endpoint_url, access_key, secret_key):
21
- s3_client = boto3.client(
22
- 's3',
23
- endpoint_url=endpoint_url,
24
- aws_access_key_id=access_key,
25
- aws_secret_access_key=secret_key,
26
- )
27
- s3_client.upload_file(file_path, bucket_name, object_name)
28
-
29
-
30
- def upload_path(
31
- source_path,
32
- endpoint_url=None,
33
- bucket_name=None,
34
- access_key=None,
35
- secret_key=None,
36
- base_url=None,
37
- ):
38
- if not endpoint_url:
39
- endpoint_url = os.environ['PLUGIN_UPLOAD_S3_ENDPOINT_URL']
40
- if not bucket_name:
41
- bucket_name = os.environ['PLUGIN_UPLOAD_S3_BUCKET_NAME']
42
- if not access_key:
43
- access_key = os.environ['PLUGIN_UPLOAD_S3_ACCESS_KEY']
44
- if not secret_key:
45
- secret_key = os.environ['PLUGIN_UPLOAD_S3_SECRET_KEY']
46
- if not base_url:
47
- base_url = os.environ['PLUGIN_UPLOAD_S3_BASE_URL']
48
-
49
- with tempfile.TemporaryDirectory() as temp_dir:
50
- temp_archive_path = os.path.join(temp_dir, 'archive.zip')
51
- command = f'git ls-files --others --exclude-standard --cached | zip -q --names-stdin {temp_archive_path}'
52
-
53
- subprocess.run(command, cwd=source_path, shell=True, check=True)
54
-
55
- checksum = calculate_checksum(temp_archive_path)
56
- # TODO subpath param으로 받기
57
- s3_object_name = f'assets/{checksum}.zip'
58
-
59
- upload_to_s3(temp_archive_path, bucket_name, s3_object_name, endpoint_url, access_key, secret_key)
60
- return f'{base_url}/{bucket_name}/{s3_object_name}'
61
-
62
-
63
- def change_whl_version(whl_name, new_version):
64
- pattern = r'^(?P<distribution>.+?)-(?P<version>\d+(\.\d+)*)(?P<rest>-.+\.whl)$'
65
- return re.sub(pattern, rf'\g<distribution>-{new_version}\g<rest>', whl_name)
66
-
67
-
68
- def build_and_upload(source_path, endpoint_url, bucket_name, access_key, secret_key, base_url, virtualenv_path='.venv'):
69
- # TODO 이미 빌드한 whl이 있으면 skip
70
- subprocess.run(f'{virtualenv_path}/bin/python -m build --wheel', cwd=source_path, shell=True, check=True)
71
-
72
- whl_file = next(Path(source_path, 'dist').glob('*.whl'), None)
73
- checksum = calculate_checksum(whl_file)
74
-
75
- # TODO subpath param으로 받기
76
- s3_object_name = f'assets/{change_whl_version(whl_file.name, checksum)}'
77
-
78
- upload_to_s3(str(whl_file), bucket_name, s3_object_name, endpoint_url, access_key, secret_key)
79
- return f'{base_url}/{bucket_name}/{s3_object_name}'
@@ -1,59 +0,0 @@
1
- .gitignore
2
- .pre-commit-config.yaml
3
- LICENSE
4
- README.md
5
- pyproject.toml
6
- requirements.txt
7
- .github/workflows/lint.yml
8
- .github/workflows/pypi-publish.yml
9
- synapse/__init__.py
10
- synapse/config.py
11
- synapse/loggers.py
12
- synapse/client/__init__.py
13
- synapse/client/exceptions.py
14
- synapse/client/utils.py
15
- synapse/client/mixins/__init__.py
16
- synapse/client/mixins/annotation.py
17
- synapse/client/mixins/dataset.py
18
- synapse/client/mixins/integration.py
19
- synapse/client/mixins/ml.py
20
- synapse/plugins/__init__.py
21
- synapse/plugins/enums.py
22
- synapse/plugins/job.py
23
- synapse/plugins/upload.py
24
- synapse/plugins/utils.py
25
- synapse/plugins/categories/__init__.py
26
- synapse/plugins/categories/base.py
27
- synapse/plugins/categories/decorators.py
28
- synapse/plugins/categories/registry.py
29
- synapse/plugins/categories/data_validation/__init__.py
30
- synapse/plugins/categories/data_validation/actions/__init__.py
31
- synapse/plugins/categories/data_validation/actions/validation.py
32
- synapse/plugins/categories/export/__init__.py
33
- synapse/plugins/categories/export/actions/__init__.py
34
- synapse/plugins/categories/export/actions/export.py
35
- synapse/plugins/categories/import/__init__.py
36
- synapse/plugins/categories/import/actions/__init__.py
37
- synapse/plugins/categories/import/actions/import.py
38
- synapse/plugins/categories/neural_net/__init__.py
39
- synapse/plugins/categories/neural_net/actions/__init__.py
40
- synapse/plugins/categories/neural_net/actions/deployment.py
41
- synapse/plugins/categories/neural_net/actions/inference.py
42
- synapse/plugins/categories/neural_net/actions/test.py
43
- synapse/plugins/categories/neural_net/actions/train.py
44
- synapse/plugins/categories/post_annotation/__init__.py
45
- synapse/plugins/categories/post_annotation/actions/__init__.py
46
- synapse/plugins/categories/post_annotation/actions/post_annotation.py
47
- synapse/plugins/categories/pre_annotation/__init__.py
48
- synapse/plugins/categories/pre_annotation/actions/__init__.py
49
- synapse/plugins/categories/pre_annotation/actions/pre_annotation.py
50
- synapse/utils/__init__.py
51
- synapse/utils/debug.py
52
- synapse/utils/file.py
53
- synapse/utils/module_loading.py
54
- synapse/utils/string.py
55
- synapse_sdk.egg-info/PKG-INFO
56
- synapse_sdk.egg-info/SOURCES.txt
57
- synapse_sdk.egg-info/dependency_links.txt
58
- synapse_sdk.egg-info/requires.txt
59
- synapse_sdk.egg-info/top_level.txt
@@ -1 +0,0 @@
1
- synapse
File without changes
File without changes
File without changes
File without changes