wizata-dsapi 1.3.34__tar.gz → 1.3.36__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.34 → wizata_dsapi-1.3.36}/PKG-INFO +1 -1
  2. {wizata_dsapi-1.3.34 → wizata_dsapi-1.3.36}/wizata_dsapi/mlmodel.py +26 -11
  3. wizata_dsapi-1.3.36/wizata_dsapi/version.py +1 -0
  4. {wizata_dsapi-1.3.34 → wizata_dsapi-1.3.36}/wizata_dsapi/wizata_dsapi_client.py +41 -49
  5. {wizata_dsapi-1.3.34 → wizata_dsapi-1.3.36}/wizata_dsapi.egg-info/PKG-INFO +1 -1
  6. wizata_dsapi-1.3.34/wizata_dsapi/version.py +0 -1
  7. {wizata_dsapi-1.3.34 → wizata_dsapi-1.3.36}/LICENSE.txt +0 -0
  8. {wizata_dsapi-1.3.34 → wizata_dsapi-1.3.36}/README.rst +0 -0
  9. {wizata_dsapi-1.3.34 → wizata_dsapi-1.3.36}/setup.cfg +0 -0
  10. {wizata_dsapi-1.3.34 → wizata_dsapi-1.3.36}/setup.py +0 -0
  11. {wizata_dsapi-1.3.34 → wizata_dsapi-1.3.36}/wizata_dsapi/__init__.py +0 -0
  12. {wizata_dsapi-1.3.34 → wizata_dsapi-1.3.36}/wizata_dsapi/api_config.py +0 -0
  13. {wizata_dsapi-1.3.34 → wizata_dsapi-1.3.36}/wizata_dsapi/api_dto.py +0 -0
  14. {wizata_dsapi-1.3.34 → wizata_dsapi-1.3.36}/wizata_dsapi/api_interface.py +0 -0
  15. {wizata_dsapi-1.3.34 → wizata_dsapi-1.3.36}/wizata_dsapi/bucket.py +0 -0
  16. {wizata_dsapi-1.3.34 → wizata_dsapi-1.3.36}/wizata_dsapi/business_label.py +0 -0
  17. {wizata_dsapi-1.3.34 → wizata_dsapi-1.3.36}/wizata_dsapi/context.py +0 -0
  18. {wizata_dsapi-1.3.34 → wizata_dsapi-1.3.36}/wizata_dsapi/dataframe_toolkit.py +0 -0
  19. {wizata_dsapi-1.3.34 → wizata_dsapi-1.3.36}/wizata_dsapi/datapoint.py +0 -0
  20. {wizata_dsapi-1.3.34 → wizata_dsapi-1.3.36}/wizata_dsapi/datastore.py +0 -0
  21. {wizata_dsapi-1.3.34 → wizata_dsapi-1.3.36}/wizata_dsapi/ds_dataframe.py +0 -0
  22. {wizata_dsapi-1.3.34 → wizata_dsapi-1.3.36}/wizata_dsapi/dsapi_json_encoder.py +0 -0
  23. {wizata_dsapi-1.3.34 → wizata_dsapi-1.3.36}/wizata_dsapi/evaluation.py +0 -0
  24. {wizata_dsapi-1.3.34 → wizata_dsapi-1.3.36}/wizata_dsapi/execution.py +0 -0
  25. {wizata_dsapi-1.3.34 → wizata_dsapi-1.3.36}/wizata_dsapi/experiment.py +0 -0
  26. {wizata_dsapi-1.3.34 → wizata_dsapi-1.3.36}/wizata_dsapi/group_system.py +0 -0
  27. {wizata_dsapi-1.3.34 → wizata_dsapi-1.3.36}/wizata_dsapi/ilogger.py +0 -0
  28. {wizata_dsapi-1.3.34 → wizata_dsapi-1.3.36}/wizata_dsapi/insight.py +0 -0
  29. {wizata_dsapi-1.3.34 → wizata_dsapi-1.3.36}/wizata_dsapi/model_toolkit.py +0 -0
  30. {wizata_dsapi-1.3.34 → wizata_dsapi-1.3.36}/wizata_dsapi/models/__init__.py +0 -0
  31. {wizata_dsapi-1.3.34 → wizata_dsapi-1.3.36}/wizata_dsapi/models/common.py +0 -0
  32. {wizata_dsapi-1.3.34 → wizata_dsapi-1.3.36}/wizata_dsapi/paged_query_result.py +0 -0
  33. {wizata_dsapi-1.3.34 → wizata_dsapi-1.3.36}/wizata_dsapi/pipeline.py +0 -0
  34. {wizata_dsapi-1.3.34 → wizata_dsapi-1.3.36}/wizata_dsapi/pipeline_image.py +0 -0
  35. {wizata_dsapi-1.3.34 → wizata_dsapi-1.3.36}/wizata_dsapi/plot.py +0 -0
  36. {wizata_dsapi-1.3.34 → wizata_dsapi-1.3.36}/wizata_dsapi/plots/__init__.py +0 -0
  37. {wizata_dsapi-1.3.34 → wizata_dsapi-1.3.36}/wizata_dsapi/plots/common.py +0 -0
  38. {wizata_dsapi-1.3.34 → wizata_dsapi-1.3.36}/wizata_dsapi/request.py +0 -0
  39. {wizata_dsapi-1.3.34 → wizata_dsapi-1.3.36}/wizata_dsapi/script.py +0 -0
  40. {wizata_dsapi-1.3.34 → wizata_dsapi-1.3.36}/wizata_dsapi/scripts/__init__.py +0 -0
  41. {wizata_dsapi-1.3.34 → wizata_dsapi-1.3.36}/wizata_dsapi/scripts/common.py +0 -0
  42. {wizata_dsapi-1.3.34 → wizata_dsapi-1.3.36}/wizata_dsapi/solution_component.py +0 -0
  43. {wizata_dsapi-1.3.34 → wizata_dsapi-1.3.36}/wizata_dsapi/streamlit_utils.py +0 -0
  44. {wizata_dsapi-1.3.34 → wizata_dsapi-1.3.36}/wizata_dsapi/template.py +0 -0
  45. {wizata_dsapi-1.3.34 → wizata_dsapi-1.3.36}/wizata_dsapi/trigger.py +0 -0
  46. {wizata_dsapi-1.3.34 → wizata_dsapi-1.3.36}/wizata_dsapi/twin.py +0 -0
  47. {wizata_dsapi-1.3.34 → wizata_dsapi-1.3.36}/wizata_dsapi/twinregistration.py +0 -0
  48. {wizata_dsapi-1.3.34 → wizata_dsapi-1.3.36}/wizata_dsapi/wizard_function.py +0 -0
  49. {wizata_dsapi-1.3.34 → wizata_dsapi-1.3.36}/wizata_dsapi/wizard_request.py +0 -0
  50. {wizata_dsapi-1.3.34 → wizata_dsapi-1.3.36}/wizata_dsapi/words.py +0 -0
  51. {wizata_dsapi-1.3.34 → wizata_dsapi-1.3.36}/wizata_dsapi.egg-info/SOURCES.txt +0 -0
  52. {wizata_dsapi-1.3.34 → wizata_dsapi-1.3.36}/wizata_dsapi.egg-info/dependency_links.txt +0 -0
  53. {wizata_dsapi-1.3.34 → wizata_dsapi-1.3.36}/wizata_dsapi.egg-info/requires.txt +0 -0
  54. {wizata_dsapi-1.3.34 → wizata_dsapi-1.3.36}/wizata_dsapi.egg-info/top_level.txt +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: wizata_dsapi
