wizata-dsapi 1.3.46__py3-none-any.whl → 1.3.48__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
@@ -29,7 +29,7 @@ class ModelIdentifierInfo:
29
29
  return obj
30
30
 
31
31
  def from_json(self, json_dict):
32
- if "active_alias" in json_dict:
32
+ if "active_alias" in json_dict and json_dict["active_alias"] is not None:
33
33
  self.active_alias = json_dict["active_alias"]
34
34
 
35
35
  class ModelFile:
@@ -310,6 +310,17 @@ class ModelInfo:
310
310
  raise RuntimeError("api is not bound to the dto use bind_api()")
311
311
  self._api.load_model(self)
312
312
 
313
+ def uncompress_bytes_to_model(self, bytes_model):
314
+ import io, joblib
315
+ if self.file_format == "pkl":
316
+ self.trained_model = joblib.load(io.BytesIO(bytes_model))
317
+ elif self.file_format == "pt":
318
+ import torch
319
+ buffer = io.BytesIO(bytes_model)
320
+ self.trained_model = torch.jit.load(buffer)
321
+ else:
322
+ raise RuntimeError(f'unsupported file format {self.file_format} must be pt or pkl')
323
+
313
324
 
314
325
  class ModelList:
315
326
  """
@@ -361,6 +372,21 @@ class ModelList:
361
372
  else:
362
373
  raise TypeError("ModelList indices must be int, str or ModelInfo.")
363
374
 
375
+ def select_all_active_model(self) -> list[ModelInfo]:
376
+ """
377
+ select all active model for all possible identifier.
378
+ :return: return a list of ModelInfo only with active models.
379
+ """
380
+ distinct_identifiers = []
381
+ for model in self.models:
382
+ identifier = model.identifier(include_alias=False)
383
+ if identifier not in distinct_identifiers:
384
+ distinct_identifiers.append(identifier)
385
+ models = []
386
+ for identifier in distinct_identifiers:
387
+ models.append(self.select_active_model(identifier=identifier))
388
+ return models
389
+
364
390
  def select_active_model(self, identifier: str) -> ModelInfo:
365
391
  """
366
392
  return the active model based on active status or latest one if none active.
@@ -374,7 +400,7 @@ class ModelList:
374
400
  return model
375
401
  else:
376
402
  models.append(model)
377
- return max(models, key=lambda f: f.updated_date, default=None)
403
+ return max(models, key=lambda f: f.updated_date or 0, default=None)
378
404
 
379
405
  def append(self, model: ModelInfo):
380
406
  self.models.append(model)
@@ -1,9 +1,9 @@
1
1
  import json
2
-
2
+ import os
3
+ import wizata_dsapi
3
4
  from .api_dto import ApiDto
4
5
  from .pipeline import Pipeline
5
6
  from .script import Script
6
- from .mlmodel import ModelInfo
7
7
  from datetime import datetime
8
8
 
9
9
  import pytz
@@ -11,7 +11,6 @@ import io
11
11
  import tarfile
12
12
  import gzip
13
13
  import dill
14
- import pickle
15
14
 
16
15
 
17
16
  def files_from_gzipped_data(gzipped_data):
@@ -153,7 +152,29 @@ class PipelineImage(ApiDto):
153
152
  # process the models
154
153
  model_files = {k: v for k, v in g_files.items() if k.startswith('models/')}
155
154
  for pkl_file in model_files:
156
- image.models[pkl_file[7:-4]] = pickle.loads(g_files[pkl_file])
155
+ parts = pkl_file.split('/')
156
+ if len(parts) == 2:
157
+ identifier = os.path.splitext(parts[1])[0]
158
+ else:
159
+ identifier = parts[1]
160
+
161
+ if identifier not in image.models:
162
+ key, twin_hardware_id, property_value, alias = wizata_dsapi.ModelInfo.split_identifier(identifier)
163
+ image.models[identifier] = wizata_dsapi.ModelInfo(
164
+ key=key,
165
+ twin_hardware_id=twin_hardware_id,
166
+ property_value=property_value,
167
+ alias=alias
168
+ )
169
+ if len(parts) == 2:
170
+ image.models[identifier].file_format = os.path.splitext(parts[1])[1].lstrip('.')
171
+ image.models[identifier].uncompress_bytes_to_model(g_files[pkl_file])
172
+ if len(parts) == 3:
173
+ image.models[identifier].add_file(wizata_dsapi.ModelFile(
174
+ full_path=pkl_file,
175
+ path=parts[2],
176
+ content=g_files[pkl_file]
177
+ ))
157
178
 
