cs-models 0.0.668__py3-none-any.whl → 0.0.669__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.

Potentially problematic release.


This version of cs-models might be problematic. Click here for more details.

@@ -1,10 +1,49 @@
1
1
  """Marshmallow Schema for AssistantCommand."""
2
+ import json
2
3
  from marshmallow import Schema, fields
3
4
  from ..WorkbookBlockComment.schemas import (
4
5
  WorkbookBlockCommentResourceSchema,
5
6
  )
6
7
 
7
8
 
9
+ class WorkbookBlockDataField(fields.Field):
10
+ """Field that stores result for the Assistant command."""
11
+
12
+ def _serialize(self, value, attr, obj, **kwargs):
13
+ """
14
+ In the DB, the `result` field is a text field. We persist
15
+ data by performing the following:
16
+
17
+ AssistantCommandModel(
18
+ ...
19
+ result=json.dumps({...}),
20
+ )
21
+
22
+ So here we need to perform the inverse operation (i.e `json.loads(..)`)
23
+ """
24
+ if value is None:
25
+ return None
26
+ return json.loads(value)
27
+
28
+ def _deserialize(self, value, attr, data, **kwargs):
29
+ """
30
+ In the DB, the `result` field is a text field. We persist
31
+ data by performing the following:
32
+
33
+
34
+
35
+ AssistantCommandModel(
36
+ ***AssistantCommandResourceSchema().load({
37
+ ...
38
+ "result": [{"some_key": 1}, {"some_key": 2}],
39
+ }),
40
+ )
41
+ """
42
+ if value is None:
43
+ return None
44
+ return json.dumps(value)
45
+
46
+
8
47
  class WorkbookBlockResourceSchema(Schema):
9
48
  """Class for AssistantCommandResource schema"""
10
49
 
@@ -12,7 +51,7 @@ class WorkbookBlockResourceSchema(Schema):
12
51
  workbook_id = fields.Integer(required=True)
13
52
  sequence_number = fields.Integer(required=True)
14
53
  block_type = fields.String(required=True)
15
- block_data = fields.String(allow_none=True)
54
+ block_data = WorkbookBlockDataField(required=True, allow_none=True)
16
55
  comments = fields.Nested(
17
56
  WorkbookBlockCommentResourceSchema(exclude=("block_id",)),
18
57
  many=True,
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: cs-models
3
- Version: 0.0.668
3
+ Version: 0.0.669
4
4
  Summary: MySQL db models
5
5
  Home-page: https://github.com/mindgram/cs-models
6
6
  Author: Shrey Verma
@@ -1055,7 +1055,7 @@ cs_models/resources/Workbook/models.py,sha256=6sj9VhKTCnBL32_pkwUqfE9ESBRu1oCL2c
1055
1055
  cs_models/resources/Workbook/schemas.py,sha256=xcNoPzHK6ER06XA3fAvX3x7VtX47aBP0vrIqiJvUVKw,688
1056
1056
  cs_models/resources/WorkbookBlock/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
1057
1057
  cs_models/resources/WorkbookBlock/models.py,sha256=tYxYRt6210QdvgUldtmy3p3-srlVuEBZU2yCT01Xnag,1467
1058
- cs_models/resources/WorkbookBlock/schemas.py,sha256=vL5zIVn8qafa99hrDfQj7FT2mca53L80C_hWiDbQhLo,798
1058
+ cs_models/resources/WorkbookBlock/schemas.py,sha256=CfjGkuRff_ohR4WNSRKYkwpIrwPBvfuK9o21lNU3sWM,1859
1059
1059
  cs_models/resources/WorkbookBlockComment/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
1060
1060
  cs_models/resources/WorkbookBlockComment/models.py,sha256=t1dLdweoPOzld1uBqrGJ3rrr66UkMwdiplNZEA1WtPU,1251
1061
1061
  cs_models/resources/WorkbookBlockComment/schemas.py,sha256=9UI_mTuPBYBk5qKUC2u0oR_clHA9XZ-bh5hhr24E-vs,563
@@ -1105,7 +1105,7 @@ cs_models/utils/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
1105
1105
  cs_models/utils/alchemy.py,sha256=fhINGFn41owJ2DLXQKXAAtLqeZ1BRzD_qU0wPK_bsGQ,1598
1106
1106
  cs_models/utils/utils.py,sha256=bY623DuzycfPQiaOQT2AxfANeWfwr5w76dBuQ813-ns,3664
1107
1107
  cs_models/utils/profiling/__init__.py,sha256=N-73vb0M92C975fxgXyBCBjCPELl8Oh21ZY_-tzDnns,569
1108
- cs_models-0.0.668.dist-info/METADATA,sha256=spbQxLNJpPnoyIUshWz9AkYm-6r-K3ddEFDDKSCVwZg,792
1109
- cs_models-0.0.668.dist-info/WHEEL,sha256=G16H4A3IeoQmnOrYV4ueZGKSjhipXx8zc8nu9FGlvMA,92
1110
- cs_models-0.0.668.dist-info/top_level.txt,sha256=M7CA8Nh5t0vRManQ9gHfphhO16uhMqIbfaxr1jPDg18,10
1111
- cs_models-0.0.668.dist-info/RECORD,,
1108
+ cs_models-0.0.669.dist-info/METADATA,sha256=fUuZ7WjCpptkNy9CeIuG7goNdBkeFiWHXreJsy908xc,792
1109
+ cs_models-0.0.669.dist-info/WHEEL,sha256=G16H4A3IeoQmnOrYV4ueZGKSjhipXx8zc8nu9FGlvMA,92
1110
+ cs_models-0.0.669.dist-info/top_level.txt,sha256=M7CA8Nh5t0vRManQ9gHfphhO16uhMqIbfaxr1jPDg18,10
1111
+ cs_models-0.0.669.dist-info/RECORD,,