Openpmd-api: Python Import Name

Created on 18 May 2018  路  12Comments  路  Source: openPMD/openPMD-api

We current do

import openPMD

but for consistency with other python libs we have so far we probably need to name it

import openpmd_api

or

import openpmd.api

or similar.

cc @RemiLehe @C0nsultant

Python3 install question

All 12 comments

Disclaimer - the current python naming scheme does not appeal greatly to me. This suggestion would certainly make this lib consistent with the other openPMD python libs, but it runs contrary to the largely accepted PEP naming convention.

I propose something more radical, conceptually different:
Instead of following the append_scheme, why not split into openpmd.subpackages?
This way, the individual parts of the ecosystem are logically connected:

import openpmd.api
import openpmd.viewer

Disclaimer - the currently python naming scheme does not appeal greatly to me.

you have my +1.

We could for convenience even provide a repo with a lightweight openpmd meta-package that depends on all others.

We could for convenience even provide a repo with a lightweight openpmd meta-package that depends on all others.

This meta-package will be nice for convenience, but it is not required. You can combine multiple distinct python sub-packages, each providing a openpmd.foo to the overall openpmd without having all of them or the meta-package.

@RemiLehe what do you think?

Yes, I like the naming openpmd.api and openpmd.viewer.

However, I am not sure how this will be implemented in practice. For instance, with the meta-package that @ax3l suggested, is the idea that openpmd_viewer and openpmd_api would still be available as pip packages (a separate Github repositories), so that the setup.py of this meta-package would list openpmd_viewer and openpmd_api as dependencies?
(I guess in this case, the meta-package would have the following openpmd/__init__.py:

import openpmd_viewer as viewer
import openpmd_api as api

Or is the plan to have a whole new package and a single Github repository for both the viewer and the API?

The idea is too keep them separated as before and just change their provided imports accordingly.

On top of that, we could make a simple wrapper-only repo and meta-package that depends on all of them. But that's not necessary for the subpackages to get this structure, as @C0nsultant pointed out.

Oh, ok I see. Sorry that I had not properly read @C0nsultant's comment/
And then the pip install command would just be

pip install openpmd.viewer
pip install openpmd.api

Is that correct?

I had admittedly never thought about the pypi project name up to this point. But yes, the pip install could look just like @RemiLehe assumed. Dots are explicitly allowed in package and project names.

The meta-package @ax3l suggested would install like

pip install openpmd

and would allow for

import openpmd.api
import openpmd.viewer
...

without explicitly installing individual packages.

Anyway, PyPI (or conda) package names is then the second step. This issue is first just about import names (module names) :)

(openPMD-api is also interesting on PyPI and easier on conda. For PyPI OSX binary wheels and a source wheel for linux are probably possible...)

E.g., the package name for conda will probably have an underscore. Also, we might be shipping openpmd_api_cpp and openpmd_api or so. Afaik, the same applies to PyPI package names.

Following proposal: as mentioned above, we can keep for module names the _ and create a openpmd.XYZ meta-module (and meta-package) later on.

# need updates
import openpmd_api as api              # done in 0.7.0+
import openpmd_validator as validator
import openpmd_viewer as viewer        # upcoming in 1.0.0+

But the package names should be consistently and PEP8 recommended (and conda compatible) called with a -:

# all good! https://pypi.org/search/?q=openPMD
pip install openpmd-api
pip install openpmd-validator
pip install openpmd-viewer
# all good!
spack install openpmd-api
# spack install openpmd-validator  # optional, not created yet
# spack install openpmd-viewer     # optional, not created yet
# need updates: https://anaconda.org/search?q=openPMD
conda install -c conda-forge openpmd-api  # done in 0.7.0+
conda install -c ax3l openpmd-validator   # to do!
conda install -c rlehe openpmd-viewer     # to do!

Import and package names for openPMD-api are consistent with the 0.7.0+ release.

Please see the respective linked issues for other repos.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

PrometheusPi picture PrometheusPi  路  3Comments

lucafedeli88 picture lucafedeli88  路  3Comments

ax3l picture ax3l  路  3Comments

KseniaBastrakova picture KseniaBastrakova  路  4Comments

franzpoeschel picture franzpoeschel  路  3Comments