wizata-dsapi 1.3.34__py3-none-any.whl → 1.3.35__py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
wizata_dsapi/mlmodel.py CHANGED
@@ -222,10 +222,6 @@ class ModelInfo:
222
222
  obj["alias"] = self.alias
223
223
  if self.model_type is not None:
224
224
  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
225
  if self.property_name is not None:
230
226
  obj["property_name"] = self.property_name
231
227
  if self.is_active is not None:
@@ -251,7 +247,7 @@ class ModelInfo:
251
247
  if "model_type" in obj.keys():
252
248
  self.model_type = obj["model_type"]
253
249
  if "file_format" in obj.keys():
254
- self.key = obj["file_format"]
250
+ self.file_format = obj["file_format"]
255
251
  if "source" in obj.keys():
256
252
  self.source = obj["source"]
257
253
  if "property_name" in obj.keys():
wizata_dsapi/version.py CHANGED
@@ -1 +1 @@
1
- __version__ = "1.3.34"
1
+ __version__ = "1.3.35"
@@ -1078,55 +1078,38 @@ 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, alias = ModelInfo.split_identifier(response_json["identifier"])
1108
+ if alias is not None:
1109
+ model_info.alias = alias
1110
+ return model_info
1111
+ else:
1112
+ raise self.__raise_error(response)
1130
1113
 
1131
1114
  def upsert_experiment(self, key: str, name: str, pipeline=None, twin=None):
