wizata-dsapi 2.2.0.dev7__tar.gz → 2.2.0.dev9__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 (71) hide show
  1. {wizata_dsapi-2.2.0.dev7 → wizata_dsapi-2.2.0.dev9}/PKG-INFO +1 -1
  2. {wizata_dsapi-2.2.0.dev7 → wizata_dsapi-2.2.0.dev9}/wizata_dsapi/inventory.py +13 -4
  3. {wizata_dsapi-2.2.0.dev7 → wizata_dsapi-2.2.0.dev9}/wizata_dsapi/product.py +12 -2
  4. wizata_dsapi-2.2.0.dev9/wizata_dsapi/version.py +1 -0
  5. {wizata_dsapi-2.2.0.dev7 → wizata_dsapi-2.2.0.dev9}/wizata_dsapi/wizata_dsapi_client.py +34 -12
  6. {wizata_dsapi-2.2.0.dev7 → wizata_dsapi-2.2.0.dev9}/wizata_dsapi.egg-info/PKG-INFO +1 -1
  7. wizata_dsapi-2.2.0.dev7/wizata_dsapi/version.py +0 -1
  8. {wizata_dsapi-2.2.0.dev7 → wizata_dsapi-2.2.0.dev9}/LICENSE.txt +0 -0
  9. {wizata_dsapi-2.2.0.dev7 → wizata_dsapi-2.2.0.dev9}/README.rst +0 -0
  10. {wizata_dsapi-2.2.0.dev7 → wizata_dsapi-2.2.0.dev9}/setup.cfg +0 -0
  11. {wizata_dsapi-2.2.0.dev7 → wizata_dsapi-2.2.0.dev9}/setup.py +0 -0
  12. {wizata_dsapi-2.2.0.dev7 → wizata_dsapi-2.2.0.dev9}/wizata_dsapi/__init__.py +0 -0
  13. {wizata_dsapi-2.2.0.dev7 → wizata_dsapi-2.2.0.dev9}/wizata_dsapi/api_config.py +0 -0
  14. {wizata_dsapi-2.2.0.dev7 → wizata_dsapi-2.2.0.dev9}/wizata_dsapi/api_dto.py +0 -0
  15. {wizata_dsapi-2.2.0.dev7 → wizata_dsapi-2.2.0.dev9}/wizata_dsapi/api_interface.py +0 -0
  16. {wizata_dsapi-2.2.0.dev7 → wizata_dsapi-2.2.0.dev9}/wizata_dsapi/bucket.py +0 -0
  17. {wizata_dsapi-2.2.0.dev7 → wizata_dsapi-2.2.0.dev9}/wizata_dsapi/business_label.py +0 -0
  18. {wizata_dsapi-2.2.0.dev7 → wizata_dsapi-2.2.0.dev9}/wizata_dsapi/connection.py +0 -0
  19. {wizata_dsapi-2.2.0.dev7 → wizata_dsapi-2.2.0.dev9}/wizata_dsapi/connection_types.py +0 -0
  20. {wizata_dsapi-2.2.0.dev7 → wizata_dsapi-2.2.0.dev9}/wizata_dsapi/context.py +0 -0
  21. {wizata_dsapi-2.2.0.dev7 → wizata_dsapi-2.2.0.dev9}/wizata_dsapi/dashboard.py +0 -0
  22. {wizata_dsapi-2.2.0.dev7 → wizata_dsapi-2.2.0.dev9}/wizata_dsapi/dataframe_toolkit.py +0 -0
  23. {wizata_dsapi-2.2.0.dev7 → wizata_dsapi-2.2.0.dev9}/wizata_dsapi/datapoint.py +0 -0
  24. {wizata_dsapi-2.2.0.dev7 → wizata_dsapi-2.2.0.dev9}/wizata_dsapi/datastore.py +0 -0
  25. {wizata_dsapi-2.2.0.dev7 → wizata_dsapi-2.2.0.dev9}/wizata_dsapi/deployment.py +0 -0
  26. {wizata_dsapi-2.2.0.dev7 → wizata_dsapi-2.2.0.dev9}/wizata_dsapi/ds_dataframe.py +0 -0
  27. {wizata_dsapi-2.2.0.dev7 → wizata_dsapi-2.2.0.dev9}/wizata_dsapi/dsapi_json_encoder.py +0 -0
  28. {wizata_dsapi-2.2.0.dev7 → wizata_dsapi-2.2.0.dev9}/wizata_dsapi/edge_config.py +0 -0
  29. {wizata_dsapi-2.2.0.dev7 → wizata_dsapi-2.2.0.dev9}/wizata_dsapi/edge_device.py +0 -0
  30. {wizata_dsapi-2.2.0.dev7 → wizata_dsapi-2.2.0.dev9}/wizata_dsapi/edge_module.py +0 -0
  31. {wizata_dsapi-2.2.0.dev7 → wizata_dsapi-2.2.0.dev9}/wizata_dsapi/evaluation.py +0 -0
  32. {wizata_dsapi-2.2.0.dev7 → wizata_dsapi-2.2.0.dev9}/wizata_dsapi/execution.py +0 -0
  33. {wizata_dsapi-2.2.0.dev7 → wizata_dsapi-2.2.0.dev9}/wizata_dsapi/execution_log.py +0 -0
  34. {wizata_dsapi-2.2.0.dev7 → wizata_dsapi-2.2.0.dev9}/wizata_dsapi/experiment.py +0 -0
  35. {wizata_dsapi-2.2.0.dev7 → wizata_dsapi-2.2.0.dev9}/wizata_dsapi/graylog_log.py +0 -0
  36. {wizata_dsapi-2.2.0.dev7 → wizata_dsapi-2.2.0.dev9}/wizata_dsapi/group_system.py +0 -0
  37. {wizata_dsapi-2.2.0.dev7 → wizata_dsapi-2.2.0.dev9}/wizata_dsapi/ilogger.py +0 -0
  38. {wizata_dsapi-2.2.0.dev7 → wizata_dsapi-2.2.0.dev9}/wizata_dsapi/insight.py +0 -0
  39. {wizata_dsapi-2.2.0.dev7 → wizata_dsapi-2.2.0.dev9}/wizata_dsapi/mlmodel.py +0 -0
  40. {wizata_dsapi-2.2.0.dev7 → wizata_dsapi-2.2.0.dev9}/wizata_dsapi/mobile_asset.py +0 -0
  41. {wizata_dsapi-2.2.0.dev7 → wizata_dsapi-2.2.0.dev9}/wizata_dsapi/model_toolkit.py +0 -0
  42. {wizata_dsapi-2.2.0.dev7 → wizata_dsapi-2.2.0.dev9}/wizata_dsapi/models/__init__.py +0 -0
  43. {wizata_dsapi-2.2.0.dev7 → wizata_dsapi-2.2.0.dev9}/wizata_dsapi/models/common.py +0 -0
  44. {wizata_dsapi-2.2.0.dev7 → wizata_dsapi-2.2.0.dev9}/wizata_dsapi/notification.py +0 -0
  45. {wizata_dsapi-2.2.0.dev7 → wizata_dsapi-2.2.0.dev9}/wizata_dsapi/paged_query_result.py +0 -0
  46. {wizata_dsapi-2.2.0.dev7 → wizata_dsapi-2.2.0.dev9}/wizata_dsapi/pipeline.py +0 -0
  47. {wizata_dsapi-2.2.0.dev7 → wizata_dsapi-2.2.0.dev9}/wizata_dsapi/pipeline_image.py +0 -0
  48. {wizata_dsapi-2.2.0.dev7 → wizata_dsapi-2.2.0.dev9}/wizata_dsapi/plot.py +0 -0
  49. {wizata_dsapi-2.2.0.dev7 → wizata_dsapi-2.2.0.dev9}/wizata_dsapi/plots/__init__.py +0 -0
  50. {wizata_dsapi-2.2.0.dev7 → wizata_dsapi-2.2.0.dev9}/wizata_dsapi/plots/common.py +0 -0
  51. {wizata_dsapi-2.2.0.dev7 → wizata_dsapi-2.2.0.dev9}/wizata_dsapi/plots/theme.py +0 -0
  52. {wizata_dsapi-2.2.0.dev7 → wizata_dsapi-2.2.0.dev9}/wizata_dsapi/request.py +0 -0
  53. {wizata_dsapi-2.2.0.dev7 → wizata_dsapi-2.2.0.dev9}/wizata_dsapi/script.py +0 -0
  54. {wizata_dsapi-2.2.0.dev7 → wizata_dsapi-2.2.0.dev9}/wizata_dsapi/scripts/__init__.py +0 -0
  55. {wizata_dsapi-2.2.0.dev7 → wizata_dsapi-2.2.0.dev9}/wizata_dsapi/scripts/common.py +0 -0
  56. {wizata_dsapi-2.2.0.dev7 → wizata_dsapi-2.2.0.dev9}/wizata_dsapi/search.py +0 -0
  57. {wizata_dsapi-2.2.0.dev7 → wizata_dsapi-2.2.0.dev9}/wizata_dsapi/solution_component.py +0 -0
  58. {wizata_dsapi-2.2.0.dev7 → wizata_dsapi-2.2.0.dev9}/wizata_dsapi/streamlit_utils.py +0 -0
  59. {wizata_dsapi-2.2.0.dev7 → wizata_dsapi-2.2.0.dev9}/wizata_dsapi/template.py +0 -0
  60. {wizata_dsapi-2.2.0.dev7 → wizata_dsapi-2.2.0.dev9}/wizata_dsapi/template_config.py +0 -0
  61. {wizata_dsapi-2.2.0.dev7 → wizata_dsapi-2.2.0.dev9}/wizata_dsapi/trigger.py +0 -0
  62. {wizata_dsapi-2.2.0.dev7 → wizata_dsapi-2.2.0.dev9}/wizata_dsapi/twin.py +0 -0
  63. {wizata_dsapi-2.2.0.dev7 → wizata_dsapi-2.2.0.dev9}/wizata_dsapi/twinregistration.py +0 -0
  64. {wizata_dsapi-2.2.0.dev7 → wizata_dsapi-2.2.0.dev9}/wizata_dsapi/user.py +0 -0
  65. {wizata_dsapi-2.2.0.dev7 → wizata_dsapi-2.2.0.dev9}/wizata_dsapi/wizard_function.py +0 -0
  66. {wizata_dsapi-2.2.0.dev7 → wizata_dsapi-2.2.0.dev9}/wizata_dsapi/wizard_request.py +0 -0
  67. {wizata_dsapi-2.2.0.dev7 → wizata_dsapi-2.2.0.dev9}/wizata_dsapi/words.py +0 -0
  68. {wizata_dsapi-2.2.0.dev7 → wizata_dsapi-2.2.0.dev9}/wizata_dsapi.egg-info/SOURCES.txt +0 -0
  69. {wizata_dsapi-2.2.0.dev7 → wizata_dsapi-2.2.0.dev9}/wizata_dsapi.egg-info/dependency_links.txt +0 -0
  70. {wizata_dsapi-2.2.0.dev7 → wizata_dsapi-2.2.0.dev9}/wizata_dsapi.egg-info/requires.txt +0 -0
  71. {wizata_dsapi-2.2.0.dev7 → wizata_dsapi-2.2.0.dev9}/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: 2.2.0.dev7
