Skip to content

Commit a02b5de

Browse files
khsraliagoscinski
authored andcommitted
no source_uuid, pydantic added (aiidateam#6825)
review applied r 2 fixed a typo in function signature fields updated review applied
1 parent 24d1df2 commit a02b5de

File tree

13 files changed

+140
-34
lines changed

13 files changed

+140
-34
lines changed

docs/source/topics/calculations/usage.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -635,7 +635,7 @@ Using the ``COPY`` mode, the target path defines another location (on the same f
635635
In addition to the ``COPY`` mode, the following modes, these storage efficient modes are also are available:
636636
``COMPRESS_TAR``, ``COMPRESS_TARBZ2``, ``COMPRESS_TARGZ``, ``COMPRESS_TARXZ``.
637637
638-
The stashed files and folders are represented by an output node that is attached to the calculation node through the label ``remote_stash``, as a ``RemoteStashFolderData`` node.
638+
The stashed files and folders are represented by an output node that is attached to the calculation node through the label ``remote_stash``, as a ``RemoteStashCopyData`` node.
639639
Just like the ``remote_folder`` node, this represents a location or files on a remote machine and so is equivalent to a "symbolic link".
640640
641641
.. important::

pyproject.toml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -119,7 +119,8 @@ requires-python = '>=3.9'
119119
'core.remote' = 'aiida.orm.nodes.data.remote.base:RemoteData'
120120
'core.remote.stash' = 'aiida.orm.nodes.data.remote.stash.base:RemoteStashData'
121121
'core.remote.stash.compress' = 'aiida.orm.nodes.data.remote.stash.compress:RemoteStashCompressedData'
122-
'core.remote.stash.folder' = 'aiida.orm.nodes.data.remote.stash.folder:RemoteStashFolderData'
122+
'core.remote.stash.copy' = 'aiida.orm.nodes.data.remote.stash.copy:RemoteStashCopyData'
123+
'core.remote.stash.folder' = 'aiida.orm.nodes.data.remote.stash.folder:RemoteStashFolderData' # legacy, to be removed in AiiDA 3.0
123124
'core.singlefile' = 'aiida.orm.nodes.data.singlefile:SinglefileData'
124125
'core.str' = 'aiida.orm.nodes.data.str:Str'
125126
'core.structure' = 'aiida.orm.nodes.data.structure:StructureData'

src/aiida/engine/daemon/execmanager.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -437,7 +437,7 @@ async def stash_calculation(calculation: CalcJobNode, transport: Transport) -> N
437437
:param transport: an already opened transport.
438438
"""
439439
from aiida.common.datastructures import StashMode
440-
from aiida.orm import RemoteStashCompressedData, RemoteStashFolderData
440+
from aiida.orm import RemoteStashCompressedData, RemoteStashCopyData
441441

442442
logger_extra = get_dblogger_extra(calculation)
443443

@@ -488,10 +488,10 @@ async def stash_calculation(calculation: CalcJobNode, transport: Transport) -> N
488488
else:
489489
EXEC_LOGGER.debug(f'stashed {source_filepath} to {target_filepath}')
490490

491-
remote_stash = RemoteStashFolderData(
491+
remote_stash = RemoteStashCopyData(
492492
computer=calculation.computer,
493-
target_basepath=str(target_basepath),
494493
stash_mode=StashMode(stash_mode),
494+
target_basepath=str(target_basepath),
495495
source_list=source_list,
496496
).store()
497497

@@ -512,8 +512,8 @@ async def stash_calculation(calculation: CalcJobNode, transport: Transport) -> N
512512

513513
remote_stash = RemoteStashCompressedData(
514514
computer=calculation.computer,
515-
target_basepath=target_destination,
516515
stash_mode=StashMode(stash_mode),
516+
target_basepath=target_destination,
517517
source_list=source_list,
518518
dereference=dereference,
519519
)

src/aiida/orm/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -89,8 +89,8 @@
8989
'QueryBuilder',
9090
'RemoteData',
9191
'RemoteStashCompressedData',
92+
'RemoteStashCopyData',
9293
'RemoteStashData',
93-
'RemoteStashFolderData',
9494
'SinglefileData',
9595
'Site',
9696
'Str',

src/aiida/orm/nodes/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,8 +51,8 @@
5151
'ProjectionData',
5252
'RemoteData',
5353
'RemoteStashCompressedData',
54+
'RemoteStashCopyData',
5455
'RemoteStashData',
55-
'RemoteStashFolderData',
5656
'SinglefileData',
5757
'Site',
5858
'Str',

src/aiida/orm/nodes/data/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -59,8 +59,8 @@
5959
'ProjectionData',
6060
'RemoteData',
6161
'RemoteStashCompressedData',
62+
'RemoteStashCopyData',
6263
'RemoteStashData',
63-
'RemoteStashFolderData',
6464
'SinglefileData',
6565
'Site',
6666
'Str',

src/aiida/orm/nodes/data/remote/__init__.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,8 @@
1010
__all__ = (
1111
'RemoteData',
1212
'RemoteStashCompressedData',
13-
'RemoteStashData',
14-
'RemoteStashFolderData'
13+
'RemoteStashCopyData',
14+
'RemoteStashData'
1515
)
1616

1717
# fmt: on

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

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,12 +6,12 @@
66

77
from .base import *
88
from .compress import *
9-
from .folder import *
9+
from .copy import *
1010

1111
__all__ = (
1212
'RemoteStashCompressedData',
13-
'RemoteStashData',
14-
'RemoteStashFolderData'
13+
'RemoteStashCopyData',
14+
'RemoteStashData'
1515
)
1616

1717
# fmt: on

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

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ def __init__(
3939
self,
4040
stash_mode: StashMode,
4141
target_basepath: str,
42-
source_list: List,
42+
source_list: List[str],
4343
dereference: bool,
4444
**kwargs,
4545
):
@@ -48,6 +48,7 @@ def __init__(
4848
:param stash_mode: the stashing mode with which the data was stashed on the remote.
4949
:param target_basepath: absolute path to place the compressed file (path+filename).
5050
:param source_list: the list of source files.
51+
:param dereference: whether to dereference symbolic links when compressing.
5152
"""
5253
super().__init__(stash_mode, **kwargs)
5354
self.target_basepath = target_basepath
Lines changed: 83 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,83 @@
1+
###########################################################################
2+
# Copyright (c), The AiiDA team. All rights reserved. #
3+
# This file is part of the AiiDA code. #
4+
# #
5+
# The code is hosted on GitHub at https://github.com/aiidateam/aiida-core #
6+
# For further information on the license, see the LICENSE.txt file #
7+
# For further information please visit http://www.aiida.net #
8+
###########################################################################
9+
"""Data plugin that models a stashed folder on a remote computer."""
10+
11+
from typing import List, Tuple, Union
12+
13+
from aiida.common.datastructures import StashMode
14+
from aiida.common.lang import type_check
15+
from aiida.common.pydantic import MetadataField
16+
17+
from .base import RemoteStashData
18+
19+
__all__ = ('RemoteStashCopyData',)
20+
21+
22+
class RemoteStashCopyData(RemoteStashData):
23+
"""Data plugin that models a folder with files of a completed calculation job that has been stashed through a copy.
24+
25+
This data plugin can and should be used to stash files if and only if the stash mode is `StashMode.COPY`.
26+
"""
27+
28+
_storable = True
29+
30+
class Model(RemoteStashData.Model):
31+
target_basepath: str = MetadataField(description='The the target basepath')
32+
source_list: List[str] = MetadataField(description='The list of source files that were stashed')
33+
34+
def __init__(self, stash_mode: StashMode, target_basepath: str, source_list: List[str], **kwargs):
35+
"""Construct a new instance
36+
37+
:param stash_mode: the stashing mode with which the data was stashed on the remote.
38+
:param target_basepath: the target basepath.
39+
:param source_list: the list of source files.
40+
"""
41+
super().__init__(stash_mode, **kwargs)
42+
self.target_basepath = target_basepath
43+
self.source_list = source_list
44+
45+
# Although this subclass supports only the `StashMode.COPY` mode,
46+
# the design aligns with the `RemoteStashData` LSP for consistency.
47+
# For stashing with compressed options, consider using `RemoteStashCompressedData`.
48+
if stash_mode != StashMode.COPY:
49+
raise ValueError('`RemoteStashCopyData` can only be used with `stash_mode == StashMode.COPY`.')
50+
51+
@property
52+
def target_basepath(self) -> str:
53+
"""Return the target basepath.
54+
55+
:return: the target basepath.
56+
"""
57+
return self.base.attributes.get('target_basepath')
58+
59+
@target_basepath.setter
60+
def target_basepath(self, value: str):
61+
"""Set the target basepath.
62+
63+
:param value: the target basepath.
64+
"""
65+
type_check(value, str)
66+
self.base.attributes.set('target_basepath', value)
67+
68+
@property
69+
def source_list(self) -> Union[List, Tuple]:
70+
"""Return the list of source files that were stashed.
71+
72+
:return: the list of source files.
73+
"""
74+
return self.base.attributes.get('source_list')
75+
76+
@source_list.setter
77+
def source_list(self, value: Union[List, Tuple]):
78+
"""Set the list of source files that were stashed.
79+
80+
:param value: the list of source files.
81+
"""
82+
type_check(value, (list, tuple))
83+
self.base.attributes.set('source_list', value)

0 commit comments

Comments
 (0)