wizata-dsapi 1.3.43__tar.gz → 1.3.45__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.
Files changed (54) hide show
  1. {wizata_dsapi-1.3.43/wizata_dsapi.egg-info → wizata_dsapi-1.3.45}/PKG-INFO +1 -1
  2. {wizata_dsapi-1.3.43 → wizata_dsapi-1.3.45}/wizata_dsapi/api_config.py +6 -0
  3. {wizata_dsapi-1.3.43 → wizata_dsapi-1.3.45}/wizata_dsapi/api_interface.py +56 -0
  4. {wizata_dsapi-1.3.43 → wizata_dsapi-1.3.45}/wizata_dsapi/context.py +32 -10
  5. {wizata_dsapi-1.3.43 → wizata_dsapi-1.3.45}/wizata_dsapi/mlmodel.py +8 -2
  6. wizata_dsapi-1.3.45/wizata_dsapi/version.py +1 -0
  7. {wizata_dsapi-1.3.43 → wizata_dsapi-1.3.45/wizata_dsapi.egg-info}/PKG-INFO +1 -1
  8. wizata_dsapi-1.3.43/wizata_dsapi/version.py +0 -1
  9. {wizata_dsapi-1.3.43 → wizata_dsapi-1.3.45}/LICENSE.txt +0 -0
  10. {wizata_dsapi-1.3.43 → wizata_dsapi-1.3.45}/README.rst +0 -0
  11. {wizata_dsapi-1.3.43 → wizata_dsapi-1.3.45}/setup.cfg +0 -0
  12. {wizata_dsapi-1.3.43 → wizata_dsapi-1.3.45}/setup.py +0 -0
  13. {wizata_dsapi-1.3.43 → wizata_dsapi-1.3.45}/wizata_dsapi/__init__.py +0 -0
  14. {wizata_dsapi-1.3.43 → wizata_dsapi-1.3.45}/wizata_dsapi/api_dto.py +0 -0
  15. {wizata_dsapi-1.3.43 → wizata_dsapi-1.3.45}/wizata_dsapi/bucket.py +0 -0
  16. {wizata_dsapi-1.3.43 → wizata_dsapi-1.3.45}/wizata_dsapi/business_label.py +0 -0
  17. {wizata_dsapi-1.3.43 → wizata_dsapi-1.3.45}/wizata_dsapi/dataframe_toolkit.py +0 -0
  18. {wizata_dsapi-1.3.43 → wizata_dsapi-1.3.45}/wizata_dsapi/datapoint.py +0 -0
  19. {wizata_dsapi-1.3.43 → wizata_dsapi-1.3.45}/wizata_dsapi/datastore.py +0 -0
  20. {wizata_dsapi-1.3.43 → wizata_dsapi-1.3.45}/wizata_dsapi/ds_dataframe.py +0 -0
  21. {wizata_dsapi-1.3.43 → wizata_dsapi-1.3.45}/wizata_dsapi/dsapi_json_encoder.py +0 -0
  22. {wizata_dsapi-1.3.43 → wizata_dsapi-1.3.45}/wizata_dsapi/evaluation.py +0 -0
  23. {wizata_dsapi-1.3.43 → wizata_dsapi-1.3.45}/wizata_dsapi/execution.py +0 -0
  24. {wizata_dsapi-1.3.43 → wizata_dsapi-1.3.45}/wizata_dsapi/experiment.py +0 -0
  25. {wizata_dsapi-1.3.43 → wizata_dsapi-1.3.45}/wizata_dsapi/group_system.py +0 -0
  26. {wizata_dsapi-1.3.43 → wizata_dsapi-1.3.45}/wizata_dsapi/ilogger.py +0 -0
  27. {wizata_dsapi-1.3.43 → wizata_dsapi-1.3.45}/wizata_dsapi/insight.py +0 -0
  28. {wizata_dsapi-1.3.43 → wizata_dsapi-1.3.45}/wizata_dsapi/model_toolkit.py +0 -0
  29. {wizata_dsapi-1.3.43 → wizata_dsapi-1.3.45}/wizata_dsapi/models/__init__.py +0 -0
  30. {wizata_dsapi-1.3.43 → wizata_dsapi-1.3.45}/wizata_dsapi/models/common.py +0 -0
  31. {wizata_dsapi-1.3.43 → wizata_dsapi-1.3.45}/wizata_dsapi/paged_query_result.py +0 -0
  32. {wizata_dsapi-1.3.43 → wizata_dsapi-1.3.45}/wizata_dsapi/pipeline.py +0 -0
  33. {wizata_dsapi-1.3.43 → wizata_dsapi-1.3.45}/wizata_dsapi/pipeline_image.py +0 -0
  34. {wizata_dsapi-1.3.43 → wizata_dsapi-1.3.45}/wizata_dsapi/plot.py +0 -0
  35. {wizata_dsapi-1.3.43 → wizata_dsapi-1.3.45}/wizata_dsapi/plots/__init__.py +0 -0
  36. {wizata_dsapi-1.3.43 → wizata_dsapi-1.3.45}/wizata_dsapi/plots/common.py +0 -0
  37. {wizata_dsapi-1.3.43 → wizata_dsapi-1.3.45}/wizata_dsapi/request.py +0 -0
  38. {wizata_dsapi-1.3.43 → wizata_dsapi-1.3.45}/wizata_dsapi/script.py +0 -0
  39. {wizata_dsapi-1.3.43 → wizata_dsapi-1.3.45}/wizata_dsapi/scripts/__init__.py +0 -0
  40. {wizata_dsapi-1.3.43 → wizata_dsapi-1.3.45}/wizata_dsapi/scripts/common.py +0 -0
  41. {wizata_dsapi-1.3.43 → wizata_dsapi-1.3.45}/wizata_dsapi/solution_component.py +0 -0
  42. {wizata_dsapi-1.3.43 → wizata_dsapi-1.3.45}/wizata_dsapi/streamlit_utils.py +0 -0
  43. {wizata_dsapi-1.3.43 → wizata_dsapi-1.3.45}/wizata_dsapi/template.py +0 -0
  44. {wizata_dsapi-1.3.43 → wizata_dsapi-1.3.45}/wizata_dsapi/trigger.py +0 -0
  45. {wizata_dsapi-1.3.43 → wizata_dsapi-1.3.45}/wizata_dsapi/twin.py +0 -0
  46. {wizata_dsapi-1.3.43 → wizata_dsapi-1.3.45}/wizata_dsapi/twinregistration.py +0 -0
  47. {wizata_dsapi-1.3.43 → wizata_dsapi-1.3.45}/wizata_dsapi/wizard_function.py +0 -0
  48. {wizata_dsapi-1.3.43 → wizata_dsapi-1.3.45}/wizata_dsapi/wizard_request.py +0 -0
  49. {wizata_dsapi-1.3.43 → wizata_dsapi-1.3.45}/wizata_dsapi/wizata_dsapi_client.py +0 -0
  50. {wizata_dsapi-1.3.43 → wizata_dsapi-1.3.45}/wizata_dsapi/words.py +0 -0
  51. {wizata_dsapi-1.3.43 → wizata_dsapi-1.3.45}/wizata_dsapi.egg-info/SOURCES.txt +0 -0
  52. {wizata_dsapi-1.3.43 → wizata_dsapi-1.3.45}/wizata_dsapi.egg-info/dependency_links.txt +0 -0
  53. {wizata_dsapi-1.3.43 → wizata_dsapi-1.3.45}/wizata_dsapi.egg-info/requires.txt +0 -0
  54. {wizata_dsapi-1.3.43 → wizata_dsapi-1.3.45}/wizata_dsapi.egg-info/top_level.txt +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: wizata_dsapi