3
- Version: 1.3.34
3
+ Version: 1.3.36
4
4
  Summary: Wizata Data Science Toolkit
5
5
  Author: Wizata S.A.
6
6
  Author-email: info@wizata.com
@@ -1,4 +1,4 @@
1
- from typing import List, Iterator, Union
1
+ from typing import List, Iterator, Union, Optional
2
2
  import os
3
3
  from .api_dto import ApiDto
4
4
  from datetime import datetime, timezone
@@ -49,13 +49,32 @@ class ModelFile:
49
49
  size: int = None,
50
50
  content = None):
51
51
  self.full_path = full_path
52
- self.path = path
53
52
  self.name = name
54
53
  self.extension = extension
54
+ self.path = path
55
55
  self.last_modified = last_modified
56
56
  self.size = size
57
57
  self.content = content
58
58
 
59
+
60
+ @property
61
+ def path(self) -> Optional[str]:
62
+ if self.name and self.extension:
63
+ return f"{self.name}.{self.extension}"
64
+ return self.name or None
65
+
66
+ @path.setter
67
+ def path(self, value: Optional[str]):
68
+ if not value:
69
+ self.name = None
70
+ self.extension = None
71
+ return
72
+
73
+ base = os.path.basename(value.strip())
74
+ name_part, ext = os.path.splitext(base)
75
+ self.name = name_part or None
76
+ self.extension = ext.lstrip(".").lower() if ext else None
77
+
59
78
  def to_json(self):
