Skip to content

Commit 2fd4b89

Browse files
Update/add models for RemoteData and RemoteStashCompressedData (#6844)
pydantic models merged with PR #6255 and commit 958bfd0 missed two classes. This commit Update/add models for `RemoteData` and `RemoteStashCompressedData`
1 parent 5807a39 commit 2fd4b89

File tree

3 files changed

+29
-19
lines changed

3 files changed

+29
-19
lines changed

src/aiida/orm/nodes/data/remote/stash/compress.py

Lines changed: 11 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212

1313
from aiida.common.datastructures import StashMode
1414
from aiida.common.lang import type_check
15-
from aiida.orm.fields import add_field
15+
from aiida.common.pydantic import MetadataField
1616

1717
from .base import RemoteStashData
1818

@@ -24,23 +24,16 @@ class RemoteStashCompressedData(RemoteStashData):
2424

2525
_storable = True
2626

27-
__qb_fields__ = [
28-
add_field(
29-
'target_basepath',
30-
dtype=str,
31-
doc='The the target basepath',
32-
),
33-
add_field(
34-
'source_list',
35-
dtype=List[str],
36-
doc='The list of source files that were stashed',
37-
),
38-
add_field(
39-
'dereference',
40-
dtype=bool,
41-
doc='The format of the compression used when stashed',
42-
),
43-
]
27+
class Model(RemoteStashData.Model):
28+
target_basepath: str = MetadataField(
29+
description='The the target basepath',
30+
)
31+
source_list: List[str] = MetadataField(
32+
description='The list of source files that were stashed',
33+
)
34+
dereference: bool = MetadataField(
35+
description='The format of the compression used when stashed',
36+
)
4437

4538
def __init__(
4639
self,

tests/orm/models/test_models.py

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
import pytest
99
from pydantic import BaseModel
1010

11+
from aiida.common.datastructures import StashMode
1112
from aiida.orm import AuthInfo, Comment, Computer, Group, Log, User
1213
from aiida.orm.nodes.data import (
1314
ArrayData,
@@ -22,6 +23,8 @@
2223
JsonableData,
2324
List,
2425
RemoteData,
26+
RemoteStashCompressedData,
27+
RemoteStashData,
2528
SinglefileData,
2629
Str,
2730
StructureData,
@@ -50,6 +53,8 @@
5053
Str,
5154
StructureData,
5255
RemoteData,
56+
RemoteStashData,
57+
RemoteStashCompressedData,
5358
)
5459

5560

@@ -137,7 +142,16 @@ def required_arguments(request, default_user, aiida_localhost, tmp_path):
137142
if request.param is StructureData:
138143
return StructureData, {'cell': [[1, 0, 0], [0, 1, 0], [0, 0, 1]]}
139144
if request.param is RemoteData:
140-
return RemoteData, {'remote_path': '/some/path', 'computer': aiida_localhost}
145+
return RemoteData, {'remote_path': '/some/path'}
146+
if request.param is RemoteStashData:
147+
return RemoteStashData, {'stash_mode': StashMode.COMPRESS_TAR}
148+
if request.param is RemoteStashCompressedData:
149+
return RemoteStashCompressedData, {
150+
'stash_mode': StashMode.COMPRESS_TAR,
151+
'target_basepath': '/some/path',
152+
'source_list': ['/some/file'],
153+
'dereference': True,
154+
}
141155

142156
raise NotImplementedError()
143157

tests/orm/test_fields/fields_aiida.data.core.remote.stash.compress.RemoteStashCompressedData.yml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ attributes: QbDictField('attributes', dtype=typing.Optional[typing.Dict[str, typ
22
is_attribute=False, is_subscriptable=True)
33
computer: QbNumericField('computer', dtype=typing.Optional[int], is_attribute=False)
44
ctime: QbNumericField('ctime', dtype=typing.Optional[datetime.datetime], is_attribute=False)
5+
dereference: QbField('dereference', dtype=<class 'bool'>, is_attribute=True)
56
description: QbStrField('description', dtype=typing.Optional[str], is_attribute=False)
67
extras: QbDictField('extras', dtype=typing.Optional[typing.Dict[str, typing.Any]],
78
is_attribute=False, is_subscriptable=True)
@@ -15,6 +16,8 @@ repository_content: QbDictField('repository_content', dtype=typing.Optional[dict
1516
repository_metadata: QbDictField('repository_metadata', dtype=typing.Optional[typing.Dict[str,
1617
typing.Any]], is_attribute=False)
1718
source: QbDictField('source', dtype=typing.Optional[dict], is_attribute=True, is_subscriptable=True)
19+
source_list: QbArrayField('source_list', dtype=typing.List[str], is_attribute=True)
1820
stash_mode: QbField('stash_mode', dtype=<enum 'StashMode'>, is_attribute=True)
21+
target_basepath: QbStrField('target_basepath', dtype=<class 'str'>, is_attribute=True)
1922
user: QbNumericField('user', dtype=typing.Optional[int], is_attribute=False)
2023
uuid: QbStrField('uuid', dtype=typing.Optional[str], is_attribute=False)

0 commit comments

Comments
 (0)