158
179
  return image
159
180
 
wizata_dsapi/version.py CHANGED
@@ -1 +1 @@
1
- __version__ = "1.3.46"
1
+ __version__ = "1.3.48"
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: wizata_dsapi
3
- Version: 1.3.46
3
+ Version: 1.3.48
4
4
  Summary: Wizata Data Science Toolkit
5
5
  Author: Wizata S.A.
6
6
  Author-email: info@wizata.com
@@ -16,12 +16,12 @@ 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=f7XmM1cuAufNo7hC5CFPlbDojTWWNfDdVnPYo2Kc0PU,24824
19
+ wizata_dsapi/mlmodel.py,sha256=YpnzTHUfRwuVdOO3IwhsLWHlIE0UH8nrY9ga73Gp_pE,25955
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=CtB6-HwJ2OtqUIbwAVTcawLmvYfudgIwGiPZARwTobM,31778
23
23
  wizata_dsapi/pipeline_deployment.py,sha256=grekBaxUK0EhL9w7lDB8vNuW_wzLnHVm9Mq8Lkbkguk,1722
24
- wizata_dsapi/pipeline_image.py,sha256=FUxaDDAOZHG8MA2xpZDoG7m1xbtiRSB8YuLFObUSd8c,5274
24
+ wizata_dsapi/pipeline_image.py,sha256=4DhDo1SYftN6QcNbehNbM86VTD6EYGmtlcOmE5DP5Vc,6330
25
25
  wizata_dsapi/plot.py,sha256=SPGKFWWYNcRvHcqvvnPIIIBKsd5UwhdsxLW7b2dG2rs,2360
26
26
  wizata_dsapi/request.py,sha256=W4E1BHacQdJiBLPI96yVeHz41rbfFuGrbuw1U60L_DM,27560
27
27
  wizata_dsapi/script.py,sha256=DeEciwVpuCYZetgJCoivw_bYe8ma52WuTaTQ_VkLEcg,12930
@@ -31,7 +31,7 @@ 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=5O78hV8ZBFKQKxB-un5qpit3OFVDyjX6JFd97JFh6aY,23
34
+ wizata_dsapi/version.py,sha256=J3iHKwFSmz-a5KrTbBRN9NJYHI5myM6ROUcZyRoDQOw,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
37
  wizata_dsapi/wizata_dsapi_client.py,sha256=PUFOt5b9OOBEjlgUgA4FtdtJyORzZ2eRv4VfWW4uH7E,84724
@@ -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.46.dist-info/licenses/LICENSE.txt,sha256=QwcOLU5TJoTeUhuIXzhdCEEDDvorGiC6-3YTOl4TecE,11356
46
- wizata_dsapi-1.3.46.dist-info/METADATA,sha256=YPJMA0vfCa6ZvoOVi2n_hqMXfFhFX6zWoZFEAyq3NIg,5651
47
- wizata_dsapi-1.3.46.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
48
- wizata_dsapi-1.3.46.dist-info/top_level.txt,sha256=-OeTJbEnh5DuWyTOHtvw0Dw3LRg3G27TNS6W4ZtfwPs,13
49
- wizata_dsapi-1.3.46.dist-info/RECORD,,
45
+ wizata_dsapi-1.3.48.dist-info/licenses/LICENSE.txt,sha256=QwcOLU5TJoTeUhuIXzhdCEEDDvorGiC6-3YTOl4TecE,11356
46
+ wizata_dsapi-1.3.48.dist-info/METADATA,sha256=ZRfFbCIchLf-PY8FwSxKUv1K0pQaB0fusUHZKTTeP-w,5651
47
+ wizata_dsapi-1.3.48.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
48
+ wizata_dsapi-1.3.48.dist-info/top_level.txt,sha256=-OeTJbEnh5DuWyTOHtvw0Dw3LRg3G27TNS6W4ZtfwPs,13
49
+ wizata_dsapi-1.3.48.dist-info/RECORD,,