synapse-sdk 1.0.0a15__tar.gz → 1.0.0a17__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 (122) hide show
  1. {synapse_sdk-1.0.0a15/synapse_sdk.egg-info → synapse_sdk-1.0.0a17}/PKG-INFO +1 -1
  2. {synapse_sdk-1.0.0a15 → synapse_sdk-1.0.0a17}/synapse_sdk/clients/backend/ml.py +1 -3
  3. {synapse_sdk-1.0.0a15 → synapse_sdk-1.0.0a17}/synapse_sdk/clients/base.py +4 -4
  4. {synapse_sdk-1.0.0a15 → synapse_sdk-1.0.0a17}/synapse_sdk/plugins/categories/base.py +9 -7
  5. {synapse_sdk-1.0.0a15 → synapse_sdk-1.0.0a17}/synapse_sdk/plugins/categories/neural_net/actions/train.py +18 -7
  6. {synapse_sdk-1.0.0a15 → synapse_sdk-1.0.0a17}/synapse_sdk/plugins/cli/publish.py +2 -2
  7. synapse_sdk-1.0.0a17/synapse_sdk/utils/file.py +168 -0
  8. {synapse_sdk-1.0.0a15 → synapse_sdk-1.0.0a17/synapse_sdk.egg-info}/PKG-INFO +1 -1
  9. synapse_sdk-1.0.0a15/synapse_sdk/utils/file.py +0 -87
  10. {synapse_sdk-1.0.0a15 → synapse_sdk-1.0.0a17}/.github/workflows/lint.yml +0 -0
  11. {synapse_sdk-1.0.0a15 → synapse_sdk-1.0.0a17}/.github/workflows/pypi-publish.yml +0 -0
  12. {synapse_sdk-1.0.0a15 → synapse_sdk-1.0.0a17}/.gitignore +0 -0
  13. {synapse_sdk-1.0.0a15 → synapse_sdk-1.0.0a17}/.pre-commit-config.yaml +0 -0
  14. {synapse_sdk-1.0.0a15 → synapse_sdk-1.0.0a17}/LICENSE +0 -0
  15. {synapse_sdk-1.0.0a15 → synapse_sdk-1.0.0a17}/README.md +0 -0
  16. {synapse_sdk-1.0.0a15 → synapse_sdk-1.0.0a17}/locale/en/LC_MESSAGES/messages.mo +0 -0
  17. {synapse_sdk-1.0.0a15 → synapse_sdk-1.0.0a17}/locale/en/LC_MESSAGES/messages.po +0 -0
  18. {synapse_sdk-1.0.0a15 → synapse_sdk-1.0.0a17}/locale/ko/LC_MESSAGES/messages.mo +0 -0
  19. {synapse_sdk-1.0.0a15 → synapse_sdk-1.0.0a17}/locale/ko/LC_MESSAGES/messages.po +0 -0
  20. {synapse_sdk-1.0.0a15 → synapse_sdk-1.0.0a17}/pyproject.toml +0 -0
  21. {synapse_sdk-1.0.0a15 → synapse_sdk-1.0.0a17}/requirements.txt +0 -0
  22. {synapse_sdk-1.0.0a15 → synapse_sdk-1.0.0a17}/setup.cfg +0 -0
  23. {synapse_sdk-1.0.0a15 → synapse_sdk-1.0.0a17}/synapse_sdk/__init__.py +0 -0
  24. {synapse_sdk-1.0.0a15 → synapse_sdk-1.0.0a17}/synapse_sdk/cli/__init__.py +0 -0
  25. {synapse_sdk-1.0.0a15 → synapse_sdk-1.0.0a17}/synapse_sdk/cli/create_plugin.py +0 -0
  26. {synapse_sdk-1.0.0a15 → synapse_sdk-1.0.0a17}/synapse_sdk/clients/__init__.py +0 -0
  27. {synapse_sdk-1.0.0a15 → synapse_sdk-1.0.0a17}/synapse_sdk/clients/agent/__init__.py +0 -0
  28. {synapse_sdk-1.0.0a15 → synapse_sdk-1.0.0a17}/synapse_sdk/clients/agent/core.py +0 -0
  29. {synapse_sdk-1.0.0a15 → synapse_sdk-1.0.0a17}/synapse_sdk/clients/agent/ray.py +0 -0
  30. {synapse_sdk-1.0.0a15 → synapse_sdk-1.0.0a17}/synapse_sdk/clients/agent/service.py +0 -0
  31. {synapse_sdk-1.0.0a15 → synapse_sdk-1.0.0a17}/synapse_sdk/clients/backend/__init__.py +0 -0
  32. {synapse_sdk-1.0.0a15 → synapse_sdk-1.0.0a17}/synapse_sdk/clients/backend/annotation.py +0 -0
  33. {synapse_sdk-1.0.0a15 → synapse_sdk-1.0.0a17}/synapse_sdk/clients/backend/dataset.py +0 -0
  34. {synapse_sdk-1.0.0a15 → synapse_sdk-1.0.0a17}/synapse_sdk/clients/backend/integration.py +0 -0
  35. {synapse_sdk-1.0.0a15 → synapse_sdk-1.0.0a17}/synapse_sdk/clients/exceptions.py +0 -0
  36. {synapse_sdk-1.0.0a15 → synapse_sdk-1.0.0a17}/synapse_sdk/clients/ray/__init__.py +0 -0
  37. {synapse_sdk-1.0.0a15 → synapse_sdk-1.0.0a17}/synapse_sdk/clients/ray/core.py +0 -0
  38. {synapse_sdk-1.0.0a15 → synapse_sdk-1.0.0a17}/synapse_sdk/clients/ray/serve.py +0 -0
  39. {synapse_sdk-1.0.0a15 → synapse_sdk-1.0.0a17}/synapse_sdk/clients/utils.py +0 -0
  40. {synapse_sdk-1.0.0a15 → synapse_sdk-1.0.0a17}/synapse_sdk/i18n.py +0 -0
  41. {synapse_sdk-1.0.0a15 → synapse_sdk-1.0.0a17}/synapse_sdk/loggers.py +0 -0
  42. {synapse_sdk-1.0.0a15 → synapse_sdk-1.0.0a17}/synapse_sdk/plugins/__init__.py +0 -0
  43. {synapse_sdk-1.0.0a15 → synapse_sdk-1.0.0a17}/synapse_sdk/plugins/categories/__init__.py +0 -0
  44. {synapse_sdk-1.0.0a15 → synapse_sdk-1.0.0a17}/synapse_sdk/plugins/categories/data_validation/__init__.py +0 -0
  45. {synapse_sdk-1.0.0a15 → synapse_sdk-1.0.0a17}/synapse_sdk/plugins/categories/data_validation/actions/__init__.py +0 -0
  46. {synapse_sdk-1.0.0a15 → synapse_sdk-1.0.0a17}/synapse_sdk/plugins/categories/data_validation/actions/validation.py +0 -0
  47. {synapse_sdk-1.0.0a15 → synapse_sdk-1.0.0a17}/synapse_sdk/plugins/categories/data_validation/templates/config.yaml +0 -0
  48. {synapse_sdk-1.0.0a15 → synapse_sdk-1.0.0a17}/synapse_sdk/plugins/categories/data_validation/templates/plugin/__init__.py +0 -0
  49. {synapse_sdk-1.0.0a15 → synapse_sdk-1.0.0a17}/synapse_sdk/plugins/categories/data_validation/templates/plugin/validation.py +0 -0
  50. {synapse_sdk-1.0.0a15 → synapse_sdk-1.0.0a17}/synapse_sdk/plugins/categories/decorators.py +0 -0
  51. {synapse_sdk-1.0.0a15 → synapse_sdk-1.0.0a17}/synapse_sdk/plugins/categories/export/__init__.py +0 -0
  52. {synapse_sdk-1.0.0a15 → synapse_sdk-1.0.0a17}/synapse_sdk/plugins/categories/export/actions/__init__.py +0 -0
  53. {synapse_sdk-1.0.0a15 → synapse_sdk-1.0.0a17}/synapse_sdk/plugins/categories/export/actions/export.py +0 -0
  54. {synapse_sdk-1.0.0a15 → synapse_sdk-1.0.0a17}/synapse_sdk/plugins/categories/import/__init__.py +0 -0
  55. {synapse_sdk-1.0.0a15 → synapse_sdk-1.0.0a17}/synapse_sdk/plugins/categories/import/actions/__init__.py +0 -0
  56. {synapse_sdk-1.0.0a15 → synapse_sdk-1.0.0a17}/synapse_sdk/plugins/categories/import/actions/import.py +0 -0
  57. {synapse_sdk-1.0.0a15 → synapse_sdk-1.0.0a17}/synapse_sdk/plugins/categories/neural_net/__init__.py +0 -0
  58. {synapse_sdk-1.0.0a15 → synapse_sdk-1.0.0a17}/synapse_sdk/plugins/categories/neural_net/actions/__init__.py +0 -0
  59. {synapse_sdk-1.0.0a15 → synapse_sdk-1.0.0a17}/synapse_sdk/plugins/categories/neural_net/actions/deployment.py +0 -0
  60. {synapse_sdk-1.0.0a15 → synapse_sdk-1.0.0a17}/synapse_sdk/plugins/categories/neural_net/actions/inference.py +0 -0
  61. {synapse_sdk-1.0.0a15 → synapse_sdk-1.0.0a17}/synapse_sdk/plugins/categories/neural_net/actions/test.py +0 -0
  62. {synapse_sdk-1.0.0a15 → synapse_sdk-1.0.0a17}/synapse_sdk/plugins/categories/neural_net/templates/config.yaml +0 -0
  63. {synapse_sdk-1.0.0a15 → synapse_sdk-1.0.0a17}/synapse_sdk/plugins/categories/neural_net/templates/plugin/__init__.py +0 -0
  64. {synapse_sdk-1.0.0a15 → synapse_sdk-1.0.0a17}/synapse_sdk/plugins/categories/neural_net/templates/plugin/inference.py +0 -0
  65. {synapse_sdk-1.0.0a15 → synapse_sdk-1.0.0a17}/synapse_sdk/plugins/categories/neural_net/templates/plugin/test.py +0 -0
  66. {synapse_sdk-1.0.0a15 → synapse_sdk-1.0.0a17}/synapse_sdk/plugins/categories/neural_net/templates/plugin/train.py +0 -0
  67. {synapse_sdk-1.0.0a15 → synapse_sdk-1.0.0a17}/synapse_sdk/plugins/categories/post_annotation/__init__.py +0 -0
  68. {synapse_sdk-1.0.0a15 → synapse_sdk-1.0.0a17}/synapse_sdk/plugins/categories/post_annotation/actions/__init__.py +0 -0
  69. {synapse_sdk-1.0.0a15 → synapse_sdk-1.0.0a17}/synapse_sdk/plugins/categories/post_annotation/actions/post_annotation.py +0 -0
  70. {synapse_sdk-1.0.0a15 → synapse_sdk-1.0.0a17}/synapse_sdk/plugins/categories/post_annotation/templates/config.yaml +0 -0
  71. {synapse_sdk-1.0.0a15 → synapse_sdk-1.0.0a17}/synapse_sdk/plugins/categories/post_annotation/templates/plugin/__init__.py +0 -0
  72. {synapse_sdk-1.0.0a15 → synapse_sdk-1.0.0a17}/synapse_sdk/plugins/categories/post_annotation/templates/plugin/post_annotation.py +0 -0
  73. {synapse_sdk-1.0.0a15 → synapse_sdk-1.0.0a17}/synapse_sdk/plugins/categories/pre_annotation/__init__.py +0 -0
  74. {synapse_sdk-1.0.0a15 → synapse_sdk-1.0.0a17}/synapse_sdk/plugins/categories/pre_annotation/actions/__init__.py +0 -0
  75. {synapse_sdk-1.0.0a15 → synapse_sdk-1.0.0a17}/synapse_sdk/plugins/categories/pre_annotation/actions/pre_annotation.py +0 -0
  76. {synapse_sdk-1.0.0a15 → synapse_sdk-1.0.0a17}/synapse_sdk/plugins/categories/pre_annotation/templates/config.yaml +0 -0
  77. {synapse_sdk-1.0.0a15 → synapse_sdk-1.0.0a17}/synapse_sdk/plugins/categories/pre_annotation/templates/plugin/__init__.py +0 -0
  78. {synapse_sdk-1.0.0a15 → synapse_sdk-1.0.0a17}/synapse_sdk/plugins/categories/pre_annotation/templates/plugin/pre_annotation.py +0 -0
  79. {synapse_sdk-1.0.0a15 → synapse_sdk-1.0.0a17}/synapse_sdk/plugins/categories/registry.py +0 -0
  80. {synapse_sdk-1.0.0a15 → synapse_sdk-1.0.0a17}/synapse_sdk/plugins/categories/smart_tool/__init__.py +0 -0
  81. {synapse_sdk-1.0.0a15 → synapse_sdk-1.0.0a17}/synapse_sdk/plugins/categories/smart_tool/actions/__init__.py +0 -0
  82. {synapse_sdk-1.0.0a15 → synapse_sdk-1.0.0a17}/synapse_sdk/plugins/categories/smart_tool/actions/auto_label.py +0 -0
  83. {synapse_sdk-1.0.0a15 → synapse_sdk-1.0.0a17}/synapse_sdk/plugins/categories/smart_tool/templates/config.yaml +0 -0
  84. {synapse_sdk-1.0.0a15 → synapse_sdk-1.0.0a17}/synapse_sdk/plugins/categories/smart_tool/templates/plugin/__init__.py +0 -0
  85. {synapse_sdk-1.0.0a15 → synapse_sdk-1.0.0a17}/synapse_sdk/plugins/categories/smart_tool/templates/plugin/auto_label.py +0 -0
  86. {synapse_sdk-1.0.0a15 → synapse_sdk-1.0.0a17}/synapse_sdk/plugins/categories/templates.py +0 -0
  87. {synapse_sdk-1.0.0a15 → synapse_sdk-1.0.0a17}/synapse_sdk/plugins/cli/__init__.py +0 -0
  88. {synapse_sdk-1.0.0a15 → synapse_sdk-1.0.0a17}/synapse_sdk/plugins/cli/run.py +0 -0
  89. {synapse_sdk-1.0.0a15 → synapse_sdk-1.0.0a17}/synapse_sdk/plugins/enums.py +0 -0
  90. {synapse_sdk-1.0.0a15 → synapse_sdk-1.0.0a17}/synapse_sdk/plugins/exceptions.py +0 -0
  91. {synapse_sdk-1.0.0a15 → synapse_sdk-1.0.0a17}/synapse_sdk/plugins/models.py +0 -0
  92. {synapse_sdk-1.0.0a15 → synapse_sdk-1.0.0a17}/synapse_sdk/plugins/templates/cookiecutter.json +0 -0
  93. {synapse_sdk-1.0.0a15 → synapse_sdk-1.0.0a17}/synapse_sdk/plugins/templates/hooks/post_gen_project.py +0 -0
  94. {synapse_sdk-1.0.0a15 → synapse_sdk-1.0.0a17}/synapse_sdk/plugins/templates/hooks/pre_prompt.py +0 -0
  95. {synapse_sdk-1.0.0a15 → synapse_sdk-1.0.0a17}/synapse_sdk/plugins/templates/synapse-{{cookiecutter.plugin_code}}-plugin/.env +0 -0
  96. {synapse_sdk-1.0.0a15 → synapse_sdk-1.0.0a17}/synapse_sdk/plugins/templates/synapse-{{cookiecutter.plugin_code}}-plugin/.env.dist +0 -0
  97. {synapse_sdk-1.0.0a15 → synapse_sdk-1.0.0a17}/synapse_sdk/plugins/templates/synapse-{{cookiecutter.plugin_code}}-plugin/.gitignore +0 -0
  98. {synapse_sdk-1.0.0a15 → synapse_sdk-1.0.0a17}/synapse_sdk/plugins/templates/synapse-{{cookiecutter.plugin_code}}-plugin/.pre-commit-config.yaml +0 -0
  99. {synapse_sdk-1.0.0a15 → synapse_sdk-1.0.0a17}/synapse_sdk/plugins/templates/synapse-{{cookiecutter.plugin_code}}-plugin/README.md +0 -0
  100. {synapse_sdk-1.0.0a15 → synapse_sdk-1.0.0a17}/synapse_sdk/plugins/templates/synapse-{{cookiecutter.plugin_code}}-plugin/config.yaml +0 -0
  101. {synapse_sdk-1.0.0a15 → synapse_sdk-1.0.0a17}/synapse_sdk/plugins/templates/synapse-{{cookiecutter.plugin_code}}-plugin/main.py +0 -0
  102. {synapse_sdk-1.0.0a15 → synapse_sdk-1.0.0a17}/synapse_sdk/plugins/templates/synapse-{{cookiecutter.plugin_code}}-plugin/plugin/__init__.py +0 -0
  103. {synapse_sdk-1.0.0a15 → synapse_sdk-1.0.0a17}/synapse_sdk/plugins/templates/synapse-{{cookiecutter.plugin_code}}-plugin/pyproject.toml +0 -0
  104. {synapse_sdk-1.0.0a15 → synapse_sdk-1.0.0a17}/synapse_sdk/plugins/templates/synapse-{{cookiecutter.plugin_code}}-plugin/requirements.txt +0 -0
  105. {synapse_sdk-1.0.0a15 → synapse_sdk-1.0.0a17}/synapse_sdk/plugins/upload.py +0 -0
  106. {synapse_sdk-1.0.0a15 → synapse_sdk-1.0.0a17}/synapse_sdk/plugins/utils.py +0 -0
  107. {synapse_sdk-1.0.0a15 → synapse_sdk-1.0.0a17}/synapse_sdk/shared/__init__.py +0 -0
  108. {synapse_sdk-1.0.0a15 → synapse_sdk-1.0.0a17}/synapse_sdk/shared/enums.py +0 -0
  109. {synapse_sdk-1.0.0a15 → synapse_sdk-1.0.0a17}/synapse_sdk/utils/__init__.py +0 -0
  110. {synapse_sdk-1.0.0a15 → synapse_sdk-1.0.0a17}/synapse_sdk/utils/debug.py +0 -0
  111. {synapse_sdk-1.0.0a15 → synapse_sdk-1.0.0a17}/synapse_sdk/utils/module_loading.py +0 -0
  112. {synapse_sdk-1.0.0a15 → synapse_sdk-1.0.0a17}/synapse_sdk/utils/pydantic/__init__.py +0 -0
  113. {synapse_sdk-1.0.0a15 → synapse_sdk-1.0.0a17}/synapse_sdk/utils/pydantic/config.py +0 -0
  114. {synapse_sdk-1.0.0a15 → synapse_sdk-1.0.0a17}/synapse_sdk/utils/pydantic/errors.py +0 -0
  115. {synapse_sdk-1.0.0a15 → synapse_sdk-1.0.0a17}/synapse_sdk/utils/pydantic/validators.py +0 -0
  116. {synapse_sdk-1.0.0a15 → synapse_sdk-1.0.0a17}/synapse_sdk/utils/storage.py +0 -0
  117. {synapse_sdk-1.0.0a15 → synapse_sdk-1.0.0a17}/synapse_sdk/utils/string.py +0 -0
  118. {synapse_sdk-1.0.0a15 → synapse_sdk-1.0.0a17}/synapse_sdk.egg-info/SOURCES.txt +0 -0
  119. {synapse_sdk-1.0.0a15 → synapse_sdk-1.0.0a17}/synapse_sdk.egg-info/dependency_links.txt +0 -0
  120. {synapse_sdk-1.0.0a15 → synapse_sdk-1.0.0a17}/synapse_sdk.egg-info/entry_points.txt +0 -0
  121. {synapse_sdk-1.0.0a15 → synapse_sdk-1.0.0a17}/synapse_sdk.egg-info/requires.txt +0 -0
  122. {synapse_sdk-1.0.0a15 → synapse_sdk-1.0.0a17}/synapse_sdk.egg-info/top_level.txt +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: synapse-sdk