3
+ Version: 2.2.0.dev9
4
4
  Summary: Wizata Data Science Toolkit
5
5
  Author: Wizata S.A.
6
6
  Author-email: info@wizata.com
@@ -83,8 +83,9 @@ class InventoryBalance:
83
83
  DataPoint ``datapoint`` (a hardware id), true at ``timestamp`` (when it was
84
84
  counted, not when it was recorded: that is ``created_at``).
85
85
 
86
- PostgreSQL ``"InventoryBalance"``, PK (``datapoint``, ``product``, ``timestamp``).
87
- Writing the same key again replaces the quantity.
86
+ PostgreSQL ``"InventoryBalance"``, PK ``id`` (DEV-6085); (``datapoint``, ``product``,
87
+ ``timestamp``) is unique, and writing the same key again replaces the quantity.
88
+ ``count`` is the key shared by every balance written in one call (one count).
88
89
 
89
90
  On write only:
90
91
 
@@ -99,7 +100,9 @@ class InventoryBalance:
99
100
  return "planner/inventory/balances"
100
101
 
101
102
  def __init__(self, datapoint: str = None, product: str = None, timestamp=None,
102
- quantity: float = None, unit=None, twin: str = None):
103
+ quantity: float = None, unit=None, twin: str = None, balance_id=None, count=None):
104
+ self.id: Optional[str] = _uuid_str(balance_id)
105
+ self.count: Optional[str] = _uuid_str(count)
103
106
  self.datapoint: Optional[str] = datapoint
