|
18 | 18 |
|
19 | 19 | import pathlib |
20 | 20 |
|
21 | | -from pydantic import field_serializer, field_validator |
| 21 | +from pydantic import field_serializer |
22 | 22 |
|
23 | 23 | from aiida.common import exceptions |
24 | 24 | from aiida.common.lang import type_check |
@@ -60,28 +60,30 @@ class Model(AbstractCode.Model): |
60 | 60 | priority=1, |
61 | 61 | ) |
62 | 62 |
|
63 | | - @field_validator('label') |
64 | | - @classmethod |
65 | | - def validate_label_uniqueness(cls, value: str) -> str: |
66 | | - """Override the validator for the ``label`` of the base class since uniqueness is defined on full label.""" |
67 | | - return value |
| 63 | + # @field_validator('label') |
| 64 | + # @classmethod |
| 65 | + # def validate_label_uniqueness(cls, value: str) -> str: |
| 66 | + # """Override the validator for the ``label`` of the base class since uniqueness is defined on full label. |
| 67 | + # """ |
| 68 | + # return value |
68 | 69 |
|
69 | | - @field_validator('computer') |
70 | | - @classmethod |
71 | | - def validate_computer(cls, value: str) -> Computer: |
72 | | - """Override the validator for the ``label`` of the base class since uniqueness is defined on full label.""" |
73 | | - from aiida.orm import load_computer |
| 70 | + # @field_validator('computer') |
| 71 | + # @classmethod |
| 72 | + # def validate_computer(cls, value: str) -> Computer: |
| 73 | + # """Override the validator for the ``label`` of the base class since uniqueness is defined on full label. |
| 74 | + # """ |
| 75 | + # from aiida.orm import load_computer |
74 | 76 |
|
75 | | - try: |
76 | | - return load_computer(value) |
77 | | - except exceptions.NotExistent as exception: |
78 | | - raise ValueError(exception) from exception |
| 77 | + # try: |
| 78 | + # return load_computer(value) |
| 79 | + # except exceptions.NotExistent as exception: |
| 80 | + # raise ValueError(exception) from exception |
79 | 81 |
|
80 | 82 | @field_serializer('computer') |
81 | 83 | def serialize_computer(self, computer: Computer, _info): |
82 | 84 | return computer.label |
83 | 85 |
|
84 | | - # TODO the following fails serialization - rethink |
| 86 | + # TODO the following fails serialization - see https://github.com/aiidateam/aiida-core/issues/6821 |
85 | 87 | # @model_validator(mode='after') # type: ignore[misc] |
86 | 88 | # def validate_full_label_uniqueness(self) -> AbstractCode.Model: |
87 | 89 | # """Validate that the full label does not already exist.""" |
|
0 commit comments