Skip to content

Commit

Permalink
continue upgrade
Browse files Browse the repository at this point in the history
  • Loading branch information
giancarloromeo committed Oct 16, 2024
1 parent 21d5906 commit 04cd728
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
StrictInt,
TypeAdapter,
ValidationError,
ValidationInfo,
field_validator,
)
from servicelib.logging_utils import LogLevelInt, LogMessageStr
Expand Down Expand Up @@ -194,8 +195,8 @@ class Job(BaseModel):

@field_validator("name", mode="before")
@classmethod
def check_name(cls, v, values):
_id = str(values["id"])
def check_name(cls, v, info: ValidationInfo):
_id = str(info.data["id"])
if not v.endswith(f"/{_id}"):
msg = f"Resource name [{v}] and id [{_id}] do not match"
raise ValueError(msg)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
from faker import Faker
from models_library.projects import Project
from models_library.projects_nodes import InputsDict, InputTypes, SimCoreFileLink
from pydantic import TypeAdapter, create_model
from pydantic import RootModel, TypeAdapter, create_model
from simcore_service_api_server.models.schemas.files import File
from simcore_service_api_server.models.schemas.jobs import ArgumentTypes, Job, JobInputs
from simcore_service_api_server.models.schemas.solvers import Solver
Expand Down Expand Up @@ -100,7 +100,7 @@ def test_job_to_node_inputs_conversion():
got_node_inputs = create_node_inputs_from_job_inputs(inputs=job_inputs)
got_job_inputs = create_job_inputs_from_node_inputs(inputs=node_inputs)

NodeInputs = create_model("NodeInputs", __root__=(dict[str, InputTypes], ...))
NodeInputs = create_model("NodeInputs", __base__=RootModel[dict[str, InputTypes]])
print(NodeInputs.model_validate(got_node_inputs).model_dump_json(indent=2))
print(got_job_inputs.model_dump_json(indent=2))

Expand Down

0 comments on commit 04cd728

Please sign in to comment.