Skip to content

Commit

Permalink
Update doc: One extra example about storing files (#18)
Browse files Browse the repository at this point in the history
  • Loading branch information
addman2 committed Nov 4, 2023
1 parent 0f99625 commit d86d8fe
Show file tree
Hide file tree
Showing 2 changed files with 36 additions and 1 deletion.
2 changes: 1 addition & 1 deletion docs/source/index.rst
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ Usage of the AiiDA-Python plugin is straightforward. To get started, you need to

It's important to note that the AiiDA-Python plugin is currently in the early stages of development. However, it is actively maintained and continuously improved to provide a reliable and efficient solution for executing Python code on remote computers.

To learn more about using the AiiDA-Python plugin and its capabilities, please refer to the ``usage.rst`` file in this documentation.
To learn more about using the AiiDA-Python plugin and its capabilities, please refer to the :ref:`usage.rst` file in this documentation.

.. note::

Expand Down
35 changes: 35 additions & 0 deletions docs/source/usage.rst
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,41 @@ And therefore the smallest eigenvalue of the original matrix.
self.outputs.value = np.average((H @ vec) / vec)
File Storing
------------

Very often one wants to use SinglefileData file and directly store the file in the working directory of the code. In ``aiida-python`` there is an easy shortcut to do it with doc strings:

.. code-block:: python
class ClassThatCannotStartWithTestCopyFile(CalcJobPython):
@classmethod
def define(cls, spec):
super().define(spec)
spec.input('repeats', valid_type=Int)
spec.input('inputfile', valid_type=SinglefileData)
spec.output('value', valid_type=Float)
spec.output('output', valid_type=SinglefileData)
def run_python(self):
"""
This is commentary
This file will be stored in the working directory:
!file inputfile: data
Unset ports will be ignored:
!file inputfile2: data2
Store output
!!file output: output
"""
# Code comes here
More Examples
-------------

Expand Down

0 comments on commit d86d8fe

Please sign in to comment.