1132
1115
  """
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: wizata-dsapi
3
- Version: 1.3.34
3
+ Version: 1.3.35
4
4
  Summary: Wizata Data Science Toolkit
5
5
  Author: Wizata S.A.
6
6
  Author-email: info@wizata.com
@@ -16,7 +16,7 @@ wizata_dsapi/experiment.py,sha256=QYQ1CJ-MTWsXq08xYbm5sAp95dRxbPOmGDgaAOoBMDQ,46
16
16
  wizata_dsapi/group_system.py,sha256=6rUKe0_J3YWACysyBlzuw_TEpKNXgLOMxhpWsNxOzwY,1708
17
17
  wizata_dsapi/ilogger.py,sha256=iYnID-Z-qrYhie26C43404aIuU4_tHSKXbDeQIdo82Q,807
18
18
  wizata_dsapi/insight.py,sha256=ABFZ04DqYxxzqAEfU1tzlTZqqrigM-zN-8Lbetko3g0,6468
19
- wizata_dsapi/mlmodel.py,sha256=8oRq6hoVAwN44490s7NrvlmzHVg6-8WO-Z60LrYARmU,22152
19
+ wizata_dsapi/mlmodel.py,sha256=VPfjdTAQ2X20kAkfAXKGGlqEUkzMCY9NcKVj422YYQ4,21993
20
20
  wizata_dsapi/model_toolkit.py,sha256=UNyw5CFSgZeXydQFsiDIRTjoMeqIsdyIIuiwumLW5bA,1574
21
21
  wizata_dsapi/paged_query_result.py,sha256=0Iyt2Kd4tvrfthhT-tk9EmSERsbJTaPNON2euHcBn6k,1150
22
22
  wizata_dsapi/pipeline.py,sha256=WDJeOxPZJiYW1qwTNZUm3jom2epIxqrSoiUwcrTF9EE,31300
@@ -31,10 +31,10 @@ wizata_dsapi/template.py,sha256=wtCRKKk3PchH4RrNgNYlEF_9C6bzZwKIeLyEvgv6Fdo,1370
31
31
  wizata_dsapi/trigger.py,sha256=w3BZYP-L3SUwvaT0oCTanh_Ewn57peZvlt7vxzHv9J8,5129
32
32
  wizata_dsapi/twin.py,sha256=S0DUzQf1smZXZTdXpXZPtkZYCfKIhw53EecCnsl9i4Q,11017
33
33
  wizata_dsapi/twinregistration.py,sha256=Mi6-YuwroiEXc0c1hgrOaphh4hNVoHupxOnXedVtJtE,13377
34
- wizata_dsapi/version.py,sha256=ZFzPwcVApl0WXETY3ii4RpYWOC9l9iNTKU07I0HChdg,23
34
+ wizata_dsapi/version.py,sha256=X9wwJLVQWqESOn2IYyoaDZxF1SSf2EHnlJd49iZiLGU,23
35
35
  wizata_dsapi/wizard_function.py,sha256=RbM7W7Gf-6Rhp_1dU9DBYkHaciknGAGvuAndhAS_vyo,942
36
36
  wizata_dsapi/wizard_request.py,sha256=v6BaqKLKvTWmUSo0_gda9FabAQz5x_-GOH1Av50GzFo,3762
37
- wizata_dsapi/wizata_dsapi_client.py,sha256=h8iSz7IGbP-Zq9rbqMdq-hTrt16laD1JeaRWPzaLaoo,77695
37
+ wizata_dsapi/wizata_dsapi_client.py,sha256=-4fE22nZPSTOzByt6mGebf774gPMoqvoIp33a3BLFis,76691
38
38
  wizata_dsapi/words.py,sha256=tV8CqzCqODZCV7PgBxBF5exBxeF_ya9t5DiUy-cg6Sg,1535
39
39
  wizata_dsapi/models/__init__.py,sha256=O5PHqw8lKILw4apO-MfDxPz73wK0vADD9y3xjuzX7Tw,104
40
40
  wizata_dsapi/models/common.py,sha256=1dTqE80-mFJnUwEdNlJdhJzfZ2N5Kp8Nb3LQ8uwPtLc,3808
@@ -42,8 +42,8 @@ wizata_dsapi/plots/__init__.py,sha256=qgnSFqrjOPur-807M8uh5awIfjM1ZHXUXcAqHc-r2l
42
42
  wizata_dsapi/plots/common.py,sha256=jdPsJqLHBwSKc6dX83BSGPqSRxzIVNHSYO5yI_8sjGk,6568
43
43
  wizata_dsapi/scripts/__init__.py,sha256=hAxiETSQf0qOHde1si1tEAJU48seqEgHrchCzS2-LvQ,80
44
44
  wizata_dsapi/scripts/common.py,sha256=efwq-Rd0lvYljIs3gSFz9izogBD7asOU2cTK-IvHTkM,4244
45
- wizata_dsapi-1.3.34.dist-info/LICENSE.txt,sha256=QwcOLU5TJoTeUhuIXzhdCEEDDvorGiC6-3YTOl4TecE,11356
46
- wizata_dsapi-1.3.34.dist-info/METADATA,sha256=f3XiXVKkbEnDaQ74Mgh0-JmqIpLDPGMBUQcyeHEHSCI,6119
47
- wizata_dsapi-1.3.34.dist-info/WHEEL,sha256=2wepM1nk4DS4eFpYrW1TTqPcoGNfHhhO_i5m4cOimbo,92
48
- wizata_dsapi-1.3.34.dist-info/top_level.txt,sha256=-OeTJbEnh5DuWyTOHtvw0Dw3LRg3G27TNS6W4ZtfwPs,13
49
- wizata_dsapi-1.3.34.dist-info/RECORD,,
45
+ wizata_dsapi-1.3.35.dist-info/LICENSE.txt,sha256=QwcOLU5TJoTeUhuIXzhdCEEDDvorGiC6-3YTOl4TecE,11356
46
+ wizata_dsapi-1.3.35.dist-info/METADATA,sha256=wl5Nn6q8EQA8vJToONdXUGyW3pEh51dNe4DtveHaD4A,6119
47
+ wizata_dsapi-1.3.35.dist-info/WHEEL,sha256=2wepM1nk4DS4eFpYrW1TTqPcoGNfHhhO_i5m4cOimbo,92
48
+ wizata_dsapi-1.3.35.dist-info/top_level.txt,sha256=-OeTJbEnh5DuWyTOHtvw0Dw3LRg3G27TNS6W4ZtfwPs,13
49
+ wizata_dsapi-1.3.35.dist-info/RECORD,,