Skip to content

Commit a566850

Browse files
Merge branch 'master' into refactor-api-keys-service
2 parents 08183d6 + dfd1463 commit a566850

File tree

123 files changed

+6125
-1717
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

123 files changed

+6125
-1717
lines changed

.coveragerc

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -7,25 +7,20 @@ parallel = True
77

88
[report]
99
# Regexes for lines to exclude from consideration
10-
exclude_lines =
11-
# Have to re-enable the standard pragma
12-
pragma: no cover
13-
10+
exclude_also =
1411
# Don't complain about missing debug-only code:
1512
def __repr__
1613
if self\.debug
17-
1814
# Don't complain if tests don't hit defensive assertion code:
1915
raise AssertionError
2016
raise NotImplementedError
21-
2217
# Don't complain if non-runnable code isn't run:
2318
if 0:
2419
if __name__ == .__main__.:
2520
if __name__ == __main__.:
21+
class .*\bProtocol\):
2622
# Don't complain about abstract methods, they aren't run:
2723
@(abc\.)?abstract(((class|static)?method)|property)
28-
2924
# Don't complain about type checking
3025
if TYPE_CHECKING:
3126

.env-devel

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -90,8 +90,8 @@ EFS_GROUP_NAME=efs-group
9090
EFS_DNS_NAME=fs-xxx.efs.us-east-1.amazonaws.com
9191
EFS_MOUNTED_PATH=/tmp/efs
9292
EFS_PROJECT_SPECIFIC_DATA_DIRECTORY=project-specific-data
93-
EFS_ONLY_ENABLED_FOR_USERIDS=[]
9493
EFS_GUARDIAN_TRACING={}
94+
EFS_DEFAULT_USER_SERVICE_SIZE_BYTES=10000
9595

9696
# DATCORE_ADAPTER
9797
DATCORE_ADAPTER_TRACING={}

api/specs/director/schemas/scripts/create_node-meta-schema.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,14 +8,15 @@
88
from pathlib import Path
99

1010
import jsonref
11+
from common_library.json_serialization import json_dumps
1112
from models_library.services import ServiceMetaDataPublished
1213

1314
CURRENT_DIR = Path(sys.argv[0] if __name__ == "__main__" else __file__).resolve().parent
1415

1516

1617
if __name__ == "__main__":
1718
with Path.open(CURRENT_DIR.parent / "node-meta-v0.0.1-pydantic.json", "w") as f:
18-
schema = ServiceMetaDataPublished.schema_json()
19+
schema = json_dumps(ServiceMetaDataPublished.model_json_schema())
1920
schema_without_ref = jsonref.loads(schema)
2021

2122
json.dump(schema_without_ref, f, indent=2)

api/specs/director/schemas/scripts/create_project-schema.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
from pathlib import Path
99

1010
import jsonref
11+
from common_library.json_serialization import json_dumps
1112
from models_library.projects import Project
1213

1314
CURRENT_DIR = Path(sys.argv[0] if __name__ == "__main__" else __file__).resolve().parent
@@ -17,7 +18,7 @@
1718
with Path.open(
1819
CURRENT_DIR.parent / "common/schemas/project-v0.0.1-pydantic.json", "w"
1920
) as f:
20-
schema = Project.schema_json()
21+
schema = json_dumps(Project.model_json_schema())
2122
schema_without_ref = jsonref.loads(schema)
2223

2324
json.dump(schema_without_ref, f, indent=2)

packages/models-library/Makefile

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -49,13 +49,6 @@ tests-ci: ## runs unit tests [ci-mode]
4949
-m "not heavy_load" \
5050
$(CURDIR)/tests
5151

52-
.PHONY: project-jsonschema.ignore.json
53-
project-jsonschema.ignore.json: ## creates project-v0.0.1.json for DEV purposes
54-
python3 -c "from models_library.projects import Project; print(Project.schema_json(indent=2))" > $@
55-
56-
.PHONY: service-jsonschema.ignore.json
57-
node-meta-jsonschema.ignore.json: ## creates node-meta-v0.0.1.json for DEV purposes
58-
python3 -c "from models_library.services import ServiceDockerData as cls; print(cls.schema_json(indent=2))" > $@
5952