60
79
  """
61
80
  convert this entity in a dict that can be json serializable
@@ -64,12 +83,12 @@ class ModelFile:
64
83
  obj = {}
65
84
  if self.full_path is not None:
66
85
  obj["full_path"] = str(self.full_path)
67
- if self.path is not None:
68
- obj["path"] = self.path
69
86
  if self.name is not None:
70
87
  obj["name"] = self.name
71
88
  if self.extension is not None:
72
89
  obj["extension"] = self.extension
90
+ if self.path is not None:
91
+ obj["path"] = self.path
73
92
  if self.last_modified is not None:
74
93
  obj["last_modified"] = self.last_modified.timestamp() * 1000.0
75
94
  if self.size is not None:
@@ -82,12 +101,12 @@ class ModelFile:
82
101
  """
83
102
  if "full_path" in obj.keys():
84
103
  self.full_path = obj["full_path"]
85
- if "path" in obj.keys():
86
- self.path = obj["path"]
87
104
  if "name" in obj.keys():
88
105
  self.name = obj["name"]
89
106
  if "extension" in obj.keys():
90
107
  self.extension = obj["extension"]
108
+ if not self.name and not self.extension and "path" in obj:
109
+ self.path = obj["path"]
91
110
  if "last_modified" in obj.keys():
92
111
  self.last_modified = datetime.fromtimestamp(obj["last_modified"] / 1000, tz=timezone.utc)
93
112
  if "size" in obj.keys():
@@ -222,10 +241,6 @@ class ModelInfo:
222
241
  obj["alias"] = self.alias
223
242
  if self.model_type is not None:
224
243
  obj["model_type"] = self.model_type
225
- if self.file_format is not None:
226
- obj["file_format"] = self.file_format
227
- if self.source is not None:
228
- obj["source"] = self.source
229
244
  if self.property_name is not None:
230
245
  obj["property_name"] = self.property_name
231
246
  if self.is_active is not None:
@@ -251,7 +266,7 @@ class ModelInfo:
251
266
  if "model_type" in obj.keys():
252
267
  self.model_type = obj["model_type"]
253
268
  if "file_format" in obj.keys():
254
- self.key = obj["file_format"]
269
+ self.file_format = obj["file_format"]
255
270
  if "source" in obj.keys():
256
271
  self.source = obj["source"]
257
272
  if "property_name" in obj.keys():
@@ -0,0 +1 @@
1
+ __version__ = "1.3.36"
@@ -1078,55 +1078,47 @@ class WizataDSAPIClient(ApiInterface):
1078
1078
  else:
1079
1079
  raise self.__raise_error(response)
1080
1080
 
