openPMD / openPMD/openPMD-api

RecordComponent Constant After Store

Open
#476 1 comment 0 reactions 0 assignees View on GitHub
backend backend: HDF5 frontend: C++17 frontend: Python3
Dominant language
C++
Stars
161
Forks
59
Avg merge
2d 22h
Merged PRs (30d)
7

Description

**Describe the bug**
Setting (accidentally) `storeChunk` and then `makeConstant` on the same `RecordComponent` before a flush does not throw a user-friendly error (nor is it gracefully handled).

Instead, a backend-error is thrown on `flush`, which even leads to an unhandled crash in case of HDF5.

**To Reproduce**

Python:
```python
import openpmd_api

# ...
```
or C++
```C++
#include

// example: data handling
#include // std::iota
#include // std::vector

namespace api = openPMD;

int main()
{

auto series = api::Series(
"myOutput/data_%05T.bp",
api::AccessType::CREATE);

auto i = series.iterations[42];

std::vector x_data(
150 * 300);
std::iota(
x_data.begin(),
x_data.end(),
0.);

float x2_data = 4.f;

// record
auto B = i.meshes["B"];

// record components
auto B_x = B["x"];

auto dataset = api::Dataset(
api::determineDatatype(),
{150, 300});
B_x.resetDataset(dataset);

B_x.storeChunk(
api::shareRaw(x_data),
{0, 0}, {150, 300});

B_x.makeConstant(y_data);

series.flush();

return 0;
}
```

JSON:
```
terminate called after throwing an instance of 'std::runtime_error'
what(): Specified dataset does not exist or is not a dataset.
Aborted
```

HDF5: (not even catched by IO backend)
```
HDF5-DIAG: Error detected in HDF5 (1.10.0-patch1) thread 0:
#000: ../../../src/H5D.c line 296 in H5Dopen2(): unable to open dataset
major: Dataset
minor: Can't open object
#001: ../../../src/H5Dint.c line 1470 in H5D__open_name(): not a dataset
major: Dataset
minor: Inappropriate type
terminate called after throwing an instance of 'std::runtime_error'
what(): Internal error: Failed to open HDF5 dataset during dataset write
Aborted
```

**Expected behavior**
A clear and concise description of what you expected to happen.

**Software Environment:**
- version of openPMD-api: 0.8.0-dev
- installed openPMD-api via: from source
- operating system: Linux Debian
- machine: local laptop
- name and version of Python implementation: CPython 3.6.7
- version of HDF5: 1.10.0-patch1
- version of ADIOS1: none
- name and version of MPI: OpenMPI 2.0.2

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.