wizata-dsapi 1.3.45__tar.gz → 1.3.47__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.45/wizata_dsapi.egg-info → wizata_dsapi-1.3.47}/PKG-INFO +1 -1
  2. {wizata_dsapi-1.3.45 → wizata_dsapi-1.3.47}/wizata_dsapi/mlmodel.py +27 -1
  3. {wizata_dsapi-1.3.45 → wizata_dsapi-1.3.47}/wizata_dsapi/pipeline_image.py +25 -4
  4. wizata_dsapi-1.3.47/wizata_dsapi/version.py +1 -0
  5. {wizata_dsapi-1.3.45 → wizata_dsapi-1.3.47}/wizata_dsapi/wizata_dsapi_client.py +17 -4
  6. {wizata_dsapi-1.3.45 → wizata_dsapi-1.3.47/wizata_dsapi.egg-info}/PKG-INFO +1 -1
  7. wizata_dsapi-1.3.45/wizata_dsapi/version.py +0 -1
  8. {wizata_dsapi-1.3.45 → wizata_dsapi-1.3.47}/LICENSE.txt +0 -0
  9. {wizata_dsapi-1.3.45 → wizata_dsapi-1.3.47}/README.rst +0 -0
  10. {wizata_dsapi-1.3.45 → wizata_dsapi-1.3.47}/setup.cfg +0 -0
  11. {wizata_dsapi-1.3.45 → wizata_dsapi-1.3.47}/setup.py +0 -0
  12. {wizata_dsapi-1.3.45 → wizata_dsapi-1.3.47}/wizata_dsapi/__init__.py +0 -0
  13. {wizata_dsapi-1.3.45 → wizata_dsapi-1.3.47}/wizata_dsapi/api_config.py +0 -0
  14. {wizata_dsapi-1.3.45 → wizata_dsapi-1.3.47}/wizata_dsapi/api_dto.py +0 -0
  15. {wizata_dsapi-1.3.45 → wizata_dsapi-1.3.47}/wizata_dsapi/api_interface.py +0 -0
  16. {wizata_dsapi-1.3.45 → wizata_dsapi-1.3.47}/wizata_dsapi/bucket.py +0 -0
  17. {wizata_dsapi-1.3.45 → wizata_dsapi-1.3.47}/wizata_dsapi/business_label.py +0 -0
  18. {wizata_dsapi-1.3.45 → wizata_dsapi-1.3.47}/wizata_dsapi/context.py +0 -0
  19. {wizata_dsapi-1.3.45 → wizata_dsapi-1.3.47}/wizata_dsapi/dataframe_toolkit.py +0 -0
  20. {wizata_dsapi-1.3.45 → wizata_dsapi-1.3.47}/wizata_dsapi/datapoint.py +0 -0
  21. {wizata_dsapi-1.3.45 → wizata_dsapi-1.3.47}/wizata_dsapi/datastore.py +0 -0
  22. {wizata_dsapi-1.3.45 → wizata_dsapi-1.3.47}/wizata_dsapi/ds_dataframe.py +0 -0
  23. {wizata_dsapi-1.3.45 → wizata_dsapi-1.3.47}/wizata_dsapi/dsapi_json_encoder.py +0 -0
  24. {wizata_dsapi-1.3.45 → wizata_dsapi-1.3.47}/wizata_dsapi/evaluation.py +0 -0
  25. {wizata_dsapi-1.3.45 → wizata_dsapi-1.3.47}/wizata_dsapi/execution.py +0 -0
  26. {wizata_dsapi-1.3.45 → wizata_dsapi-1.3.47}/wizata_dsapi/experiment.py +0 -0
  27. {wizata_dsapi-1.3.45 → wizata_dsapi-1.3.47}/wizata_dsapi/group_system.py +0 -0
  28. {wizata_dsapi-1.3.45 → wizata_dsapi-1.3.47}/wizata_dsapi/ilogger.py +0 -0
  29. {wizata_dsapi-1.3.45 → wizata_dsapi-1.3.47}/wizata_dsapi/insight.py +0 -0
  30. {wizata_dsapi-1.3.45 → wizata_dsapi-1.3.47}/wizata_dsapi/model_toolkit.py +0 -0
  31. {wizata_dsapi-1.3.45 → wizata_dsapi-1.3.47}/wizata_dsapi/models/__init__.py +0 -0
  32. {wizata_dsapi-1.3.45 → wizata_dsapi-1.3.47}/wizata_dsapi/models/common.py +0 -0
  33. {wizata_dsapi-1.3.45 → wizata_dsapi-1.3.47}/wizata_dsapi/paged_query_result.py +0 -0
  34. {wizata_dsapi-1.3.45 → wizata_dsapi-1.3.47}/wizata_dsapi/pipeline.py +0 -0
  35. {wizata_dsapi-1.3.45 → wizata_dsapi-1.3.47}/wizata_dsapi/plot.py +0 -0
  36. {wizata_dsapi-1.3.45 → wizata_dsapi-1.3.47}/wizata_dsapi/plots/__init__.py +0 -0
  37. {wizata_dsapi-1.3.45 → wizata_dsapi-1.3.47}/wizata_dsapi/plots/common.py +0 -0
  38. {wizata_dsapi-1.3.45 → wizata_dsapi-1.3.47}/wizata_dsapi/request.py +0 -0
  39. {wizata_dsapi-1.3.45 → wizata_dsapi-1.3.47}/wizata_dsapi/script.py +0 -0
  40. {wizata_dsapi-1.3.45 → wizata_dsapi-1.3.47}/wizata_dsapi/scripts/__init__.py +0 -0
  41. {wizata_dsapi-1.3.45 → wizata_dsapi-1.3.47}/wizata_dsapi/scripts/common.py +0 -0
  42. {wizata_dsapi-1.3.45 → wizata_dsapi-1.3.47}/wizata_dsapi/solution_component.py +0 -0
  43. {wizata_dsapi-1.3.45 → wizata_dsapi-1.3.47}/wizata_dsapi/streamlit_utils.py +0 -0
  44. {wizata_dsapi-1.3.45 → wizata_dsapi-1.3.47}/wizata_dsapi/template.py +0 -0
  45. {wizata_dsapi-1.3.45 → wizata_dsapi-1.3.47}/wizata_dsapi/trigger.py +0 -0
  46. {wizata_dsapi-1.3.45 → wizata_dsapi-1.3.47}/wizata_dsapi/twin.py +0 -0
  47. {wizata_dsapi-1.3.45 → wizata_dsapi-1.3.47}/wizata_dsapi/twinregistration.py +0 -0
  48. {wizata_dsapi-1.3.45 → wizata_dsapi-1.3.47}/wizata_dsapi/wizard_function.py +0 -0
  49. {wizata_dsapi-1.3.45 → wizata_dsapi-1.3.47}/wizata_dsapi/wizard_request.py +0 -0
  50. {wizata_dsapi-1.3.45 → wizata_dsapi-1.3.47}/wizata_dsapi/words.py +0 -0
  51. {wizata_dsapi-1.3.45 → wizata_dsapi-1.3.47}/wizata_dsapi.egg-info/SOURCES.txt +0 -0
  52. {wizata_dsapi-1.3.45 → wizata_dsapi-1.3.47}/wizata_dsapi.egg-info/dependency_links.txt +0 -0
  53. {wizata_dsapi-1.3.45 → wizata_dsapi-1.3.47}/wizata_dsapi.egg-info/requires.txt +0 -0
  54. {wizata_dsapi-1.3.45 → wizata_dsapi-1.3.47}/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.45