3
- Version: 1.0.0a15
3
+ Version: 1.0.0a17
4
4
  Summary: synapse sdk
5
5
  Author-email: datamaker <developer@datamaker.io>
6
6
  License: MIT
@@ -9,9 +9,7 @@ class MLClientMixin(BaseClient):
9
9
 
10
10
  def get_model(self, pk, params=None, url_conversion=None):
11
11
  path = f'models/{pk}/'
12
- url_conversion = get_default_url_conversion(
13
- url_conversion, files_fields=['files', 'parent.files'], is_list=False
14
- )
12
+ url_conversion = get_default_url_conversion(url_conversion, files_fields=['file'], is_list=False)
15
13
  return self._get(path, params=params, url_conversion=url_conversion)
16
14
 
17
15
  def create_model(self, data):
@@ -62,7 +62,7 @@ class BaseClient:
62
62
  response = self._request('get', path, **kwargs)
63
63
  if url_conversion:
64
64
  if url_conversion['is_list']:
65
- files_url_to_path_from_objs(response['results'], **url_conversion)
65
+ files_url_to_path_from_objs(response['results'], **url_conversion, is_async=True)
66
66
  else:
67
67
  files_url_to_path_from_objs(response, **url_conversion)
68
68
  return response
@@ -80,14 +80,14 @@ class BaseClient:
80
80
  return self._request('delete', path, **kwargs)