6053
DOCKER_API_VERSION ?= 1.41
6154
.PHONY: docker_rest_api.py

packages/models-library/src/models_library/function_services_catalog/services/iter_sensitivity.py

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,15 +2,18 @@
22
from copy import deepcopy
33
from typing import Any
44

5-
from pydantic import schema_of
5+
from pydantic import TypeAdapter
66

77
from ...projects_nodes import OutputID, OutputsDict
88
from ...services import ServiceMetaDataPublished, ServiceType
99
from ...services_constants import LATEST_INTEGRATION_VERSION
1010
from .._key_labels import FUNCTION_SERVICE_KEY_PREFIX
1111
from .._utils import EN, OM, FunctionServices, create_fake_thumbnail_url
1212

13-
LIST_NUMBERS_SCHEMA: dict[str, Any] = schema_of(list[float], title="list[number]")
13+
LIST_NUMBERS_SCHEMA: dict[str, Any] = {
14+
**TypeAdapter(list[float]).json_schema(),
15+
"title": "list[number]",
16+
}
1417

1518

1619
META = ServiceMetaDataPublished.model_validate(

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@
3434

3535
UUIDStr: TypeAlias = Annotated[str, StringConstraints(pattern=UUID_RE)]
3636

37-
NodeIDStr = UUIDStr
37+
NodeIDStr: TypeAlias = UUIDStr
3838

3939
LocationID = int
4040
LocationName = str

packages/models-library/src/models_library/utils/common_validators.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ class MyModel(BaseModel):
2222

2323
from common_library.json_serialization import json_loads
2424
from orjson import JSONDecodeError
25+
from pydantic import BaseModel
2526

2627

2728
def empty_str_to_none_pre_validator(value: Any):
@@ -102,8 +103,8 @@ def create__check_only_one_is_set__root_validator(alternative_field_names: list[
102103
SEE test_uid_or_email_are_set.py for more details
103104
"""
104105

105-
def _validator(cls, values):
106-
assert set(alternative_field_names).issubset(cls.__fields__) # nosec
106+
def _validator(cls: type[BaseModel], values):
107+
assert set(alternative_field_names).issubset(cls.model_fields) # nosec
107108

108109
got = {
109110
field_name: getattr(values, field_name)

packages/models-library/src/models_library/utils/services_io.py

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,16 +2,20 @@
22
from copy import deepcopy
33
from typing import Any, Literal
44

5-
from pydantic import schema_of
5+
from pydantic import TypeAdapter
66

77
from ..services import ServiceInput, ServiceOutput
88
from ..services_regex import PROPERTY_TYPE_TO_PYTHON_TYPE_MAP
99

1010
PortKindStr = Literal["input", "output"]
1111
JsonSchemaDict = dict[str, Any]
1212

13+
1314
_PROPERTY_TYPE_TO_SCHEMAS = {
14-
property_type: schema_of(python_type, title=property_type.capitalize())
15+
property_type: {
16+
**TypeAdapter(python_type).json_schema(),
17+
"title": property_type.capitalize(),
18+
}
1519
for property_type, python_type in PROPERTY_TYPE_TO_PYTHON_TYPE_MAP.items()
1620
}
1721

packages/models-library/tests/test__models_fit_schemas.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@
22
# pylint:disable=unused-argument
33
# pylint:disable=redefined-outer-name
44
# pylint:disable=protected-access
5-
import json
65
from collections.abc import Callable
76

87
import pytest
@@ -28,7 +27,7 @@ def test_generated_schema_same_as_original(
2827
# TODO: create instead a fixture that returns a Callable and do these checks
2928
# on separate test_* files that follow the same package submodule's hierarchy
3029
#
31-
generated_schema = json.loads(pydantic_model.schema_json(indent=2))
30+
generated_schema = pydantic_model.model_json_schema()
3231
original_schema = json_schema_dict(original_json_schema)
3332

3433
# NOTE: A change is considered an addition when the destination schema has become more permissive relative to the source schema. For example {"type": "string"} -> {"type": ["string", "number"]}.

0 commit comments

Comments
 (0)