3
+ Version: 1.3.47
4
4
  Summary: Wizata Data Science Toolkit
5
5
  Author: Wizata S.A.
6
6
  Author-email: info@wizata.com
@@ -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
 
@@ -0,0 +1 @@
1
+ __version__ = "1.3.47"
@@ -1142,10 +1142,16 @@ class WizataDSAPIClient(ApiInterface, ApiDtoInterface):
1142
1142
  for file in model_info.files:
1143
1143
  file: wizata_dsapi.ModelFile
1144
1144
  if file.name != "trained_model":
1145
- headers["Content-Type"] = "application/octet-stream"
1145
+ single_file = {
1146
+ "file": (
1147
+ file.path,
1148
+ file.content,
1149
+ "application/octet-stream",
1150
+ )
1151
+ }
1146
1152
  response = requests.post(self.__url() + f"models/{model_info.identifier(include_alias=True)}/files/{file.path}",
1147
1153
  headers=headers,
1148
- data=file.content,
1154
+ files=single_file,
1149
1155
  timeout=60)
1150
1156
  if response.status_code != 200 and response.status_code != 201:
1151
1157
  raise self.__raise_error(response)
@@ -2021,10 +2027,17 @@ class WizataDSAPIClient(ApiInterface, ApiDtoInterface):
2021
2027
  path = file.path
2022
2028
 
2023
2029
  headers = self.__header()
2024
- headers["Content-Type"] = "application/octet-stream"
2030
+ headers.pop("Content-Type", None)
2031
+ single_file = {
2032
+ "file": (
2033
+ path,
2034
+ content,
2035
+ "application/octet-stream",
2036
+ )
2037
+ }
2025
2038
  response = requests.post(self.__url() + f"models/{identifier}/files/{path}",
2026
2039
  headers=headers,
2027
- data=content,
2040
+ files=single_file,
2028
2041
  timeout=60)
2029
2042
  if response.status_code != 200 and response.status_code != 201:
2030
2043
  return
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: wizata_dsapi
3
- Version: 1.3.45
3
+ Version: 1.3.47
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.45"
File without changes
File without changes
File without changes
File without changes