plexus-python-common 1.0.66__py3-none-any.whl → 1.0.67__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.
@@ -468,10 +468,10 @@ def model_revision_type(dialect: str | None = None) -> sa.types.TypeEngine[int]:
468
468
 
469
469
  # At the present time, we cannot express intersection of Protocol and SQLModel directly.
470
470
  # Thus, we define union types here for the mixins.
471
- SequenceModelMixin = SequenceModelMixinProtocol | SQLModel
472
- ChangingModelMixin = ChangingModelMixinProtocol | SQLModel
473
- SnapshotModelMixin = SnapshotModelMixinProtocol | SQLModel
474
- RevisionModelMixin = RevisionModelMixinProtocol | SQLModel
471
+ SequenceModelMixin = SequenceModelMixinProtocol | pdt.BaseModel
472
+ ChangingModelMixin = ChangingModelMixinProtocol | pdt.BaseModel
473
+ SnapshotModelMixin = SnapshotModelMixinProtocol | pdt.BaseModel
474
+ RevisionModelMixin = RevisionModelMixinProtocol | pdt.BaseModel
475
475
 
476
476
 
477
477
  def make_sequence_model_mixin(dialect: str | None = None) -> type[SequenceModelMixin]:
@@ -483,7 +483,7 @@ def make_sequence_model_mixin(dialect: str | None = None) -> type[SequenceModelM
483
483
  :return: A mixin class that can be used with SQLModel models to add the ``sqn`` field.
484
484
  """
485
485
 
486
- class ModelMixin(SQLModel):
486
+ class ModelMixin(pdt.BaseModel):
487
487
  sqn: int | None = Field(
488
488
  sa_column=sa.Column(model_sqn_type(dialect), primary_key=True, autoincrement=True),
489
489
  default=None,
@@ -503,7 +503,7 @@ def make_changing_model_mixin(dialect: str | None = None) -> type[ChangingModelM
503
503
  updatable records.
504
504
  """
505
505
 
506
- class ModelMixin(SQLModel):
506
+ class ModelMixin(pdt.BaseModel):
507
507
  sqn: int | None = Field(
508
508
  sa_column=sa.Column(model_sqn_type(dialect), primary_key=True, autoincrement=True),
509
509
  default=None,
@@ -573,7 +573,7 @@ def make_snapshot_model_mixin(dialect: str | None = None) -> type[SnapshotModelM
573
573
  record snapshots.
574
574
  """
575
575
 
576
- class ModelMixin(SQLModel):
576
+ class ModelMixin(pdt.BaseModel):
577
577
  sqn: int | None = Field(
578
578
  sa_column=sa.Column(model_sqn_type(dialect), primary_key=True, autoincrement=True),
579
579
  default=None,
@@ -676,7 +676,7 @@ def make_revision_model_mixin(dialect: str | None = None) -> type[RevisionModelM
676
676
  record revisions.
677
677
  """
678
678
 
679
- class ModelMixin(SQLModel):
679
+ class ModelMixin(pdt.BaseModel):
680
680
  sqn: int | None = Field(
681
681
  sa_column=sa.Column(model_sqn_type(dialect), primary_key=True, autoincrement=True),
682
682
  default=None,
@@ -27,7 +27,7 @@ from iker.common.utils.iterutils import dicttree_children, dicttree_lineage, dic
27
27
  from iker.common.utils.jsonutils import JsonObject, JsonType
28
28
  from iker.common.utils.randutils import randomizer
29
29
  from iker.common.utils.strutils import is_blank
30
- from sqlmodel import Field, SQLModel
30
+ from sqlmodel import Field
31
31
 
32
32
  from plexus.common.resources.tags import predefined_tagset_specs
33
33
  from plexus.common.utils.datautils import validate_colon_tag, validate_snake_case, validate_vehicle_name
@@ -46,6 +46,8 @@ __all__ = [
46
46
  "populate_tagset",
47
47
  "predefined_tagsets",
48
48
  "render_tagset_markdown_readme",
49
+ "make_tag_target_model_mixin",
50
+ "make_tag_record_model_mixin",
49
51
  "TagTarget",
50
52
  "TagRecord",
51
53
  "TagTargetTable",
@@ -376,173 +378,187 @@ def render_tagset_markdown_readme(tagset: Tagset) -> str:
376
378
  return env.from_string(template_str).render(tagset=tagset)
377
379
 
378
380
 
379
- BaseModel = make_base_model()
380
-
381
-
382
- class TagTarget(BaseModel):
383
- identifier: str = Field(
384
- sa_column=sa.Column(sa_sqlite.VARCHAR(256), nullable=False, unique=True),
385
- description="Identifier of the tag target",
386
- )
387
- tagger_name: str = Field(
388
- sa_column=sa.Column(sa_sqlite.VARCHAR(128), nullable=False),
389
- description="Name of the tagger that generates the tag records for the target",
390
- )
391
- tagger_version: str = Field(
392
- sa_column=sa.Column(sa_sqlite.VARCHAR(32), nullable=False),
393
- description="Version of the tagger that generates the tag records for the target",
394
- )
395
- vehicle_name: str = Field(
396
- sa_column=sa.Column(sa_sqlite.VARCHAR(128), nullable=False),
397
- description="Vehicle name associated with the tag record",
398
- )
399
- begin_dt: datetime.datetime = Field(
400
- sa_column=sa.Column(SQLiteDateTime, nullable=False),
401
- description="Begin datetime of the target range associated with the tag record",
402
- )
403
- end_dt: datetime.datetime = Field(
404
- sa_column=sa.Column(SQLiteDateTime, nullable=False),
405
- description="End datetime of the target range associated with the tag record",
406
- )
407
-
408
- @pdt.field_validator("identifier", mode="after")
409
- @classmethod
410
- def validate_identifier(cls, v: str) -> str:
411
- validate_slash_tag(v)
412
- return v
413
-
414
- @pdt.field_validator("tagger_name", mode="after")
415
- @classmethod
416
- def validate_tagger_name(cls, v: str) -> str:
417
- validate_snake_case(v)
418
- return v
419
-
420
- @pdt.field_validator("tagger_version", mode="after")
421
- @classmethod
422
- def validate_tagger_version(cls, v: str) -> str:
423
- validate_semver(v)
424
- return v
425
-
426
- @pdt.field_validator("vehicle_name", mode="after")
427
- @classmethod
428
- def validate_vehicle_name(cls, v: str) -> str:
429
- validate_vehicle_name(v)
430
- return v
431
-
432
- @pdt.field_validator("begin_dt", mode="after")
433
- @classmethod
434
- def validate_begin_dt(cls, v: datetime.datetime) -> datetime.datetime:
435
- validate_dt_timezone(v)
436
- return v
437
-
438
- @pdt.field_validator("end_dt", mode="after")
439
- @classmethod
440
- def validate_end_dt(cls, v: datetime.datetime) -> datetime.datetime:
441
- validate_dt_timezone(v)
442
- return v
443
-
444
- @pdt.model_validator(mode="after")
445
- def validate_begin_dt_end_dt(self) -> Self:
446
- if self.begin_dt > self.end_dt:
447
- raise ValueError(f"begin_dt '{self.begin_dt}' is greater than end_dt '{self.end_dt}'")
448
- return self
381
+ def make_tag_target_model_mixin() -> type[pdt.BaseModel]:
382
+ class ModelMixin(pdt.BaseModel):
383
+ identifier: str = Field(
384
+ sa_column=sa.Column(sa_sqlite.VARCHAR(256), nullable=False, unique=True),
385
+ description="Identifier of the tag target",
386
+ )
387
+ tagger_name: str = Field(
388
+ sa_column=sa.Column(sa_sqlite.VARCHAR(128), nullable=False),
389
+ description="Name of the tagger that generates the tag records for the target",
390
+ )
391
+ tagger_version: str = Field(
392
+ sa_column=sa.Column(sa_sqlite.VARCHAR(32), nullable=False),
393
+ description="Version of the tagger that generates the tag records for the target",
394
+ )
395
+ vehicle_name: str = Field(
396
+ sa_column=sa.Column(sa_sqlite.VARCHAR(128), nullable=False),
397
+ description="Vehicle name associated with the tag record",
398
+ )
399
+ begin_dt: datetime.datetime = Field(
400
+ sa_column=sa.Column(SQLiteDateTime, nullable=False),
401
+ description="Begin datetime of the target range associated with the tag record",
402
+ )
403
+ end_dt: datetime.datetime = Field(
404
+ sa_column=sa.Column(SQLiteDateTime, nullable=False),
405
+ description="End datetime of the target range associated with the tag record",
406
+ )
449
407
 
450
- @pdt.field_serializer("begin_dt", mode="plain")
451
- def serialize_begin_dt(self, v: datetime.datetime) -> str:
452
- return json_datetime_encoder(v)
408
+ @pdt.field_validator("identifier", mode="after")
409
+ @classmethod
410
+ def validate_identifier(cls, v: str) -> str:
411
+ validate_slash_tag(v)
412
+ return v
453
413
 
454
- @pdt.field_serializer("end_dt", mode="plain")
455
- def serialize_end_dt(self, v: datetime.datetime) -> str:
456
- return json_datetime_encoder(v)
414
+ @pdt.field_validator("tagger_name", mode="after")
415
+ @classmethod
416
+ def validate_tagger_name(cls, v: str) -> str:
417
+ validate_snake_case(v)
418
+ return v
457
419
 
420
+ @pdt.field_validator("tagger_version", mode="after")
421
+ @classmethod
422
+ def validate_tagger_version(cls, v: str) -> str:
423
+ validate_semver(v)
424
+ return v
425
+
426
+ @pdt.field_validator("vehicle_name", mode="after")
427
+ @classmethod
428
+ def validate_vehicle_name(cls, v: str) -> str:
429
+ validate_vehicle_name(v)
430
+ return v
431
+
432
+ @pdt.field_validator("begin_dt", mode="after")
433
+ @classmethod
434
+ def validate_begin_dt(cls, v: datetime.datetime) -> datetime.datetime:
435
+ validate_dt_timezone(v)
436
+ return v
437
+
438
+ @pdt.field_validator("end_dt", mode="after")
439
+ @classmethod
440
+ def validate_end_dt(cls, v: datetime.datetime) -> datetime.datetime:
441
+ validate_dt_timezone(v)
442
+ return v
443
+
444
+ @pdt.model_validator(mode="after")
445
+ def validate_begin_dt_end_dt(self) -> Self:
446
+ if self.begin_dt > self.end_dt:
447
+ raise ValueError(f"begin_dt '{self.begin_dt}' is greater than end_dt '{self.end_dt}'")
448
+ return self
449
+
450
+ @pdt.field_serializer("begin_dt", mode="plain")
451
+ def serialize_begin_dt(self, v: datetime.datetime) -> str:
452
+ return json_datetime_encoder(v)
453
+
454
+ @pdt.field_serializer("end_dt", mode="plain")
455
+ def serialize_end_dt(self, v: datetime.datetime) -> str:
456
+ return json_datetime_encoder(v)
457
+
458
+ return ModelMixin
459
+
460
+
461
+ def make_tag_record_model_mixin() -> type[pdt.BaseModel]:
462
+ class ModelMixin(pdt.BaseModel):
463
+ target_sqn: int = Field(
464
+ sa_column=sa.Column(sa_sqlite.INTEGER, nullable=False),
465
+ description="Sequence number of the tag record's target",
466
+ )
467
+ begin_dt: datetime.datetime = Field(
468
+ sa_column=sa.Column(SQLiteDateTime, nullable=False),
469
+ description="Begin datetime of the tag record",
470
+ )
471
+ end_dt: datetime.datetime = Field(
472
+ sa_column=sa.Column(SQLiteDateTime, nullable=False),
473
+ description="End datetime of the tag record",
474
+ )
475
+ tagset_namespace: str | None = Field(
476
+ sa_column=sa.Column(sa_sqlite.VARCHAR(64), nullable=True),
477
+ default=None,
478
+ description="Namespace of the tagset that the tag belongs to",
479
+ )
480
+ tagset_version: str | None = Field(
481
+ sa_column=sa.Column(sa_sqlite.VARCHAR(32), nullable=True),
482
+ default=None,
483
+ description="Version of the tagset that the tag belongs to",
484
+ )
485
+ tag: str = Field(
486
+ sa_column=sa.Column(sa_sqlite.VARCHAR(256), nullable=False),
487
+ description="Tag name",
488
+ )
489
+ props: JsonType | None = Field(
490
+ sa_column=sa.Column(sa_sqlite.JSON, nullable=True),
491
+ default=None,
492
+ description="Additional properties of the tag record in JSON format",
493
+ )
494
+ flags: int = Field(
495
+ sa_column=sa.Column(sa_sqlite.INTEGER),
496
+ default=0,
497
+ description="Integer bitmask storing status or metadata flags for this tag record",
498
+ )
458
499
 
459
- class TagRecord(BaseModel):
460
- target_sqn: int = Field(
461
- sa_column=sa.Column(sa_sqlite.INTEGER, nullable=False),
462
- description="Sequence number of the tag record's target",
463
- )
464
- begin_dt: datetime.datetime = Field(
465
- sa_column=sa.Column(SQLiteDateTime, nullable=False),
466
- description="Begin datetime of the tag record",
467
- )
468
- end_dt: datetime.datetime = Field(
469
- sa_column=sa.Column(SQLiteDateTime, nullable=False),
470
- description="End datetime of the tag record",
471
- )
472
- tagset_namespace: str | None = Field(
473
- sa_column=sa.Column(sa_sqlite.VARCHAR(64), nullable=True),
474
- default=None,
475
- description="Namespace of the tagset that the tag belongs to",
476
- )
477
- tagset_version: str | None = Field(
478
- sa_column=sa.Column(sa_sqlite.VARCHAR(32), nullable=True),
479
- default=None,
480
- description="Version of the tagset that the tag belongs to",
481
- )
482
- tag: str = Field(
483
- sa_column=sa.Column(sa_sqlite.VARCHAR(256), nullable=False),
484
- description="Tag name",
485
- )
486
- props: JsonType | None = Field(
487
- sa_column=sa.Column(sa_sqlite.JSON, nullable=True),
488
- default=None,
489
- description="Additional properties of the tag record in JSON format",
490
- )
491
- flags: int = Field(
492
- sa_column=sa.Column(sa_sqlite.INTEGER),
493
- default=0,
494
- description="Integer bitmask storing status or metadata flags for this tag record",
495
- )
500
+ @pdt.field_validator("begin_dt", mode="after")
501
+ @classmethod
502
+ def validate_begin_dt(cls, v: datetime.datetime) -> datetime.datetime:
503
+ validate_dt_timezone(v)
504
+ return v
505
+
506
+ @pdt.field_validator("end_dt", mode="after")
507
+ @classmethod
508
+ def validate_end_dt(cls, v: datetime.datetime) -> datetime.datetime:
509
+ validate_dt_timezone(v)
510
+ return v
511
+
512
+ @pdt.field_validator("tagset_namespace", mode="after")
513
+ @classmethod
514
+ def validate_tagset_namespace(cls, v: str | None) -> str | None:
515
+ if v is not None:
516
+ validate_snake_case(v)
517
+ return v
518
+
519
+ @pdt.field_validator("tagset_version", mode="after")
520
+ @classmethod
521
+ def validate_tagset_version(cls, v: str | None) -> str | None:
522
+ if v is not None:
523
+ validate_semver(v)
524
+ return v
525
+
526
+ @pdt.model_validator(mode="after")
527
+ def validate_begin_dt_end_dt(self) -> Self:
528
+ if self.begin_dt > self.end_dt:
529
+ raise ValueError(f"begin_dt '{self.begin_dt}' is greater than end_dt '{self.end_dt}'")
530
+ return self
531
+
532
+ @pdt.field_validator("tag", mode="after")
533
+ @classmethod
534
+ def validate_tag(cls, v: str) -> str:
535
+ validate_colon_tag(v)
536
+ return v
537
+
538
+ @pdt.field_serializer("begin_dt", mode="plain")
539
+ def serialize_begin_dt(self, v: datetime.datetime) -> str:
540
+ return json_datetime_encoder(v)
541
+
542
+ @pdt.field_serializer("end_dt", mode="plain")
543
+ def serialize_end_dt(self, v: datetime.datetime) -> str:
544
+ return json_datetime_encoder(v)
545
+
546
+ return ModelMixin
496
547
 
497
- @pdt.field_validator("begin_dt", mode="after")
498
- @classmethod
499
- def validate_begin_dt(cls, v: datetime.datetime) -> datetime.datetime:
500
- validate_dt_timezone(v)
501
- return v
502
-
503
- @pdt.field_validator("end_dt", mode="after")
504
- @classmethod
505
- def validate_end_dt(cls, v: datetime.datetime) -> datetime.datetime:
506
- validate_dt_timezone(v)
507
- return v
508
-
509
- @pdt.field_validator("tagset_namespace", mode="after")
510
- @classmethod
511
- def validate_tagset_namespace(cls, v: str | None) -> str | None:
512
- if v is not None:
513
- validate_snake_case(v)
514
- return v
515
548
 
516
- @pdt.field_validator("tagset_version", mode="after")
517
- @classmethod
518
- def validate_tagset_version(cls, v: str | None) -> str | None:
519
- if v is not None:
520
- validate_semver(v)
521
- return v
549
+ BaseModel = make_base_model()
522
550
 
523
- @pdt.model_validator(mode="after")
524
- def validate_begin_dt_end_dt(self) -> Self:
525
- if self.begin_dt > self.end_dt:
526
- raise ValueError(f"begin_dt '{self.begin_dt}' is greater than end_dt '{self.end_dt}'")
527
- return self
528
551
 
529
- @pdt.field_validator("tag", mode="after")
530
- @classmethod
531
- def validate_tag(cls, v: str) -> str:
532
- validate_colon_tag(v)
533
- return v
552
+ class TagTarget(BaseModel, make_tag_target_model_mixin()):
553
+ pass
534
554
 
535
- @pdt.field_serializer("begin_dt", mode="plain")
536
- def serialize_begin_dt(self, v: datetime.datetime) -> str:
537
- return json_datetime_encoder(v)
538
555
 
539
- @pdt.field_serializer("end_dt", mode="plain")
540
- def serialize_end_dt(self, v: datetime.datetime) -> str:
541
- return json_datetime_encoder(v)
556
+ class TagRecord(BaseModel, make_tag_record_model_mixin()):
557
+ pass
542
558
 
543
559
 
544
560
  class TagTargetTable(TagTarget, make_sequence_model_mixin("sqlite"), table=True):
545
- __tablename__ = "tag_target_info"
561
+ __tablename__ = "tag_target"
546
562
 
547
563
 
548
564
  class TagRecordTable(TagRecord, make_sequence_model_mixin("sqlite"), table=True):
@@ -550,7 +566,7 @@ class TagRecordTable(TagRecord, make_sequence_model_mixin("sqlite"), table=True)
550
566
 
551
567
 
552
568
  if typing.TYPE_CHECKING:
553
- class TagTargetTable(SQLModel, SequenceModelMixinProtocol):
569
+ class TagTarget(BaseModel):
554
570
  identifier: sa_orm.Mapped[str] = ...
555
571
  tagger_name: sa_orm.Mapped[str] = ...
556
572
  tagger_version: sa_orm.Mapped[str] = ...
@@ -559,7 +575,11 @@ if typing.TYPE_CHECKING:
559
575
  end_dt: sa_orm.Mapped[datetime.datetime] = ...
560
576
 
561
577
 
562
- class TagRecordTable(SQLModel, SequenceModelMixinProtocol):
578
+ class TagTargetTable(TagTarget, SequenceModelMixinProtocol):
579
+ pass
580
+
581
+
582
+ class TagRecord(BaseModel):
563
583
  target_sqn: sa_orm.Mapped[int] = ...
564
584
  begin_dt: sa_orm.Mapped[datetime.datetime] = ...
565
585
  end_dt: sa_orm.Mapped[datetime.datetime] = ...
@@ -570,6 +590,10 @@ if typing.TYPE_CHECKING:
570
590
  flags: sa_orm.Mapped[int] = ...
571
591
 
572
592
 
593
+ class TagRecordTable(TagRecord, SequenceModelMixinProtocol):
594
+ pass
595
+
596
+
573
597
  @singleton
574
598
  def tag_cache_file_path() -> pathlib.Path:
575
599
  return pathlib.Path.home() / ".local" / "plexus" / "tag_cache" / f"{randomizer().random_alphanumeric(7)}.db"
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: plexus-python-common
3
- Version: 1.0.66
3
+ Version: 1.0.67
4
4
  Classifier: Programming Language :: Python :: 3
5
5
  Classifier: Programming Language :: Python :: 3.12
6
6
  Classifier: Programming Language :: Python :: 3.13
@@ -16,14 +16,14 @@ plexus/common/utils/datautils.py,sha256=mgnr-dcHpw-Pk3qBud0lC3JX_pv-iKzI8llsPW9Q
16
16
  plexus/common/utils/dockerutils.py,sha256=WPxQuabRWyyM8wpSSYhb_HZaOw5yZ2TbU2dEQ2xRIlQ,5787
17
17
  plexus/common/utils/gisutils.py,sha256=UR3uVoD1nAy0SWJ1AYWCUy94Lo8zNb4nv_JdpcANBDE,11462
18
18
  plexus/common/utils/jsonutils.py,sha256=-_uKlQMLMgmVO9pB99S45Y_Vufx5dFSq43DIwGz1a54,3328
19
- plexus/common/utils/ormutils.py,sha256=_kkQLTScYeoAneEdbGvkcsXh1TDja__AUznVkOpRNn0,60393
19
+ plexus/common/utils/ormutils.py,sha256=CHrp6l5shRL2qa8GzRLqeVbtC-eZZkfWCOpBy32JDok,60433
20
20
  plexus/common/utils/pathutils.py,sha256=hGJqSLj08tuOeZ7WeC5d4BtjnPI732BuntVQBQsqOaI,9581
21
21
  plexus/common/utils/s3utils.py,sha256=zlO4kGs-c2gUeOfPfiKIE5liQZsbYxqAZYCwA8kL0Lo,36017
22
22
  plexus/common/utils/sqlutils.py,sha256=D6kTBjhO5YlNRt3uFlPt6z3uH61m9ajEzPYmsI6NoFc,231
23
23
  plexus/common/utils/strutils.py,sha256=O9Inv4ffUTf6Xjc5ftoZwbIua1NeG7itCT9S3zjZxBc,16436
24
- plexus/common/utils/tagutils.py,sha256=MzsuxBH62lAPuvQL1wx7kKvQHsA5NXYMEPRhSYwb4gA,51077
24
+ plexus/common/utils/tagutils.py,sha256=n4yd4KIq8Ub4sGN8wYFom1Ea4IJ19s9UEW-rTl30NDs,52104
25
25
  plexus/common/utils/testutils.py,sha256=N8ijLu7X-hlQlHzvv0TtSsQpIF4T1hbr-AjkILoV2Ac,6152
26
- plexus_python_common-1.0.66.dist-info/METADATA,sha256=FrVKPSwnSIbWkpwtHO-PABwKcvEK6Sey8UtP8sRKleg,1481
27
- plexus_python_common-1.0.66.dist-info/WHEEL,sha256=aeYiig01lYGDzBgS8HxWXOg3uV61G9ijOsup-k9o1sk,91
28
- plexus_python_common-1.0.66.dist-info/top_level.txt,sha256=ug_g7CVwaMQuas5UzAXbHUrQvKGCn8ezc6ZNvvRlJOE,7
29
- plexus_python_common-1.0.66.dist-info/RECORD,,
26
+ plexus_python_common-1.0.67.dist-info/METADATA,sha256=VYNQqHRyN3ivhmKeAU4tVa1xtVuUlfpQT8U706C3Ps0,1481
27
+ plexus_python_common-1.0.67.dist-info/WHEEL,sha256=aeYiig01lYGDzBgS8HxWXOg3uV61G9ijOsup-k9o1sk,91
28
+ plexus_python_common-1.0.67.dist-info/top_level.txt,sha256=ug_g7CVwaMQuas5UzAXbHUrQvKGCn8ezc6ZNvvRlJOE,7
29
+ plexus_python_common-1.0.67.dist-info/RECORD,,