104
107
  self.product: Optional[str] = product
105
108
  self.timestamp: Optional[datetime] = _ts_in(timestamp)
@@ -113,7 +116,8 @@ class InventoryBalance:
113
116
 
114
117
  def to_dict(self) -> dict:
115
118
  obj = {}
116
- for name, value in (("datapoint", self.datapoint), ("product", self.product),
119
+ for name, value in (("id", self.id), ("count", self.count),
120
+ ("datapoint", self.datapoint), ("product", self.product),
117
121
  ("quantity", self.quantity), ("unit", self.unit),
118
122
  ("twin", self.twin), ("createdBy", self.created_by),
119
123
  ("updatedBy", self.updated_by)):
@@ -128,6 +132,8 @@ class InventoryBalance:
128
132
  @classmethod
129
133
  def from_dict(cls, data: dict) -> "InventoryBalance":
130
134
  obj = cls()
135
+ obj.id = _uuid_str(data.get("id"))
136
+ obj.count = _uuid_str(data.get("count"))
131
137
  obj.datapoint = data.get("datapoint")
132
138
  obj.product = data.get("product")
133
139
  obj.timestamp = _ts_in(data.get("timestamp"))
@@ -140,6 +146,9 @@ class InventoryBalance:
140
146
  obj.updated_by = data.get("updatedBy") or data.get("updated_by")
141
147
  return obj
142
148
 
149
+ def api_id(self) -> str:
150
+ return self.id
151
+
143
152
  def key(self) -> tuple:
144
153
  return self.datapoint, self.product, self.timestamp
145
154
 
@@ -7,7 +7,9 @@ ProductKind — what role a product plays: raw material, container, finished pro
7
7
 
8
8
  Product — something the plant consumes or makes, identified by a Wizata key
9
9
  (e.g. ``can_33_coke``). ``category`` is a backend category id (Volume, Count, ...):
10
- it says how a quantity of that product is expressed.
10
+ it says how a quantity of that product is expressed. ``unit`` (optional, DEV-6087) is
11
+ its default unit, a backend unit id of that category, used for stock totals across
12
+ storages; ``unit_symbol`` is filled on read only.
11
13
 
12
14
  ProductComponent — one line of a product's bill of materials: ``product`` is made of
13
15
  ``quantity`` ``unit`` of ``composed_of``. The unit is a backend unit id and must
@@ -120,12 +122,14 @@ class Product:
120
122
  return "planner/products"
121
123
 
122
124
  def __init__(self, key: str = None, name: str = None, category=None,
123
- kind: str = None, description: str = None):
125
+ kind: str = None, description: str = None, unit=None):
124
126
  self.key: Optional[str] = key
125
127
  self.name: Optional[str] = name
126
128
  self.category: Optional[str] = _uuid_str(category)
127
129
  self.kind: Optional[str] = kind
128
130
  self.description: Optional[str] = description
131
+ self.unit: Optional[str] = _uuid_str(unit)
132
+ self.unit_symbol: Optional[str] = None
129
133
  self.created_at: Optional[datetime] = None
130
134
  self.updated_at: Optional[datetime] = None
131
135
 
@@ -141,6 +145,10 @@ class Product:
141
145
  obj["kind"] = self.kind
142
146
  if self.description is not None:
143
147
  obj["description"] = self.description
148
+ if self.unit is not None:
149
+ obj["unit"] = self.unit
150
+ if self.unit_symbol is not None:
151
+ obj["unitSymbol"] = self.unit_symbol
144
152
  if self.created_at is not None:
145
153
  obj["createdAt"] = _ts_out(self.created_at)
146
154
  if self.updated_at is not None:
@@ -155,6 +163,8 @@ class Product:
155
163
  obj.category = _uuid_str(data.get("category"))
156
164
  obj.kind = data.get("kind")
157
165
  obj.description = data.get("description")
166
+ obj.unit = _uuid_str(data.get("unit"))
167
+ obj.unit_symbol = data.get("unitSymbol") or data.get("unit_symbol")
158
168
  obj.created_at = _ts_in(data.get("createdAt") or data.get("created_at"))
159
169
  obj.updated_at = _ts_in(data.get("updatedAt") or data.get("updated_at"))
160
170
  return obj
@@ -0,0 +1 @@
1
+ __version__ = "2.2.0.dev9"
@@ -2886,7 +2886,8 @@ class WizataDSAPIClient(ApiInterface, ApiDtoInterface):
2886
2886
  inventoryMovement DataPoint by ``datapoint``, or by ``twin`` (the DataPoint
2887
2887
  of the product's category on that Twin). ``unit`` converts the quantity to
2888
2888
  the DataPoint's unit.
2889
- :return: the stored balances, quantities in the DataPoint's unit.
2889
+ :return: the stored balances, quantities in the DataPoint's unit, each with its
2890
+ ``id`` and the ``count`` key the call created.
2890
2891
  """
2891
2892
  body = [b.to_dict() if isinstance(b, InventoryBalance) else b for b in balances]
2892
2893
  response = self._planner_request("POST", "planner/inventory/balances/", body=body)
@@ -2896,8 +2897,8 @@ class WizataDSAPIClient(ApiInterface, ApiDtoInterface):
2896
2897
  """
2897
2898
  List recorded balances, newest first by default.
2898
2899
 
2899
- :param search_query: SearchQuery or dict; filters on ``datapoint`` and
2900
- ``product`` (eq / in) and ``timestamp`` (gte / gt / lt / lte).
2900
+ :param search_query: SearchQuery or dict; filters on ``datapoint``, ``product``,
2901
+ ``twin``, ``count``, ``id`` (eq / in) and ``timestamp`` (eq / gte / gt / lt / lte).
2901
2902
  :return: PagedQueryResult with InventoryBalance results.
2902
2903
  """
2903
2904
  if search_query is None:
@@ -2908,19 +2909,40 @@ class WizataDSAPIClient(ApiInterface, ApiDtoInterface):
2908
2909
  body=search_query.to_dict())
2909
2910
  return PagedQueryResult.from_dict(response.json(), dto_class=InventoryBalance)
2910
2911
 
2911
- def delete_inventory_balance(self, datapoint: str, product: str, timestamp):
2912
+ @staticmethod
2913
+ def _balance_id(value) -> str:
2914
+ balance_id = value.id if isinstance(value, InventoryBalance) else value
2915
+ if not balance_id:
2916
+ raise ValueError("please provide a balance or its id")
2917
+ return urllib.parse.quote(str(balance_id), safe="")
2918
+
2919
+ def get_inventory_balance(self, balance_id):
2920
+ """
2921
+ :param balance_id: the balance's id.
2922
+ :return: InventoryBalance, or None when it does not exist.
2923
+ """
2924
+ response = self._planner_request("GET", f"planner/inventory/balances/{self._balance_id(balance_id)}/",
2925
+ expected=(200, 404))
2926
+ return InventoryBalance.from_dict(response.json()) if response.status_code == 200 else None
2927
+
2928
+ def update_inventory_balance(self, balance: InventoryBalance) -> InventoryBalance:
2929
+ """
2930
+ Change one balance's quantity and/or time (its datapoint and product never change).
2931
+ ``unit`` converts the quantity to the datapoint's unit. 409 when another balance
2932
+ already holds the new time.
2933
+ """
2934
+ body = {k: v for k, v in balance.to_dict().items() if k in ("quantity", "timestamp", "unit")}
2935
+ response = self._planner_request("PUT", f"planner/inventory/balances/{self._balance_id(balance)}/",
2936
+ body=body)
2937
+ return InventoryBalance.from_dict(response.json())
2938
+
2939
+ def delete_inventory_balance(self, balance):
2912
2940
  """
2913
2941
  Delete one recorded balance (a count entered by mistake).
2914
2942
 
2915
- :param timestamp: datetime or ISO string, exactly as stored.
2943
+ :param balance: InventoryBalance or its id.
2916
2944
  """
2917
- if isinstance(timestamp, datetime.datetime):
2918
- if timestamp.tzinfo is None:
2919
- timestamp = timestamp.replace(tzinfo=datetime.timezone.utc)
2920
- timestamp = timestamp.isoformat()
2921
- self._planner_request("DELETE", "planner/inventory/balances/",
2922
- params={"datapoint": datapoint, "product": product,
2923
- "timestamp": timestamp},
2945
+ self._planner_request("DELETE", f"planner/inventory/balances/{self._balance_id(balance)}/",
2924
2946
  expected=(204,))
2925
2947
 
2926
2948
 
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: wizata_dsapi
3
- Version: 2.2.0.dev7
3
+ Version: 2.2.0.dev9
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__ = "2.2.0.dev7"