Skip to content

Commit 779a81a

Browse files
Update streaming documentation to snapshots API (#1773)
1 parent 82a1f7b commit 779a81a

1 file changed

Lines changed: 14 additions & 28 deletions

File tree

docs/source/usage/streaming.rst

Lines changed: 14 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -3,15 +3,13 @@
33
Streaming
44
=========
55

6-
.. note::
7-
Data streaming is a novel backend and under active development.
8-
At the moment, the internal data format is still changing rapidly and is likely not compatible between releases of the openPMD-api.
9-
106
The openPMD API includes a streaming-aware API as well as streaming-enabled backends (currently: ADIOS2).
117

128
Unlike in file-based backends, the order in which data is put out becomes relevant in streaming-based backends.
139
Each iteration will be published as one atomical step by the streaming API (compare the concept of `steps in ADIOS2 <https://adios2.readthedocs.io/en/latest/components/components.html#engine>`_).
1410

11+
In order to process Iterations synchronously, and one after another, the openPMD-api has *linear* access modes twinned with each regular, i.e. *random-access* mode (except ``READ_WRITE``, which only supports random-access).
12+
1513
Reading
1614
-------
1715

@@ -21,37 +19,29 @@ It can be used to read any kind of openPMD-compatible dataset, stream-based and
2119
C++
2220
^^^
2321

24-
The reading end of the streaming API is activated through use of ``Series::readIterations()`` instead of accessing the field ``Series::iterations`` directly.
25-
Use of ``Access::READ_LINEAR`` mode is recommended.
26-
The returned object of type ``ReadIterations`` can be used in a C++11 range-based for loop to iterate over objects of type ``IndexedIteration``.
27-
This class extends the ``Iteration`` class with a field ``IndexedIteration::iterationIndex``, denoting this iteration's index.
22+
The reading end of the streaming API is activated through use of ``Access::READ_LINEAR`` instead of ``Access::READ_RANDOM_ACCESS`` (or ``Access::READ_ONLY``). Iterations must be accessed with ``Series::snapshots()`` instead of directly using the field ``Series::iterations``.
2823

29-
Iterations are implicitly opened by the Streaming API and ``Iteration::open()`` needs not be called explicitly.
24+
In ``READ_LINEAR`` mode, Iterations are implicitly opened and ``Iteration::open()`` needs not be called explicitly.
3025
Users are encouraged to explicitly ``.close()`` the iteration after reading from it.
3126
Closing the iteration will flush all pending operations on that iteration.
3227
If an iteration is not closed until the beginning of the next iteration, it will be closed automatically.
3328

34-
Note that a closed iteration cannot be reopened.
35-
This pays tribute to the fact that in streaming mode, an iteration may be dropped by the data source once the data sink has finished reading from it.
29+
Note that a closed iteration can in general not be reopened. Limited support for reopening closed Iterations in ``READ_LINEAR`` is available under the condition that the Series is neither a stream nor that it uses ADIOS2 steps. In a stream, Iterations may be dropped by the writer once the reader has finished reading from it.
3630

3731
.. literalinclude:: 10_streaming_read.cpp
3832
:language: cpp
3933

4034
Python
4135
^^^^^^
4236

43-
The reading end of the streaming API is activated through use of ``Series.read_iterations()`` instead of accessing the field ``Series.iterations`` directly.
44-
Use of ``Access.read_linear`` mode is recommended.
45-
The returned object of type ``ReadIterations`` can be used in a Python range-based for loop to iterate over objects of type ``IndexedIteration``.
46-
This class extends the ``Iteration`` class with a field ``IndexedIteration.iteration_index``, denoting this iteration's index.
37+
The reading end of the streaming API is activated through use of ``Access.read_linear`` instead of ``Access.read_random_access`` (or ``Access.read_only``). Iterations must be accessed with ``Series.snapshots()`` instead of directly using the field ``Series.iterations``.
4738

48-
Iterations are implicitly opened by the Streaming API and ``Iteration.open()`` needs not be called explicitly.
39+
In ``read_linear`` mode, Iterations are implicitly opened and ``Iteration.open()`` needs not be called explicitly.
4940
Users are encouraged to explicitly ``.close()`` the iteration after reading from it.
5041
Closing the iteration will flush all pending operations on that iteration.
5142
If an iteration is not closed until the beginning of the next iteration, it will be closed automatically.
5243

53-
Note that a closed iteration cannot be reopened.
54-
This pays tribute to the fact that in streaming mode, an iteration may be dropped by the data source once the data sink has finished reading from it.
44+
Note that a closed iteration can in general not be reopened. Limited support for reopening closed Iterations in ``read_linear`` is available under the condition that the Series is neither a stream nor that it uses ADIOS2 steps. In a stream, Iterations may be dropped by the writer once the reader has finished reading from it.
5545

5646
.. literalinclude:: 10_streaming_read.py
5747
:language: python3
@@ -65,33 +55,29 @@ It can be used to write any kind of openPMD-compatible dataset, stream-based and
6555
C++
6656
^^^
6757

68-
The writing end of the streaming API is activated through use of ``Series::writeIterations()`` instead of accessing the field ``Series::iterations`` directly.
69-
The returned object of type ``WriteIterations`` wraps the field ``Series::iterations``, but exposes only a restricted subset of functionality.
70-
Using ``WriteIterations::operator[]( uint64_t )`` will automatically open a streaming step for the corresponding iteration.
58+
The writing end of the streaming API is activated through use of ``Access::CREATE_LINEAR`` instead of ``ACCESS::CREATE_RANDOM_ACCESS`` (or ``Access::CREATE``). Iterations must be accessed with ``Series::snapshots()`` instead of using the field ``Series::iterations`` directly.
59+
With linear create mode, ``Snapshots::operator[](uint64_t)`` will automatically open a streaming step for each new corresponding iteration.
7160

7261
Users are encouraged to explicitly ``.close()`` the iteration after writing to it.
7362
Closing the iteration will flush all pending operations on that iteration.
7463
If an iteration is not closed until the next iteration is accessed via ``WriteIterations::operator[]( uint64_t )``, it will be closed automatically.
7564

76-
Note that a closed iteration cannot be reopened.
77-
This pays tribute to the fact that in streaming mode, an iteration is sent to the sink upon closing it and the data source can no longer modify it.
65+
Note that a closed iteration can in general not be reopened. Limited support for reopening closed Iterations in ``CREATE_LINEAR`` is available for non-streaming backends other than ADIOS2 (and in ADIOS2, if using file-based encoding with engine BP5 and engine option ``FlattenSteps=ON``). In a stream, Iterations may not be modified after they have been sent to readers.
7866

7967
.. literalinclude:: 10_streaming_write.cpp
8068
:language: cpp
8169

8270
Python
8371
^^^^^^
8472

85-
The writing end of the streaming API is activated through use of ``Series.write_iterations()`` instead of accessing the field ``Series.iterations`` directly.
86-
The returned object of type ``WriteIterations`` wraps the field ``Series.iterations``, but exposes only a restricted subset of functionality.
87-
Using ``WriteIterations.__getitem__(index)`` (i.e. the index operator ``series.writeIterations()[index]``) will automatically open a streaming step for the corresponding iteration.
73+
The writing end of the streaming API is activated through use of ``Access.create_linear`` instead of ``ACCESS.create_random_access`` (or ``Access.create``). Iterations must be accessed with ``Series.snapshots()`` instead of using the field ``Series.iterations`` directly.
74+
With linear create mode, ``Snapshots.__getitem__(index)`` will automatically open a streaming step for each new corresponding iteration.
8875

8976
Users are encouraged to explicitly ``.close()`` the iteration after writing to it.
9077
Closing the iteration will flush all pending operations on that iteration.
9178
If an iteration is not closed until the next iteration is accessed via ``WriteIterations.__getitem__(index)``, it will be closed automatically.
9279

93-
Note that a closed iteration cannot be reopened.
94-
This pays tribute to the fact that in streaming mode, an iteration is sent to the sink upon closing it and the data source can no longer modify it.
80+
Note that a closed iteration can in general not be reopened. Limited support for reopening closed Iterations in ``create_linear`` is available for non-streaming backends other than ADIOS2 (and in ADIOS2, if using file-based encoding with engine BP5 and engine option ``FlattenSteps=ON``). In a stream, Iterations may not be modified after they have been sent to readers.
9581

9682
.. literalinclude:: 10_streaming_write.py
9783
:language: python3

0 commit comments

Comments
 (0)