3
- Version: 1.3.43
3
+ Version: 1.3.45
4
4
  Summary: Wizata Data Science Toolkit
5
5
  Author: Wizata S.A.
6
6
  Author-email: info@wizata.com
@@ -76,6 +76,12 @@ _registry = {
76
76
  "cloud_dsapi": ['lists', 'get_by_id', 'create', 'update', 'delete', 'search'],
77
77
  "cloud_context": ['get_by_id', 'create', 'update', 'delete', 'search']
78
78
  },
79
+ "models":
80
+ {
81
+ "class": ModelInfo,
82
+ "cloud_dsapi": ['download_model', 'download_file' , 'upload_model' , 'upload_file'],
83
+ "cloud_context": ['download_model' , 'download_file' , 'upload_model' , 'upload_file']
84
+ },
79
85
  "pipelines":
80
86
  {
81
87
  "class": Pipeline,
@@ -2,6 +2,7 @@ import uuid
2
2
  from .solution_component import SolutionComponent
3
3
  from .paged_query_result import PagedQueryResult
4
4
  from .pipeline import AlertType
5
+ from .mlmodel import ModelInfo, ModelFile
5
6
  from datetime import datetime
6
7
  import pandas
7
8
 
@@ -276,3 +277,58 @@ class ApiInterface:
276
277
  :param list cc: for email only - cc recipients list.
277
278
  """
278
279
  pass
280
+
281
+ def download_model(self, identifier: str) -> ModelInfo:
282
+ """
283
+ download a model image directly from the repository, auto-select alias if necessary.
284
+ :param identifier: exact identifier including alias of the model or no alias to auto-select active version.
285
+ :return: ModelInfo with trained_model loaded, extra file must be downloaded separately.
286
+ """
287
+ pass
288
+
289
+ def download_file(self,
290
+ model: ModelInfo = None,
291
+ file: ModelFile = None,
292
+ identifier: str = None,
293
+ path: str = None):
294
+ """
295
+ download a model extra file from the repository.
296
+ :param model: model (ModelInfo), alternatively can use identifier
297
+ :param file: file (ModelFile), alternatively can use path
298
+ :param identifier: identifier including alias of the model.
299
+ :param path: path name of the file including the extension.
300
+ :return: bytes content.
301
+ """
302
+ pass
303
+
304
+ def upload_file(self,
305
+ content,
306
+ model: ModelInfo = None,
307
+ file: ModelFile = None,
308
+ identifier: str = None,
309
+ path: str = None
310
+ ):
311
+ """
312
+ upload a model extra file to the repository.
313
+ please use upload_model for a trained_model
314
+ :param content: the bytes content of the file.
315
+ :param model: model (ModelInfo), alternatively can use identifier
316
+ :param file: file (ModelFile), alternatively can use path
317
+ :param identifier: identifier including alias of the model.
318
+ :param path: path name of the file including the extension.
319
+ :return: bytes content.
320
+ """
321
+ pass
322
+
323
+ def upload_model(self,
324
+ model_info: ModelInfo,
325
+ bytes_content=None):
326
+ """
327
+ upload a model within the model repository.
328
+ - by default use model_info.trained_model and convert it to a pickle
329
+ - for already torch or pickle please pass the bytes_content
330
+ - model_info.file_format must be set properly to 'pkl' or 'pt'
331
+ :param model_info: model info, with at least key (+twin, +property, +alias) and trained_model.
332
+ :param bytes_content: bytes[] of your torch or pickle model.
333
+ """
334
+ pass
@@ -1,7 +1,11 @@
1
1
  import uuid
2
2
  import pandas
3
+ import numpy as np
4
+ import io
5
+ import json
6
+ import pickle
3
7
 
4
- from .mlmodel import ModelInfo
8
+ from .mlmodel import ModelInfo, ModelFile
5
9
  from .plot import Plot
6
10
  from .ilogger import ILogger
7
11
  from .api_interface import ApiInterface
@@ -188,22 +192,40 @@ class Context(ILogger):
188
192
  if self.__new_plot is not None:
189
193
  return self.__new_plot.figure
190
194
 
191
- def set_model(self, trained_model, input_columns, output_columns=None, has_anomalies=False, scaler=None):
195
+ def set_model(self,
196
+ trained_model,
197
+ **kwargs):
192
198
  """
193
199
  set model to be added to the context.
194
200
  :param trained_model: Trained Model to be stored as a pickled object.
195
- :param list input_columns: List of str defining input columns to call the model (df.columns)
196
- :param list output_columns: List of output columns - Optional as can be detected automatically during validation.
197
- :param bool has_anomalies: False by default, define if the model set anomalies
198
- :param scaler: Scaler to be stored if necessary.
199
- :return: ML Model object prepared.
201
+ :param scaler: Scaler extra file to be stored.
202
+ :return: ModelInfo object
200
203
  """
201
204
  model_info = ModelInfo(key="undefined")
202
205
  model_info.trained_model = trained_model
206
+
207
+ scaler = kwargs.pop("scaler", None)
203
208
  model_info.scaler = scaler
204
- model_info.input_columns = input_columns
205
- model_info.output_columns = output_columns
206
- model_info.has_anomalies = has_anomalies
209
+
210
+ for key, value in kwargs.items():
211
+
212
+ if isinstance(value, (pandas.Index, pandas.Series, np.ndarray)):
213
+ content = json.dumps(value.tolist()).encode('utf-8')
214
+ filename = f"{key}.json"
215
+ elif isinstance(value, (dict, list)):
216
+ content = json.dumps(value).encode('utf-8')
217
+ filename = f"{key}.json"
218
+ else:
219
+ content = pickle.dumps(value)
220
+ filename = f"{key}.pkl"
221
+
222
+ model_info.add_file(
223
+ file=ModelFile(
224
+ content=io.BytesIO(content),
225
+ path=filename
226
+ )
227
+ )
228
+
207
229
  self.__new_model = model_info
208
230
  return model_info
209
231
 
@@ -133,7 +133,8 @@ class ModelInfo:
133
133
  trained_model = None,
134
134
  scaler = None,
135
135
  files = None,
136
- updated_date = None
136
+ updated_date = None,
137
+ metadata: dict = None
137
138
  ):
138
139
  # information identifying a model
139
140
  self.key = key
@@ -153,7 +154,8 @@ class ModelInfo:
153
154
  if not isinstance(file, ModelFile):
154
155
  raise TypeError("file is not a ModelFile with files")
155
156
  self.is_active = False
156
- self.updated_date = None
157
+ self.updated_date = updated_date
158
+ self.metadata = metadata
157
159
 
158
160
  # files attached to model when loaded
159
161
  self.trained_model = trained_model
@@ -264,6 +266,8 @@ class ModelInfo:
264
266
  obj["files"] = [file.to_json() for file in self.files]
265
267
  if self.updated_date is not None:
266
268
  obj["updatedDate"] = str(self.updated_date)
269
+ if self.metadata is not None:
270
+ obj["metadata"] = self.metadata
267
271
  return obj
268
272
 
269
273
  def from_json(self, obj):
@@ -290,6 +294,8 @@ class ModelInfo:
290
294
  self.is_active = get_bool(obj, name="is_active")
291
295
  if "updatedDate" in obj.keys() and obj["updatedDate"] is not None:
292
296
  self.updated_date = obj["updatedDate"]
297
+ if "metadata" in obj.keys() and obj["metadata"] is not None:
298
+ self.metadata = obj["metadata"]
293
299
  if "files" in obj.keys():
294
300
  for obj_file in obj["files"]:
295
301
  model_file = ModelFile()
@@ -0,0 +1 @@
1
+ __version__ = "1.3.45"
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: wizata_dsapi
3
- Version: 1.3.43
3
+ Version: 1.3.45
4
4
  Summary: Wizata Data Science Toolkit
5
5
  Author: Wizata S.A.
6
6
  Author-email: info@wizata.com
@@ -1 +0,0 @@
1
- __version__ = "1.3.43"
File without changes
File without changes
File without changes
File without changes