-
Notifications
You must be signed in to change notification settings - Fork 232
Update node serialization/deserialization and other Pydantic issues #6990
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from all commits
1ca7bb7
5035601
f042534
fbeb32f
02fed45
4713222
646ce4d
acb6aec
511ac53
adc9c19
79b1363
b6d0898
bd728a7
71bfac0
98bafad
950813b
7af6acf
94e1726
e253132
b735511
281cfa5
08ef433
a036678
c7b9aeb
3be2297
f703612
d5e0002
09c3615
289228b
086f14a
26e4e91
3435796
f8e724c
67073e4
2ae4717
36da6f6
1b5a634
fb47977
cec3766
aa2ab44
899ec5a
ad356fb
7c4c7b6
5d1563a
23397ff
88aa0cd
dfd2203
60d4654
a82c6b7
afabd93
e17a9a0
36b4d59
9bb780c
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -167,8 +167,8 @@ class CalcInfo(DefaultFieldsAttributeDict): | |
| max_wallclock_seconds: None | int | ||
| max_memory_kb: None | int | ||
| rerunnable: bool | ||
| retrieve_list: None | list[str | tuple[str, str, str]] | ||
| retrieve_temporary_list: None | list[str | tuple[str, str, str]] | ||
| retrieve_list: None | list[str | tuple[str, str, int]] | ||
| retrieve_temporary_list: None | list[str | tuple[str, str, int]] | ||
|
Comment on lines
+170
to
+171
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The last argument of the tuple is the depth, which "can be used to control what level of nesting of the source folder hierarchy should be maintained". It is an integer. |
||
| local_copy_list: None | list[tuple[str, str, str]] | ||
| remote_copy_list: None | list[tuple[str, str, str]] | ||
| remote_symlink_list: None | list[tuple[str, str, str]] | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -3,7 +3,6 @@ | |
| from __future__ import annotations | ||
|
|
||
| import typing as t | ||
| from pathlib import Path | ||
|
|
||
| from pydantic import Field | ||
| from pydantic_core import PydanticUndefined | ||
|
|
@@ -35,10 +34,9 @@ def MetadataField( # noqa: N802 | |
| short_name: str | None = None, | ||
| option_cls: t.Any | None = None, | ||
| orm_class: type[Entity[t.Any, t.Any]] | str | None = None, | ||
| orm_to_model: t.Callable[[Entity[t.Any, t.Any], Path], t.Any] | None = None, | ||
| model_to_orm: t.Callable[['BaseModel'], t.Any] | None = None, | ||
| orm_to_model: t.Callable[[Entity[t.Any, t.Any], dict[str, t.Any]], t.Any] | None = None, | ||
| model_to_orm: t.Callable[[BaseModel], t.Any] | None = None, | ||
| exclude_to_orm: bool = False, | ||
| exclude_from_cli: bool = False, | ||
| is_attribute: bool = True, | ||
| is_subscriptable: bool = False, | ||
| **kwargs: t.Any, | ||
|
|
@@ -66,7 +64,7 @@ class Model(BaseModel): | |
| :param short_name: Optional short name to use for an option on a command line interface. | ||
| :param option_cls: The :class:`click.Option` class to use to construct the option. | ||
| :param orm_class: The class, or entry point name thereof, to which the field should be converted. If this field is | ||
| defined, the value of this field should acccept an integer which will automatically be converted to an instance | ||
| defined, the value of this field should accept an integer which will automatically be converted to an instance | ||
| of said ORM class using ``orm_class.collection.get(id={field_value})``. This is useful, for example, where a | ||
| field represents an instance of a different entity, such as an instance of ``User``. The serialized data would | ||
| store the ``pk`` of the user, but the ORM entity instance would receive the actual ``User`` instance with that | ||
|
|
@@ -75,10 +73,8 @@ class Model(BaseModel): | |
| :param model_to_orm: Optional callable to convert the value of a field from a model instance to an ORM instance. | ||
| :param exclude_to_orm: When set to ``True``, this field value will not be passed to the ORM entity constructor | ||
| through ``Entity.from_model``. | ||
| :param exclude_from_cli: When set to ``True``, this field value will not be exposed on the CLI command that is | ||
| dynamically generated to create a new instance. | ||
| :param is_attribute: Whether the field is stored as an attribute. | ||
| :param is_subscriptable: Whether the field can be indexed like a list or dictionary. | ||
| :param is_attribute: Whether the field is stored as an attribute. Used by `QbFields`. | ||
| :param is_subscriptable: Whether the field can be indexed like a list or dictionary. Used by `QbFields`. | ||
| """ | ||
| field_info = Field(default, **kwargs) | ||
|
|
||
|
|
@@ -90,11 +86,15 @@ class Model(BaseModel): | |
| ('orm_to_model', orm_to_model), | ||
| ('model_to_orm', model_to_orm), | ||
| ('exclude_to_orm', exclude_to_orm), | ||
| ('exclude_from_cli', exclude_from_cli), | ||
| ('is_attribute', is_attribute), | ||
| ('is_subscriptable', is_subscriptable), | ||
| ): | ||
| if value is not None: | ||
| field_info.metadata.append({key: value}) | ||
|
|
||
| if exclude_to_orm: | ||
| extra = getattr(field_info, 'json_schema_extra', None) or {} | ||
| extra.update({'readOnly': True}) | ||
| field_info.json_schema_extra = extra | ||
|
Comment on lines
+95
to
+98
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Marking |
||
|
|
||
| return field_info | ||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I prefer here we explicitly hardcode 'filepath_files', as it is the intended exclusion here.
is_attributeis used for other purposes, not for marking exclusion from the CLIshowcommand. Reminding @GeigerJ2 to open an issue (optionally reply here with a link to the issue).Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, I agree, better to do it like this! I just created #7099 as a sub-issue of #7050, thanks for the reminder!