Skip to content

Commit 7f7293f

Browse files
committed
adds model examples
1 parent 0dd4c6b commit 7f7293f

File tree

2 files changed

+42
-19
lines changed

2 files changed

+42
-19
lines changed

packages/models-library/src/models_library/projects_filters.py

Lines changed: 0 additions & 18 deletions
This file was deleted.

packages/models-library/src/models_library/rpc/webserver/projects.py

Lines changed: 42 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,13 +24,54 @@ class MetadataFilterItem(BaseModel):
2424

2525

2626
class ListProjectsMarkedAsJobRpcFilter(BaseModel):
27-
# NOTE: add here any early validation of filters e.g. incompatible filters etc
27+
"""Filter model for the list_projects_marked_as_jobs RPC.
28+
29+
NOTE: Filter models are used to validate all possible filters in an API early on,
30+
particularly to ensure compatibility and prevent conflicts between different filters.
31+
"""
32+
2833
job_parent_resource_name_prefix: str | None = None
34+
2935
any_of_metadata: Annotated[
3036
list[MetadataFilterItem] | None,
3137
Field(description="Searchs for matches of any of the custom metadata fields"),
3238
] = None
3339

40+
@staticmethod
41+
def _update_json_schema_extra(schema: JsonDict) -> None:
42+
schema.update(
43+
{
44+
"examples": [
45+
{
46+
"job_parent_resource_name_prefix": "solvers/solver123",
47+
"any_of_metadata": [
48+
{
49+
"name": "solver_type",
50+
"pattern": "FEM",
51+
},
52+
{
53+
"name": "mesh_cells",
54+
"pattern": "1*",
55+
},
56+
],
57+
},
58+
{
59+
"any_of_metadata": [
60+
{
61+
"name": "solver_type",
62+
"pattern": "*CFD*",
63+
}
64+
],
65+
},
66+
{"job_parent_resource_name_prefix": "solvers/solver123"},
67+
]
68+
}
69+
)
70+
71+
model_config = ConfigDict(
72+
json_schema_extra=_update_json_schema_extra,
73+
)
74+
3475

3576
class ProjectJobRpcGet(BaseModel):
3677
"""

0 commit comments

Comments
 (0)