81
81
 
82
82
  def _list(self, path, url_conversion=None, list_all=False, **kwargs):
83
- response = self._get(path, url_conversion, **kwargs)
83
+ response = self._get(path, **kwargs)
84
84
  if list_all:
85
85
  return self._list_all(path, url_conversion, **kwargs), response['count']
86
86
  else:
87
87
  return response
88
88
 
89
- def _list_all(self, path, url_conversion=None, **kwargs):
90
- response = self._get(path, url_conversion, **kwargs)
89
+ def _list_all(self, path, url_conversion=None, params=None, **kwargs):
90
+ response = self._get(path, url_conversion, params=params, **kwargs)
91
91
  yield from response['results']
92
92
  if response['next']:
93
93
  yield from self._list_all(response['next'], url_conversion, **kwargs)
@@ -92,13 +92,15 @@ class Action:
92
92
  @property
93
93
  def debug_modules(self):
94
94
  debug_modules = []
95
- for module_path in self.envs.get('SYNAPSE_DEBUG_MODULES', '').split(','):
96
- if module_path.startswith('https://'): # TODO ray에서 지원하는 remote uri 형식 (https, s3, gs) 모두 지원
97
- module_url = module_path
98
- else:
99
- module_url = build_and_upload(module_path, self.plugin_storage_url)
100
- debug_modules.append(module_url)
101
- self.envs['SYNAPSE_DEBUG_MODULES'] = ','.join(debug_modules)
95
+ if self.envs.get('SYNAPSE_DEBUG_MODULES'):
96
+ for module_path in self.envs['SYNAPSE_DEBUG_MODULES'].split(','):
97
+ # TODO ray에서 지원하는 remote uri 형식 (https, s3, gs) 모두 지원
98
+ if module_path.startswith('https://'):
99
+ module_url = module_path
100
+ else:
101
+ module_url = build_and_upload(module_path, self.plugin_storage_url)
102
+ debug_modules.append(module_url)
103
+ self.envs['SYNAPSE_DEBUG_MODULES'] = ','.join(debug_modules)
102
104
  return debug_modules