1081
- def register_model(self,
1082
- model_key,
1083
- train_model,
1084
- df: pandas.DataFrame,
1085
- scaler=None,
1086
- has_anomalies: bool = False,
1087
- has_target_feat: bool = False,
1088
- experiment_key = None) -> tuple[ModelInfo, pandas.DataFrame]:
1089
- """
1090
- Register a Machine Learning model to Wizata.
1091
- Model is tested by the API against a sample dataframe.
1092
- :param model_key: logical string id to identify the model.
1093
- :param train_model: trained model (must be compatible with pickle library)
1094
- :param df: sample dataframe.
1095
- :param scaler: scaler (must be compatible with pickle library)
1096
- :param has_anomalies: True is model generate Anomalies
1097
- :param has_target_feat: True if model need a target feature to be selected
1098
- :param experiment_key: Reference of an experiment to which link the generated ML Model
1099
- :return: registered ML Model , pandas.DataFrame
1100
- """
1101
- if model_key is None and isinstance(model_key, str):
1102
- raise ValueError('Please provide a str Model Key to identify the model.')
1103
- if train_model is None:
1104
- raise ValueError('Trained Machine Learning model should not be null')
1105
- elif df is None:
1106
- raise ValueError('A sample dataframe must be provided')
1107
-
1108
- ml_model = ModelInfo(key=model_key)
1109
- ml_model.trained_model = train_model
1110
- if scaler is not None:
1111
- ml_model.scaler = scaler
1112
- ml_model.has_anomalies = has_anomalies
1113
- ml_model.has_target_feat = has_target_feat
1114
- ml_model.input_columns = df.columns
1115
-
1116
- if experiment_key is not None:
1117
- ml_model.experimentId = self.get(experiment_key=experiment_key).experiment_id
1118
-
1119
- try:
1120
- result_df = predict(df, ml_model)
1121
- if result_df is not None:
1122
- ml_model.status = "valid"
1123
- #TODO: proper method to upload and download from registry to modify this one
1124
- ## self.upsert(ml_model)
1125
- return ml_model, result_df
1126
- else:
1127
- raise RuntimeError('no dataframe was generated by your model while testing predict capabilities')
1128
- except Exception as e:
1129
- raise RuntimeError('not able to validated the model : ' + str(e))
1081
+ def upload_model(self,
1082
+ model_info: ModelInfo):
1083
+ """
1084
+ upload a model within the model repository.
1085
+ :param model_info: model info, with at least key (+twin, +property, +alias) and trained_model.
1086
+ """
1087
+ if model_info.trained_model is None:
1088
+ raise ValueError("model_info must have a trained model as bytes content pkl or pt")
1089
+ files = {
1090
+ "trained_model": (
1091
+ "trained_model." + model_info.file_format ,
1092
+ model_info.trained_model,
1093
+ "application/octet-stream",
1094
+ )
1095
+ }
1096
+ headers = self.__header()
1097
+ headers.pop("Content-Type", None)
1098
+ response = requests.post(self.__url() + f"models",
1099
+ headers=headers,
1100
+ data={
1101
+ "payload": json.dumps(model_info.to_json())
1102
+ },
1103
+ files=files)
1104
+ if response.status_code == 200:
1105
+ response_json = response.json()
1106
+ if "identifier" in response_json:
1107
+ key , twin, property_value, alias = ModelInfo.split_identifier(response_json["identifier"])
1108
+ if alias is not None:
1109
+ model_info.alias = alias
1110
+ for file in model_info.files:
1111
+ file: wizata_dsapi.ModelFile
1112
+ if file.name != "trained_model":
1113
+ headers["Content-Type"] = "application/octet-stream"
1114
+ response = requests.post(self.__url() + f"models/{model_info.identifier(include_alias=True)}/files/{file.name}",
1115
+ data=file.content,
1116
+ timeout=60)
1117
+ if response.status_code != 200 and response.status_code != 201:
1118
+ raise self.__raise_error(response)
1119
+ return model_info
1120
+ else:
1121
+ raise self.__raise_error(response)
1130
1122
 
1131
1123
  def upsert_experiment(self, key: str, name: str, pipeline=None, twin=None):
1132
1124
  """
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: wizata-dsapi
3
- Version: 1.3.34
3
+ Version: 1.3.36
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.34"
File without changes
File without changes
File without changes
File without changes