diff --git a/docs/python/readwrite.rst b/docs/python/readwrite.rst index 402e0be9d9f4c6ee7a7645ad1fff4e55ca3eb511..2f4e5afe3e44e1f27e118532e14739afa52155ae 100644 --- a/docs/python/readwrite.rst +++ b/docs/python/readwrite.rst @@ -111,4 +111,16 @@ References .. autofunction:: read_phys_origin -.. autofunction:: write_genericio \ No newline at end of file +.. autofunction:: write_genericio + +.. autoclass:: FileIO + :noindex: + +.. autoclass:: MismatchBehavior + :noindex: + +.. autofunction:: setDefaultShouldCompress + +.. autofunction:: setNaturalDefaultPartition + +.. autofunction:: setCollectiveMPIIOThreshold \ No newline at end of file diff --git a/python/genericio.cpp b/python/genericio.cpp index 089951b3030966e489ebbe87cd12827706e8b939..53df6f5502cec0c448fe6eb2b86e38315c10fc57 100644 --- a/python/genericio.cpp +++ b/python/genericio.cpp @@ -338,6 +338,7 @@ PYBIND11_MODULE(pygio, m) { py::class_<PyGenericIO> pyGenericIO(m, "PyGenericIO"); + // ENUMS py::enum_<PyGenericIO::FileIO>(pyGenericIO, "FileIO") .value("FileIOMPI", PyGenericIO::FileIO::FileIOMPI) .value("FileIOPOSIX", PyGenericIO::FileIO::FileIOPOSIX) @@ -369,8 +370,12 @@ PYBIND11_MODULE(pygio, m) { .def("read_variable_names", &PyGenericIO::read_variable_names) .def("read_variable_dtypes", &PyGenericIO::read_variable_dtypes) .def("get_source_ranks", &PyGenericIO::getSourceRanks) + .def_static("setDefaultShouldCompress", &PyGenericIO::setDefaultShouldCompress) + .def_static("setNaturalDefaultPartition", &PyGenericIO::setNaturalDefaultPartition) + .def_static("setDefaultFileIOType", &PyGenericIO::setDefaultFileIOType) #ifndef GENERICIO_NO_MPI .def("rebalance_source_ranks", &PyGenericIO::rebalanceSourceRanks) + .def_static("setCollectiveMPIIOThreshold", &PyGenericIO::setCollectiveMPIIOThreshold) #endif ; diff --git a/python/pygio/__init__.py b/python/pygio/__init__.py index 17ea2496000907a2e0df98cf6f9f13f8129b320b..ce4f4fbd7658223b197b333cd2b928aa52e0d4a9 100644 --- a/python/pygio/__init__.py +++ b/python/pygio/__init__.py @@ -2,19 +2,39 @@ from __future__ import print_function import os _GENERICIO_NO_MPI = False -if 'GENERICIO_NO_MPI' in os.environ: - _GENERICIO_NO_MPI = os.environ['GENERICIO_NO_MPI'].lower() in ['true', 'yes', 'y'] +if "GENERICIO_NO_MPI" in os.environ: + _GENERICIO_NO_MPI = os.environ["GENERICIO_NO_MPI"].lower() in ["true", "yes", "y"] if _GENERICIO_NO_MPI: - print("WARNING: the pygio module without MPI support has been loaded (due to the GENERICIO_NO_MPI env variable). Writing GenericIO files not supported.") + print( + "WARNING: the pygio module without MPI support has been loaded (due to the GENERICIO_NO_MPI env variable). Writing GenericIO files not supported." + ) from .pygio_nompi import * else: # try to load the MPI library (or the no-mpi library, in case of missing MPI during compilation) from . import pygio as _pygio + try: _pygio._init_mpi() except: - print("WARNING: The pygio module has been compiled without MPI support. Writing GenericIO files not supported.") + print( + "WARNING: The pygio module has been compiled without MPI support. Writing GenericIO files not supported." + ) + _GENERICIO_NO_MPI = True + from .pygio import * + + +# move some ENUMs and static functions up to the module namespace +FileIO = PyGenericIO.FileIO +MismatchBehavior = PyGenericIO.MismatchBehavior +setDefaultShouldCompress = PyGenericIO.setDefaultShouldCompress +setNaturalDefaultPartition = PyGenericIO.setNaturalDefaultPartition +setDefaultFileIOType = PyGenericIO.setDefaultFileIOType +if not _GENERICIO_NO_MPI: + setCollectiveMPIIOThreshold = PyGenericIO.setCollectiveMPIIOThreshold - from .pygio import * \ No newline at end of file +# sensible defaults? +if not _GENERICIO_NO_MPI: + setNaturalDefaultPartition() + setDefaultFileIOType(FileIO.FileIOMPICollective)