103
105
 
104
106
  def get_run(self):
@@ -12,7 +12,7 @@ from synapse_sdk.plugins.categories.base import Action
12
12
  from synapse_sdk.plugins.categories.decorators import register_action
13
13
  from synapse_sdk.plugins.enums import PluginCategory, RunMethod
14
14
  from synapse_sdk.plugins.models import Run
15
- from synapse_sdk.utils.file import archive
15
+ from synapse_sdk.utils.file import archive, get_temp_path, unarchive
16
16
  from synapse_sdk.utils.pydantic.validators import non_blank
17
17
 
18
18
 
@@ -83,10 +83,15 @@ class TrainAction(Action):
83
83
  self.run.log_message('Preparing dataset for training.')
84
84
  input_dataset = self.get_dataset()
85
85
 
86
+ # retrieve checkpoint
87
+ checkpoint = None
88
+ if self.params['checkpoint']:
89
+ self.run.log_message('Retrieving checkpoint.')
90
+ checkpoint = self.get_model(self.params['checkpoint'])
91
+
86
92
  # train dataset
87
93
  self.run.log_message('Starting model training.')
88
-
89
- result = self.entrypoint(self.run, input_dataset, hyperparameter)
94
+ result = self.entrypoint(self.run, input_dataset, hyperparameter, checkpoint=checkpoint)
90
95
 
91
96
  # upload model_data
92
97
  self.run.log_message('Registering model data.')
@@ -106,6 +111,7 @@ class TrainAction(Action):
106
111
  ground_truths, count_dataset = client.list_ground_truth_events(
107
112
  params={
108
113
  'fields': ['category', 'files', 'data'],
114
+ 'expand': ['data'],
109
115
  'ground_truth_dataset_versions': self.params['dataset'],
110
116
  },
111
117
  list_all=True,
@@ -120,11 +126,16 @@ class TrainAction(Action):
120
126
 
121
127
  return input_dataset
122
128
 
123
- def create_model(self, path):
124
- if not self.client:
125
- print(path)
126
- return None
129
+ def get_model(self, model_id):
130
+ model = self.client.get_model(model_id)
131
+ model_file = Path(model['file'])
132
+ output_path = get_temp_path(f'models/{model_file.stem}')
133
+ if not output_path.exists():
134
+ unarchive(model_file, output_path)
135
+ model['path'] = output_path
136
+ return model
127
137
 
138
+ def create_model(self, path):
128
139
  params = copy.deepcopy(self.params)
129
140
  configuration_fields = ['hyperparameter']
130
141
  configuration = {field: params.pop(field) for field in configuration_fields}
@@ -26,8 +26,8 @@ def publish(ctx, host, user_token, tenant, debug_modules):
26
26
 
27
27
  data = {'plugin': plugin_release.plugin, 'file': str(archive_path), 'debug': debug}
28
28
  if debug:
29
- if debug_modules:
30
- data['debug_meta'] = json.dumps({'modules': debug_modules.split(',')})
29
+ modules = debug_modules.split(',') if debug_modules else []
30
+ data['debug_meta'] = json.dumps({'modules': modules})
31
31
 
32
32
  client = BackendClient(host, user_token, tenant=tenant)
33
33
  client.create_plugin_release(data)
@@ -0,0 +1,168 @@
1
+ import asyncio
2
+ import hashlib
3
+ import json
4
+ import operator
5
+ import zipfile
6
+ from functools import reduce
7
+ from pathlib import Path
8
+ from urllib.parse import urlparse
9
+
10
+ import aiohttp
11
+ import requests
12
+ import yaml
13
+
14
+
15
+ def download_file(url, path_download, name=None, coerce=None):
16
+ if name:
17
+ name += Path(url).suffix
18
+ else:
19
+ name = Path(url).name
20
+
21
+ name = urlparse(name).path
22
+ path = Path(path_download) / name
23
+ if not path.is_file():
24
+ r = requests.get(url, allow_redirects=True)
25
+ open(str(path), 'wb').write(r.content)
26
+
27
+ if coerce:
28
+ path = coerce(path)
29
+
30
+ return path
31
+
32
+
33
+ def files_url_to_path(files, coerce=None, file_field=None):
34
+ path_download = Path('/tmp/datamaker') / 'media'
35
+ path_download.mkdir(parents=True, exist_ok=True)
36
+ if file_field:
37
+ files[file_field] = download_file(files[file_field], path_download, coerce=coerce)
38
+ else:
39
+ for file_name in files:
40
+ if isinstance(files[file_name], str):
41
+ files[file_name] = download_file(files[file_name], path_download, coerce=coerce)
42
+ else:
43
+ files[file_name]['path'] = download_file(files[file_name].pop('url'), path_download, coerce=coerce)
44
+
45
+
46
+ def files_url_to_path_from_objs(objs, files_fields, coerce=None, is_list=False, is_async=False):
47
+ if is_async:
48
+ asyncio.run(afiles_url_to_path_from_objs(objs, files_fields, coerce=coerce, is_list=is_list))
49
+ else:
50
+ if not is_list:
51
+ objs = [objs]
52
+
53
+ for obj in objs:
54
+ for files_field in files_fields:
55
+ try:
56
+ files = reduce(operator.getitem, files_field.split('.'), obj)
57
+ if isinstance(files, str):
58
+ files_url_to_path(obj, coerce=coerce, file_field=files_field)
59
+ else:
60
+ files_url_to_path(files, coerce=coerce)
61
+ except KeyError:
62
+ pass
63
+
64
+
65
+ async def adownload_file(url, path_download, name=None, coerce=None):
66
+ if name:
67
+ name += Path(url).suffix
68
+ else:
69
+ name = Path(url).name
70
+
71
+ name = urlparse(name).path
72
+ path = Path(path_download) / name
73
+ if not path.is_file():
74
+ async with aiohttp.ClientSession() as session:
75
+ async with session.get(url) as response:
76
+ with open(str(path), 'wb') as file:
77
+ while chunk := await response.content.read(1024 * 64):
78
+ file.write(chunk)
79
+
80
+ if coerce:
81
+ path = coerce(path)
82
+
83
+ return path
84
+
85
+
86
+ async def afiles_url_to_path(files, coerce=None):
87
+ path_download = get_temp_path('media')
88
+ path_download.mkdir(parents=True, exist_ok=True)
89
+ for file_name in files:
90
+ if isinstance(files[file_name], str):
91
+ files[file_name] = await adownload_file(files[file_name], path_download, coerce=coerce)
92
+ else:
93
+ files[file_name]['path'] = await adownload_file(files[file_name].pop('url'), path_download, coerce=coerce)
94
+
95
+
96
+ async def afiles_url_to_path_from_objs(objs, files_fields, coerce=None, is_list=False):
97
+ if not is_list:
98
+ objs = [objs]
99
+
100
+ tasks = []
101
+
102
+ for obj in objs:
103
+ for files_field in files_fields:
104
+ try:
105
+ files = reduce(operator.getitem, files_field.split('.'), obj)
106
+ tasks.append(afiles_url_to_path(files, coerce=coerce))
107
+ except KeyError:
108
+ pass
109
+
110
+ await asyncio.gather(*tasks)
111
+
112
+
113
+ def get_dict_from_file(file_path):
114
+ if isinstance(file_path, str):
115
+ file_path = Path(file_path)
116
+
117
+ with open(file_path) as f:
118
+ if file_path.suffix == '.yaml':
119
+ return yaml.safe_load(f)
120
+ else:
121
+ return json.load(f)
122
+
123
+
124
+ def calculate_checksum(file_path, prefix=''):
125
+ md5_hash = hashlib.md5()
126
+ with open(file_path, 'rb') as f:
127
+ for byte_block in iter(lambda: f.read(4096), b''):
128
+ md5_hash.update(byte_block)
129
+ checksum = md5_hash.hexdigest()
130
+ if prefix:
131
+ return f'dev-{checksum}'
132
+ return checksum
133
+
134
+
135
+ def archive(input_path, output_path):
136
+ input_path = Path(input_path)
137
+ output_path = Path(output_path)
138
+
139
+ with zipfile.ZipFile(output_path, mode='w', compression=zipfile.ZIP_DEFLATED) as zipf:
140
+ if input_path.is_file():
141
+ zipf.write(input_path, input_path.name)
142
+ else:
143
+ for file_path in input_path.rglob('*'):
144
+ if file_path.is_file(): # Only add files, skip directories
145
+ arcname = file_path.relative_to(input_path.parent)
146
+ zipf.write(file_path, arcname)
147
+
148
+
149
+ def unarchive(file_path, output_path):
150
+ """
151
+ Unarchives a ZIP file to a given directory.
152
+
153
+ Parameters:
154
+ file_path (str | Path): The path to the ZIP file.
155
+ output_path (str): The directory where the files will be extracted.
156
+ """
157
+ output_path = Path(output_path)
158
+ output_path.mkdir(parents=True, exist_ok=True)
159
+
160
+ with zipfile.ZipFile(str(file_path), 'r') as zip_ref:
161
+ zip_ref.extractall(output_path)
162
+
163
+
164
+ def get_temp_path(sub_path=None):
165
+ path = Path('/tmp/datamaker')
166
+ if sub_path:
167
+ path = path / sub_path
168
+ return path
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: synapse-sdk
3
- Version: 1.0.0a15
3
+ Version: 1.0.0a17
4
4
  Summary: synapse sdk
5
5
  Author-email: datamaker <developer@datamaker.io>
6
6
  License: MIT
@@ -1,87 +0,0 @@
1
- import hashlib
2
- import json
3
- import operator
4
- import zipfile
5
- from functools import reduce
6
- from pathlib import Path
7
- from urllib.parse import urlparse
8
-
9
- import requests
10
- import yaml
11
-
12
-
13
- def download_file(url, path_download, name=None, coerce=None):
14
- if name:
15
- name += Path(url).suffix
16
- else:
17
- name = Path(url).name
18
-
19
- name = urlparse(name).path
20
- path = Path(path_download) / name
21
- if not path.is_file():
22
- r = requests.get(url, allow_redirects=True)
23
- open(str(path), 'wb').write(r.content)
24
-
25
- if coerce:
26
- path = coerce(path)
27
-
28
- return path
29
-
30
-
31
- def files_url_to_path(files, coerce=None):
32
- path_download = Path('/tmp/datamaker') / 'media'
33
- path_download.mkdir(parents=True, exist_ok=True)
34
- for file_name in files:
35
- if isinstance(files[file_name], str):
36
- files[file_name] = download_file(files[file_name], path_download, coerce=coerce)
37
- else:
38
- files[file_name]['path'] = download_file(files[file_name].pop('url'), path_download, coerce=coerce)
39
-
40
-
41
- def files_url_to_path_from_objs(objs, files_fields, coerce=None, is_list=False):
42
- if not is_list:
43
- objs = [objs]
44
-
45
- for obj in objs:
46
- for files_field in files_fields:
47
- try:
48
- files = reduce(operator.getitem, files_field.split('.'), obj)
49
- files_url_to_path(files, coerce=coerce)
50
- except KeyError:
51
- pass
52
-
53
-
54
- def get_dict_from_file(file_path):
55
- if isinstance(file_path, str):
56
- file_path = Path(file_path)
57
-
58
- with open(file_path) as f:
59
- if file_path.suffix == '.yaml':
60
- return yaml.safe_load(f)
61
- else:
62
- return json.load(f)
63
-
64
-
65
- def calculate_checksum(file_path, prefix=''):
66
- md5_hash = hashlib.md5()
67
- with open(file_path, 'rb') as f:
68
- for byte_block in iter(lambda: f.read(4096), b''):
69
- md5_hash.update(byte_block)
70
- checksum = md5_hash.hexdigest()
71
- if prefix:
72
- return f'dev-{checksum}'
73
- return checksum
74
-
75
-
76
- def archive(input_path, output_path):
77
- input_path = Path(input_path)
78
- output_path = Path(output_path)
79
-
80
- with zipfile.ZipFile(output_path, mode='w', compression=zipfile.ZIP_DEFLATED) as zipf:
81
- if input_path.is_file():
82
- zipf.write(input_path, input_path.name)
83
- else:
84
- for file_path in input_path.rglob('*'):
85
- if file_path.is_file(): # Only add files, skip directories
86
- arcname = file_path.relative_to(input_path.parent)
87
- zipf.write(file_path, arcname)
File without changes
File without changes
File without changes