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

@@ -14,6 +14,7 @@ class SmartDefGridCellAnswerModel(Base):
14
14
  question_id = Column(Integer, ForeignKey("smart_def_grid_cell_questions.id", ondelete="CASCADE"), nullable=False)
15
15
 
16
16
  smart_def_grid_id = Column(Integer, ForeignKey("smart_def_grids.id", ondelete="CASCADE"), nullable=False)
17
+ run_id = Column(Integer, ForeignKey("smart_def_grid_runs.id", ondelete="SET NULL"), nullable=True)
17
18
  cell_id = Column(String(36), nullable=False)
18
19
 
19
20
  # canonical payload
@@ -37,6 +38,8 @@ class SmartDefGridCellAnswerModel(Base):
37
38
  ondelete="CASCADE",
38
39
  ),
39
40
  Index("ix_smart_def_grid_cell_answers_cell", "smart_def_grid_id", "cell_id", "created_at"),
41
+ Index("ix_sdgca_run_cell", "run_id", "smart_def_grid_id", "cell_id", "created_at"),
40
42
  )
41
43
 
42
44
  question = relationship("SmartDefGridCellQuestionModel", back_populates="answers")
45
+ run = relationship("SmartDefGridRunModel")
@@ -26,6 +26,7 @@ class SmartDefGridCellQuestionModel(Base):
26
26
 
27
27
  id = Column(Integer, primary_key=True, autoincrement=True) # question_id (uuid)
28
28
  smart_def_grid_id = Column(Integer, ForeignKey("smart_def_grids.id", ondelete="CASCADE"), nullable=False)
29
+ run_id = Column(Integer, ForeignKey("smart_def_grid_runs.id", ondelete="SET NULL"), nullable=True)
29
30
  cell_id = Column(String(36), nullable=False)
30
31
 
31
32
  question_text = Column(Text, nullable=False)
@@ -54,12 +55,15 @@ class SmartDefGridCellQuestionModel(Base):
54
55
 
55
56
  # relationships
56
57
  answers = relationship("SmartDefGridCellAnswerModel", back_populates="question", cascade="all, delete-orphan")
58
+ run = relationship("SmartDefGridRunModel")
57
59
 
58
60
  __table_args__ = (
59
61
  # Useful to grab next jobs: status+priority+created
60
62
  Index("ix_smart_def_grid_cell_questions_queue", "status", "priority", "created_at"),
61
63
  # Quick lookup for this cell's active question(s)
62
64
  Index("ix_smart_def_grid_cell_questions_cell", "smart_def_grid_id", "cell_id"),
65
+ Index("ix_sdgcq_run_status", "run_id", "status", "priority", "created_at"),
66
+ Index("ix_sdgcq_run_cell", "run_id", "smart_def_grid_id", "cell_id"),
63
67
  ForeignKeyConstraint(
64
68
  ["smart_def_grid_id", "cell_id"],
65
69
  ["smart_def_grid_cells.smart_def_grid_id", "smart_def_grid_cells.cell_id"],
@@ -11,6 +11,7 @@ class SmartDefGridCellQuestionResourceSchema(Schema):
11
11
 
12
12
  id = fields.String(dump_only=True)
13
13
  smart_def_grid_id = fields.Integer(required=True)
14
+ run_id = fields.Integer(allow_none=True)
14
15
  cell_id = fields.String(required=True)
15
16
 
16
17
  question_text = fields.String(required=True, validate=not_blank)
@@ -13,6 +13,7 @@ class SmartDefGridCellValueModel(Base):
13
13
  __tablename__ = "smart_def_grid_cell_values"
14
14
 
15
15
  smart_def_grid_id = Column(Integer, ForeignKey("smart_def_grids.id", ondelete="CASCADE"), primary_key=True)
16
+ applied_run_id = Column(Integer, ForeignKey("smart_def_grid_runs.id", ondelete="SET NULL"), nullable=True)
16
17
  cell_id = Column(String(36), primary_key=True)
17
18
 
18
19
  # applied value derived from a specific answer_id (or manual override)
@@ -50,3 +51,4 @@ class SmartDefGridCellValueModel(Base):
50
51
  )
51
52
 
52
53
  answer = relationship("SmartDefGridCellAnswerModel", foreign_keys=[answer_id])
54
+ applied_run = relationship("SmartDefGridRunModel")
@@ -3,6 +3,7 @@ from marshmallow import Schema, fields
3
3
 
4
4
  class SmartDefGridCellValueResourceSchema(Schema):
5
5
  smart_def_grid_id = fields.Integer(required=True)
6
+ applied_run_id = fields.Integer(allow_none=True)
6
7
  cell_id = fields.String(required=True)
7
8
 
8
9
  answer_id = fields.Integer(allow_none=True)
File without changes
@@ -0,0 +1,52 @@
1
+ from enum import Enum
2
+ from datetime import datetime
3
+ from sqlalchemy import Enum as SAEnum
4
+ from sqlalchemy import Column, DateTime, ForeignKey, Integer, String, JSON, Text, Index
5
+ from sqlalchemy.orm import relationship
6
+ from ...database import Base
7
+
8
+
9
+ class SmartDefGridRunStatus(str, Enum):
10
+ created = "created"
11
+ dispatched = "dispatched"
12
+ running = "running"
13
+ succeeded = "succeeded"
14
+ failed = "failed"
15
+ cancelled = "cancelled"
16
+ partial = "partial" # finished with some failed cells
17
+
18
+
19
+ class SmartDefGridRunModel(Base):
20
+ __tablename__ = "smart_def_grid_runs"
21
+
22
+ id = Column(Integer, primary_key=True, autoincrement=True) # run_id
23
+ smart_def_grid_id = Column(Integer, ForeignKey("smart_def_grids.id", ondelete="CASCADE"), nullable=False)
24
+
25
+ # optional snapshotting to make runs reproducible/debuggable
26
+ outline_json = Column(JSON, nullable=False) # new outline created for this run
27
+ original_table_json = Column(JSON, nullable=False) # stamped block at run start
28
+
29
+ # execution metadata
30
+ status = Column(
31
+ SAEnum(
32
+ SmartDefGridRunStatus,
33
+ validate_strings=True, # allow assigning "created" etc. as strings too
34
+ ),
35
+ nullable=False,
36
+ default=SmartDefGridRunStatus.created,
37
+ )
38
+
39
+ started_by_user_id = Column(String(64), nullable=False)
40
+ notes = Column(Text, nullable=True)
41
+ # optional idempotency token if you want “re-run latest”
42
+ client_token = Column(String(128), nullable=True, index=True)
43
+
44
+ created_at = Column(DateTime, default=datetime.utcnow, nullable=False)
45
+ started_at = Column(DateTime, nullable=True)
46
+ finished_at = Column(DateTime, nullable=True)
47
+ updated_at = Column(DateTime, default=datetime.utcnow, onupdate=datetime.utcnow, nullable=False)
48
+
49
+ grid = relationship("SmartDefGridModel", backref="runs")
50
+ __table_args__ = (
51
+ Index("ix_sdgr_runs_grid_created", "smart_def_grid_id", "created_at"),
52
+ )
@@ -0,0 +1,28 @@
1
+ from marshmallow import Schema, fields, validate
2
+
3
+
4
+ class SmartDefGridRunResourceSchema(Schema):
5
+ """
6
+ The user-defined table artifact (aka 'SmartDefGrid' resource).
7
+ - id is your table_id (UUID string or int—your choice).
8
+ - outline_json/original_table_json can be dicts (preferred) or JSON strings if you’d rather store serialized blobs.
9
+ """
10
+ not_blank = validate.Length(min=1, error="Field cannot be blank")
11
+
12
+ id = fields.String(dump_only=True) # table_id
13
+ smart_def_grid_id = fields.Integer(allow_none=True) # if you link to a workbook
14
+
15
+ # prefer dicts; switch to fields.String if you store JSON-serialized strings
16
+ outline_json = fields.Raw(required=True)
17
+ original_table_json = fields.Raw(required=True)
18
+
19
+ status = fields.String(required=True)
20
+ started_by_user_id = fields.String(required=True)
21
+
22
+ notes = fields.String(allow_none=True)
23
+ client_token = fields.String(allow_none=True)
24
+
25
+ created_at = fields.DateTime(dump_only=True)
26
+ started_at = fields.DateTime(allow_none=True)
27
+ finished_at = fields.DateTime(allow_none=True)
28
+ updated_at = fields.DateTime(dump_only=True)
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: cs-models
3
- Version: 0.0.808
3
+ Version: 0.0.810
4
4
  Summary: MySQL db models
5
5
  Home-page: https://github.com/mindgram/cs-models
6
6
  Author: Shrey Verma
@@ -960,17 +960,20 @@ cs_models/resources/SmartDefGridCell/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeu
960
960
  cs_models/resources/SmartDefGridCell/models.py,sha256=rbvJPsKQLhWZjUMza1--kS5oQC_D7Ylde8jAzjRoG_8,2315
961
961
  cs_models/resources/SmartDefGridCell/schemas.py,sha256=opd_dD3dj-U618RABBAo8UFAKwt9wPev1WVnPQca26c,1479
962
962
  cs_models/resources/SmartDefGridCellAnswer/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
963
- cs_models/resources/SmartDefGridCellAnswer/models.py,sha256=sQgZDzZUIw7WRUtjrVwk9BZANCnxcuxFaQ-9x4WCDto,1935
963
+ cs_models/resources/SmartDefGridCellAnswer/models.py,sha256=5lvvhs8d8gV7IGP_fskJPD88r3ZUj6GfYa7qwXRyB1Q,2177
964
964
  cs_models/resources/SmartDefGridCellAnswer/schemas.py,sha256=Nvt2pRq7SbbFmnp6EWrvao0A9BmmXqHOsTqf3qTo22Y,915
965
965
  cs_models/resources/SmartDefGridCellAnswerCitation/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
966
966
  cs_models/resources/SmartDefGridCellAnswerCitation/models.py,sha256=pCNakAl08pSFTbuhJypF43zDfoapZDsvFPH2PP7QQqo,916
967
967
  cs_models/resources/SmartDefGridCellAnswerCitation/schemas.py,sha256=1dYybWcoSuhP0OLqwQ3igNeexMcV-Nj0IqtBaPVap-Q,568
968
968
  cs_models/resources/SmartDefGridCellQuestion/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
969
- cs_models/resources/SmartDefGridCellQuestion/models.py,sha256=dQ8HFXuRJNeQJlDzAXVIsvLLm5AkWgU0oKtWpvzGM40,3033
970
- cs_models/resources/SmartDefGridCellQuestion/schemas.py,sha256=ui0WrwQ55fCWqBZ3tcibfS_4gIiYY00ls_H0C9VIEaQ,1586
969
+ cs_models/resources/SmartDefGridCellQuestion/models.py,sha256=3pOYSZZnY6ufYBkRTqbV7heuclfDIcm8SnUy0kJDNic,3345
970
+ cs_models/resources/SmartDefGridCellQuestion/schemas.py,sha256=P1w8PTxhC7D6zYcs1ijy-ZZxHrYJJnAfDXNV-zbn3UY,1631
971
971
  cs_models/resources/SmartDefGridCellValue/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
972
- cs_models/resources/SmartDefGridCellValue/models.py,sha256=s5Tnj7s633qbAM14Eh4OU1QHN-CeSUe7GZSGrzywOGA,2259
973
- cs_models/resources/SmartDefGridCellValue/schemas.py,sha256=fqp1odR0nPheKjGeLScs9lPR6bDZzWVm2x78NNLuIRc,637
972
+ cs_models/resources/SmartDefGridCellValue/models.py,sha256=xNonMUcjN09lqS0CrYLoVGRpsGPFvW75FcT5IY7ggUA,2425
973
+ cs_models/resources/SmartDefGridCellValue/schemas.py,sha256=RjxVxBtxd29iReLOfArdHOzmV4ruyfyUnqfL8Wf9BG4,690
974
+ cs_models/resources/SmartDefGridRun/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
975
+ cs_models/resources/SmartDefGridRun/models.py,sha256=LMrguTz0u1l8pDkI2hAmG0zW-jzVkq6u54-sOMuWlUg,1952
976
+ cs_models/resources/SmartDefGridRun/schemas.py,sha256=VQeBvql_e_K9cGKmDR6t8GMkJjkYW_HxaB4lvaHmQpI,1156
974
977
  cs_models/resources/SmartGrid/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
975
978
  cs_models/resources/SmartGrid/models.py,sha256=9weIkYbh-Y-My5vjjUP-N-ziSNV-AWww1UUltK8EIy0,1011
976
979
  cs_models/resources/SmartGrid/schemas.py,sha256=v5iG5dsEDnRp8P3UKba7uN39ZD_hqPvfLWyX1ltKKjM,665
@@ -1318,7 +1321,7 @@ cs_models/utils/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
1318
1321
  cs_models/utils/alchemy.py,sha256=fhINGFn41owJ2DLXQKXAAtLqeZ1BRzD_qU0wPK_bsGQ,1598
1319
1322
  cs_models/utils/utils.py,sha256=BzCDk3u1np7DoJQqCZIJN4f80JNHvJoWO4qEFgolN-8,4474
1320
1323
  cs_models/utils/profiling/__init__.py,sha256=N-73vb0M92C975fxgXyBCBjCPELl8Oh21ZY_-tzDnns,569
1321
- cs_models-0.0.808.dist-info/METADATA,sha256=JkQmTZvrWgCKwN46aRRzPwqz7O5JQ16uyx-Wp-RUtVg,751
1322
- cs_models-0.0.808.dist-info/WHEEL,sha256=tZoeGjtWxWRfdplE7E3d45VPlLNQnvbKiYnx7gwAy8A,92
1323
- cs_models-0.0.808.dist-info/top_level.txt,sha256=M7CA8Nh5t0vRManQ9gHfphhO16uhMqIbfaxr1jPDg18,10
1324
- cs_models-0.0.808.dist-info/RECORD,,
1324
+ cs_models-0.0.810.dist-info/METADATA,sha256=lDeFnNXB9HTj2s6JmBt0EQx5xC7cf6bi66Z0aA89j1A,751
1325
+ cs_models-0.0.810.dist-info/WHEEL,sha256=tZoeGjtWxWRfdplE7E3d45VPlLNQnvbKiYnx7gwAy8A,92
1326
+ cs_models-0.0.810.dist-info/top_level.txt,sha256=M7CA8Nh5t0vRManQ9gHfphhO16uhMqIbfaxr1jPDg18,10
1327
+ cs_models-0.0.810.dist-info/RECORD,,