Skip to content

Unclear handling of attributes in BP4/BP5 #4471

Description

@jorgensd

The following minimal example using the ADIOS2 Python interface (2.10.2), shows a difference in how variables are handled in the BP4 and BP5 formats.

import adios2.bindings as adios2
from mpi4py import MPI


def read_attr(engine):
    filename = "test_" + engine + ".bp"

    adios = adios2.ADIOS(MPI.COMM_WORLD)


    io = adios.DeclareIO("reader" + engine)
    io.SetEngine(engine)
    file = io.Open(str(filename), adios2.Mode.Read)
    print(engine,  io.AvailableAttributes().keys())
    for step in range(file.Steps()):
        file.BeginStep()
        print(engine, step, io.AvailableAttributes().keys())
        file.EndStep()
    file.Close()
    adios.RemoveIO("reader"+engine)


def write_attr(engine):
    filename = "test_" + engine + ".bp"

    # Write two attributes to file
    adios = adios2.ADIOS(MPI.COMM_WORLD)
    io = adios.DeclareIO("writer" + engine)
    io.SetEngine(engine)
    adios_file = io.Open(str(filename), adios2.Mode.Write, MPI.COMM_WORLD)
    adios_file.BeginStep()
    io.DefineAttribute("a", "first")
    adios_file.PerformPuts()
    adios_file.EndStep()

    adios_file.BeginStep()
    io.DefineAttribute("b", "last")
    adios_file.PerformPuts()
    adios_file.EndStep()

    adios_file.Close()
    adios.RemoveIO("writer"+"engine")

if __name__ == "__main__":
    write_attr("BP4")
    read_attr("BP4")
    write_attr("BP5")
    read_attr("BP5")

This yields:

BP4 dict_keys(['a'])
BP4 0 dict_keys(['a'])
BP5 dict_keys([])
BP5 0 dict_keys(['a'])
BP5 1 dict_keys(['a', 'b'])

Which makes the handling of both formats within Python very hard to maintain.
Is this a change that was made on purpose or a bug?

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions