Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Python Import Name #181

Closed
ax3l opened this issue May 18, 2018 · 12 comments
Closed

Python Import Name #181

ax3l opened this issue May 18, 2018 · 12 comments

Comments

@ax3l
Copy link
Member

ax3l commented May 18, 2018

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

@C0nsultant
Copy link
Member

C0nsultant commented May 22, 2018

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

@ax3l
Copy link
Member Author

ax3l commented May 22, 2018

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.

@C0nsultant
Copy link
Member

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.

@ax3l
Copy link
Member Author

ax3l commented May 23, 2018

@RemiLehe what do you think?

@RemiLehe
Copy link
Member

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

@RemiLehe
Copy link
Member

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

@ax3l
Copy link
Member Author

ax3l commented May 23, 2018

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.

@RemiLehe
Copy link
Member

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?

@C0nsultant
Copy link
Member

C0nsultant commented May 24, 2018

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.

@ax3l
Copy link
Member Author

ax3l commented May 24, 2018

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.

@ax3l
Copy link
Member Author

ax3l commented Oct 8, 2018

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!

@ax3l
Copy link
Member Author

ax3l commented Feb 6, 2019

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

Please see the respective linked issues for other repos.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants