fable-model 0.2.2__tar.gz → 0.4.0__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.
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: fable-model
3
- Version: 0.2.2
3
+ Version: 0.4.0
4
4
  Summary: Data models utilized in the FABLE ecosystem's HTTP-based services.
5
5
  License-Expression: MIT
6
6
  License-File: LICENSE
@@ -16,13 +16,14 @@ Classifier: Programming Language :: Python :: 3.11
16
16
  Classifier: Programming Language :: Python :: 3.12
17
17
  Classifier: Programming Language :: Python :: 3.13
18
18
  Classifier: Programming Language :: Python :: 3.14
19
+ Requires-Dist: packaging (>=26.3,<27.0)
19
20
  Requires-Dist: pydantic (>=2.7.0,<3.0.0)
20
21
  Project-URL: Repository, https://github.com/ul-mds/fable-model
21
22
  Description-Content-Type: text/markdown
22
23
 
23
24
  [![PyPI](https://img.shields.io/pypi/v/fable-model?cacheSeconds=0)](https://pypi.org/project/fable-model/)
24
25
  [![Python Versions](https://img.shields.io/pypi/pyversions/fable-model?cacheSeconds=0)](https://pypi.org/project/fable-model/)
25
- ![Code Coverage](https://img.shields.io/badge/Coverage-98%25-brightgreen.svg)
26
+ ![Code Coverage](https://img.shields.io/badge/Coverage-97%25-brightgreen.svg)
26
27
  [![License](https://img.shields.io/pypi/l/fable-model?cacheSeconds=0)](https://pypi.org/project/fable-model/)
27
28
  [![Conventional Commits](https://img.shields.io/badge/Conventional%20Commits-1.0.0-%23FE5196?logo=conventionalcommits&logoColor=white)](https://conventionalcommits.org)
28
29
 
@@ -1,6 +1,6 @@
1
1
  [![PyPI](https://img.shields.io/pypi/v/fable-model?cacheSeconds=0)](https://pypi.org/project/fable-model/)
2
2
  [![Python Versions](https://img.shields.io/pypi/pyversions/fable-model?cacheSeconds=0)](https://pypi.org/project/fable-model/)
3
- ![Code Coverage](https://img.shields.io/badge/Coverage-98%25-brightgreen.svg)
3
+ ![Code Coverage](https://img.shields.io/badge/Coverage-97%25-brightgreen.svg)
4
4
  [![License](https://img.shields.io/pypi/l/fable-model?cacheSeconds=0)](https://pypi.org/project/fable-model/)
5
5
  [![Conventional Commits](https://img.shields.io/badge/Conventional%20Commits-1.0.0-%23FE5196?logo=conventionalcommits&logoColor=white)](https://conventionalcommits.org)
6
6
 
@@ -1,4 +1,4 @@
1
- from .common import BitVectorEntity, AttributeValueEntity, HealthResponse
1
+ from .common import BitVectorEntity, AttributeValueEntity, HealthResponse, ServiceBaseInformation
2
2
  from .mask import (
3
3
  HashStrategy,
4
4
  DoubleHash,
@@ -58,6 +58,25 @@ from .transform import (
58
58
  EntityTransformResponse,
59
59
  BaseTransformRequest,
60
60
  )
61
+ from .broker import (
62
+ BaseSessionModel,
63
+ BaseAuthenticatedSessionModel,
64
+ SessionCreationRequest,
65
+ SessionUpdateRequest,
66
+ SessionCreationResponse,
67
+ SessionDeletionRequest,
68
+ SessionUpdateResponse,
69
+ BitVectorMetadata,
70
+ MetaBitVectorEntity,
71
+ BaseClientModel,
72
+ ClientSubmissionRequest,
73
+ ClientVectorBatch,
74
+ VectorMatchBatch,
75
+ ClientResultRequest,
76
+ MatchedClientVector,
77
+ ClientResultResponse,
78
+ SessionGetResponse,
79
+ )
61
80
 
62
81
  __all__ = [
63
82
  "BitVectorEntity",
@@ -119,4 +138,22 @@ __all__ = [
119
138
  "BaseMatchRequest",
120
139
  "MatchMethod",
121
140
  "SimilarityAggregator",
141
+ "BaseSessionModel",
142
+ "BaseAuthenticatedSessionModel",
143
+ "SessionCreationRequest",
144
+ "SessionUpdateRequest",
145
+ "SessionCreationResponse",
146
+ "SessionDeletionRequest",
147
+ "SessionUpdateResponse",
148
+ "BitVectorMetadata",
149
+ "MetaBitVectorEntity",
150
+ "BaseClientModel",
151
+ "ClientSubmissionRequest",
152
+ "ClientVectorBatch",
153
+ "VectorMatchBatch",
154
+ "ClientResultRequest",
155
+ "MatchedClientVector",
156
+ "ClientResultResponse",
157
+ "ServiceBaseInformation",
158
+ "SessionGetResponse",
122
159
  ]
@@ -1,17 +1,25 @@
1
1
  from typing import Annotated
2
2
 
3
- from pydantic import BaseModel, Field
3
+ from pydantic import BaseModel, Field, SecretStr, field_serializer
4
4
 
5
5
  from fable_model.common import BitVectorEntity
6
6
  from fable_model.match import MatchConfig
7
7
 
8
8
 
9
9
  class BaseSessionModel(BaseModel):
10
- session: str
10
+ session: SecretStr
11
+
12
+ @field_serializer("session")
13
+ def serialize_session(self, value: SecretStr) -> str:
14
+ return value.get_secret_value()
11
15
 
12
16
 
13
17
  class BaseAuthenticatedSessionModel(BaseSessionModel):
14
- token: str
18
+ token: SecretStr
19
+
20
+ @field_serializer("token")
21
+ def serialize_token(self, value: SecretStr) -> str:
22
+ return value.get_secret_value()
15
23
 
16
24
 
17
25
  class SessionCreationRequest(BaseSessionModel):
@@ -23,8 +31,16 @@ class SessionUpdateResponse(BaseSessionModel):
23
31
  expires_at: int
24
32
 
25
33
 
34
+ class SessionGetResponse(SessionUpdateResponse):
35
+ match_config: MatchConfig
36
+
37
+
26
38
  class SessionCreationResponse(SessionUpdateResponse):
27
- token: str
39
+ token: SecretStr
40
+
41
+ @field_serializer("token")
42
+ def serialize_token(self, value: SecretStr) -> str:
43
+ return value.get_secret_value()
28
44
 
29
45
 
30
46
  SessionDeletionRequest = BaseAuthenticatedSessionModel
@@ -41,7 +57,11 @@ class MetaBitVectorEntity(BitVectorEntity):
41
57
 
42
58
 
43
59
  class BaseClientModel(BaseSessionModel):
44
- client: str
60
+ client: SecretStr
61
+
62
+ @field_serializer("client")
63
+ def serialize_client(self, value: SecretStr) -> str:
64
+ return value.get_secret_value()
45
65
 
46
66
 
47
67
  class ClientSubmissionRequest(BaseClientModel):
@@ -49,16 +69,24 @@ class ClientSubmissionRequest(BaseClientModel):
49
69
 
50
70
 
51
71
  class ClientVectorBatch(BaseModel):
52
- client: str
72
+ client: SecretStr
53
73
  ids: list[str]
54
74
 
75
+ @field_serializer("client")
76
+ def serialize_client(self, value: SecretStr) -> str:
77
+ return value.get_secret_value()
78
+
55
79
 
56
80
  class VectorMatchBatch(BaseModel):
57
81
  domain: ClientVectorBatch
58
82
  range: list[ClientVectorBatch]
59
- session: str
83
+ session: SecretStr
60
84
  config: MatchConfig
61
85
 
86
+ @field_serializer("session")
87
+ def serialize_session(self, value: SecretStr) -> str:
88
+ return value.get_secret_value()
89
+
62
90
 
63
91
  class ClientResultRequest(BaseClientModel):
64
92
  show_unfinished_results: bool = False
@@ -0,0 +1,35 @@
1
+ from typing import Annotated, Literal
2
+
3
+ from packaging.version import Version, InvalidVersion
4
+ from pydantic import BaseModel, ConfigDict, BeforeValidator
5
+
6
+
7
+ class ParentModel(BaseModel):
8
+ model_config = ConfigDict(extra="forbid")
9
+
10
+
11
+ class AttributeValueEntity(ParentModel):
12
+ id: str
13
+ attributes: dict[str, str]
14
+
15
+
16
+ class BitVectorEntity(ParentModel):
17
+ id: str
18
+ value: str
19
+
20
+
21
+ class HealthResponse(ParentModel):
22
+ status: Literal["ok"] = "ok"
23
+
24
+
25
+ def _validate_version(value: str) -> str:
26
+ try:
27
+ Version(value)
28
+ except InvalidVersion as e:
29
+ raise ValueError(f"Invalid version: {value!r}") from e
30
+
31
+ return value
32
+
33
+
34
+ class ServiceBaseInformation(ParentModel):
35
+ version: Annotated[str, BeforeValidator(_validate_version)]
@@ -1,6 +1,6 @@
1
1
  [project]
2
2
  name = "fable-model"
3
- version = "0.2.2"
3
+ version = "0.4.0"
4
4
  description = "Data models utilized in the FABLE ecosystem's HTTP-based services."
5
5
  authors = [
6
6
  {name = "Maximilian Jugl"},
@@ -9,7 +9,8 @@ authors = [
9
9
  readme = "README.md"
10
10
  requires-python = ">=3.11"
11
11
  dependencies = [
12
- "pydantic (>=2.7.0,<3.0.0)"
12
+ "pydantic (>=2.7.0,<3.0.0)",
13
+ "packaging (>=26.3,<27.0)"
13
14
  ]
14
15
  license = "MIT"
15
16
  classifiers = [
@@ -39,18 +40,15 @@ markers = [
39
40
  "integration: mark a test as an integration test."
40
41
  ]
41
42
 
42
- [tool.coverage.run]
43
- omit = [
44
- "fable_model/broker.py",
45
- ]
46
-
47
43
  [build-system]
48
44
  requires = ["poetry-core>=2.0.0,<3.0.0"]
49
45
  build-backend = "poetry.core.masonry.api"
50
46
 
51
- [tool.poetry.group.dev.dependencies]
52
- ruff = ">=0.15.0"
53
- pytest = ">=8.3.0"
54
- pytest-cov = "^7.1.0"
55
- pre-commit = "^4.6.0"
56
- readme-coverage-badger = "^1.1.0"
47
+ [dependency-groups]
48
+ dev = [
49
+ "ruff (>=0.15.0,<0.16.0)",
50
+ "pytest (>=9.1.1,<10.0.0)",
51
+ "pytest-cov (>=7.1.0,<8.0.0)",
52
+ "pre-commit (>=4.6.1,<5.0.0)",
53
+ "readme-coverage-badger (>=1.1.0,<2.0.0)"
54
+ ]
@@ -1,21 +0,0 @@
1
- from typing import Literal
2
-
3
- from pydantic import BaseModel, ConfigDict
4
-
5
-
6
- class ParentModel(BaseModel):
7
- model_config = ConfigDict(extra="forbid")
8
-
9
-
10
- class AttributeValueEntity(ParentModel):
11
- id: str
12
- attributes: dict[str, str]
13
-
14
-
15
- class BitVectorEntity(ParentModel):
16
- id: str
17
- value: str
18
-
19
-
20
- class HealthResponse(ParentModel):
21
- status: Literal["ok"] = "ok"
File without changes