-
Notifications
You must be signed in to change notification settings - Fork 8
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
Installation documentation and issues #5
Comments
To support these suggestions, here are some references about how to properly package python software: |
@rabernat Thanks for the comments. I ran into some difficulties addressing these issues. I tried to upload to PyPI, but it seems that
So it won't work as a dependency. Then I tried building a conda package, but failed again. Previously I managed to This is my
The
Both The
I think I've added all dependencies in both the setup.py and |
For building a conda package, the only way to go is to use conda forge: https://conda-forge.org/#add_recipe
Basemap is no longer maintained. Cartopy has replaced it. But more generally, why does your package need to depend on a mapping tool at all? Or any other visualization package? Of course one needs visualization to plot the results, but that's not the same thing as a dependency. |
I think I've managed to get a PR merged to conda-forge, and I just tested that it is installable using |
@Xunius these changes are a great step towards making IPART much easier to install. 👍 Looking at your meta.yaml for conda-forge, it looks like no tests run as part of making the conda-forge build. Recipes should include at least some tests (see, for example, this part of the conda forge documentation). Your tests take about 9 seconds to run, so I would recommend having them all run. One other minor comment:
|
@kbarnhart So if I understood you correctly, the suggested change is to add something like the following to the
If so, is the README change still required? |
@Xunius, based on my understanding of IPART and conda-forge, what you've described above would be the appropriate change. With the test commands you then ensure that the packages built by conda-forge pass the tests before they are distributed. I would still recommend making the README change because a user who installed with conda-forge would not be able to run |
adding tests to meta.yml See ihesp/IPART#5 (comment)
@kbarnhart After a bit of trial-n-error, I added unittest to the meta.yml recipe and merged the PR. Also edited README in this commit |
@Xunius thanks for making that change to the conda-forge recipe. As this is @rabernat 's issue and is a bit more substantial than #6 I'm going to let him chime in on whether he thinks the issues he has raised have been addressed. I want to follow up with some guidance from JOSS regarding dependencies, and in particular deprecated dependencies. It appears that basemap is a listed dependency because it is used to make some built in result plots. I consider whether or not these sort of functions are in or out of the package as a point of developer preference and will not express an editorial opinion on it here. However, as @rabernat points out, basemap was deprecated (quite a while ago) and replaced with cartopy. I consulted with the rest of the JOSS editorial board regarding this case: Unless you can make a strong case that the deprecated dependency cannot be replaced by the new package or it would be a substantial burden to replace it, then you must replace it as part of the review. The JOSS :_ formal peer review process that is designed to improve the quality of the software submitted_. https://joss.theoj.org/about Basemap is used relatively infrequently in ipart, and thus I do not think it is an undue burden to have you replace its use with cartopy. |
@kbarnhart @rabernat I've made the transition from basemap to cartopy in these commits: New conda-recipe is updated here A side note regarding the cartopy replacement, I feel that we are pushing the deprecation too hard, last time I checked out cartopy it didn't support the latitude/longitude labeling in projections other than PlateCarree and Mercator, this functionality is added in the recent 0.18.0 release in May. It took me a good while to figure out how to plot the data across the dateline, and you can see some relevant issues still open. And basemap is perfectly installable inside conda. Anyway, please let me know whether this issue has been addressed. |
Hi @Xunius -- sorry for my long silence. Thanks for all the work you've put into this. It's great that the package is now conda installable! I don't have strong feelings about basemap vs. cartopy, other than pointing out that basemap is deprecated. Relying on basemap will make it harder to maintain your package in the future. But my most relevant comment was:
It don't think this question has been addressed. I don't fundamentally understand why you need cartopy / matplotlib as a dependency. This is not a visualization package, is it? I see you have some utility routines (e.g. Regarding the original issue here, installation instructions, I see you have made some updates. However, your recommended installation is still:
Considering these recommendations differ from 99% of existing python packages, I would like to understand the justification for them. Why is iHESP so special that it requires its own dedicated environment + installation from github? Why can't the installation instructions just simply be?
Wouldn't that be simpler and easier for your users? |
@rabernat Thanks for coming back. I used basemap previously for plotting, but also for some computations as well. I used its coordinates transformation function to compute some polygon areas measured in km^2. But that relevant functionality was turned off in a later change. So it is now solely for plotting. Matplotlib's contour function is also used to obtain the contour coordinates, without actually plotting them out. That's why I have to import matplotlib in the test scripts, and change the backend to 'Agg' immediately. My understanding is that since JOSS requires the authors to provide some notebooks to help the users to get to know the software, plotting modules are therefore required dependencies. Similarly for the "advised" installation method, I feel that it's encouraged to let the user get the git repository, so that they can obtain the notebooks. Besides, the |
I'll chime in quickly with some JOSS-specific guidance: JOSS does not require notebooks, specifically. However, we do require that there is sufficient narrative documentation such that a user can learn to use the software, and API documentation. Often for python packages, Jupyter Notebooks are one of the easiest ways to provide narrative documentation and examples. However, this is beside the point of whether matplotlib and cartopy are appropriate as dependencies. |
@kbarnhart So it is ok to remove cartopy as a dependency but leave the notebooks there? Just put a sentence somewhere in the notebook to tell the user to install cartopy themselves? |
@Xunius That is not how I would interpret my comment. My comment was meant to point out that jupyter notebooks are not an explicit requirement of JOSS. However, having narrative documentation and examples are a requirement (and these are commonly created as jupyter notebooks). One approach that I have seen to communicate install instructions when there are packages needed to run examples but not needed for the package itself is as follows:
A nice byproduct of this approach is that one of the "examples" conda environment can be used to specify Binder. It supports a pretty clean set of install instructions, namely:
@rabernat may have comments on this approach. However, it appears to me that there are still some comments made by @rabernat above to address. Specifically (and I paraphrase): |
This is a really nice summary @kbarnhart. I think this is a technical issue, related to what it means to create a package vs. documentation / examples of that package. Let me use my experience as an xarray developer to help clarify. DependenciesRequired DependenciesRequired dependencies should be the bare minimum of other packages required by your package in order to run its core functionality. Xarray's dependencies, as specified in its setup.cfg, are just
https://github.com/pydata/xarray/blob/2acd0fc6563c3ad57f16e6ee804d592969419938/setup.cfg#L76-L82 These must be installed for xarray to run, and if you try to install xarray with pip or conda, these dependencies will automatically be installed as well. Setuptools handles that for you. So you should ask yourself: what are the bare minimum requirements to run iHESP's core functionality? Optional DependenciesOptional dependencies are extra packages which, if installed, enable extra optional features in your package. For xarray, matlplotlib in an optional dependency. It is not required, but some functions use it (like all of the plotting functions). If you try to use these functions without matplotlib installed, you just get an error when xarray tries to EnvironmentsAn environment is not the same as the dependencies. An environment is a self-contained python installation. Most packages define several different environments for different purposes, but users should not be required or expected to use these exact environments. Most users already have existing environments that they know and like, and they don't want to create a new environment just for your package. Test environmentsIn xarray, we define 8 different environments for testing: Documentation / Demo EnvironmentsXarray's documentation has it's own environment: Finally, we have a binder environment, designed to let users try xarray in the cloud without installing anything: This is a lot to digest. If this is your first time putting together a python package, it may be overwhelming. My point is that looking at the best practices established by mature, widely-used python packages can be a very useful guide. |
@kbarnhart @rabernat Thanks for all these information. Now I understand your point better. So I have tried to make cartopy an optional dependency and make it installable via the environment file approach, in these commits:
and the updated conda recipe. Regarding matplotlib, I'm still using it to compute contour coordinates, so it's not only for plotting, therefore a required dependency. |
Makes sense. 👍 None of these links works for me, so it's hard for me to directly validate your claims / approve your changes. |
@rabernat My bad. I copied the wrong string. Please check the updated links below: |
@Xunius with one small exception I think these changes look good. Of course, I'll let @rabernat chime in and indicate what he thinks. My only recommendation would be to put the cartopy import in ipart\utils\plot.py in a try except block with an informative error message telling a user that they've tried to use a part of ipart which relies on the optional dependency. For example: try:
import cartopy
except ImportError:
raise ImportError("Your message here") |
I second @kbarnhart's suggestion above. But I think enough has been done here that we can close this. |
This issue is in reference to my JOSS review of your paper (openjournals/joss-reviews#2407).
I am trying to understand the recommended installation procedure for this package.
On one hand, you seem to provide a pip package with dependencies:
IPART/setup.py
Lines 14 to 22 in 6bbf452
On the other hand, your installation instructions don't mention pip and instead recommend manually creating a new conda environment from scratch. The instructions are mostly about how to create conda environments. This does not adhere to best practices for distributing python code. For example, what if you want to use this package in an existing environment? Do you have to create a new environment?
A better solution would be to provide working pip and / or conda-forge packages which automatically check for and, if needed, install the required dependencies on installation. This would allow the user to simply run
pip install ipart
orconda install -c conda-forge ipart
. Could you provide a pip or conda-forge package for this software?A related issue is whether the user is required to clone the master repository in order to use the software. I notice that there are various scripts and notebooks that are part of the repo but not the package itself. Are these required or optional. Again, this is not a standard practice for scientific python software. I recommend that users only be required to interact with the git repository if they wish to contribute to IPART development. Otherwise a pip / conda install should be sufficient to use the software.
Making these changes would also help resolve #2.
The text was updated successfully, but these errors were encountered: