GPlates/gplately

PTT: pkg_resources is deprecated as an API

Closed this issue · 9 comments

@jcannon-gplates @brmather

See the code below. The pkg_resources is deprecated as an API.

Do we still need this install_documentation() function?

The PTT examples are not in gplately repository. Should we copy them into the ptt folder?

If the PTT is already a part of gplately, should we archive the PTT repository https://github.com/EarthByte/PlateTectonicTools?

import pkg_resources as _pkg_resources
from distutils import dir_util as _dir_util
import os
def install_documentation(path="./PlateTectonicTools-Examples"):
"""
Install the examples for PlateTectonicTools in the given location.
WARNING: If the path exists, the files will be written into the path
and will overwrite any existing files with which they collide. The default
path ("./PlateTectonicTools-Examples") is chosen to make collision less likely/problematic
The documentation for PlateTectonicTools is in the form of jupyter notebooks.
"""
Notebooks_Path = _pkg_resources.resource_filename("ptt", os.path.join("Examples"))
ct = _dir_util.copy_tree(Notebooks_Path, path, preserve_mode=1, preserve_times=1, preserve_symlinks=1, update=0, verbose=1, dry_run=0)
return

The PTT examples are not in gplately repository. Should we copy them into the ptt folder?

I guess we might as well. Looks like they're all notebooks, so could just simply copy to them to a new ptt sub-directory of gplately/Notebooks/Example/ (which could just contain the PTT 'data' and 'notebooks' directories)?

Do we still need this install_documentation() function?

I'm guessing not, since you don't install the gplately examples, AFAIK, so ptt probably doesn't need it either.

However, if we do keep it then I guess could replace pkg_resources with importlib.resources (added in Python 3.7).

If the PTT is already a part of gplately, should we archive the PTT repository?

Yes definitely, I should've done that before actually.

Someone recently brought that to my attention, and I decided I should first do one final PTT release (when pyGPlates is released, soon) just to bring PTT up-to-date with what it was when it got copied into GPlately. Currently the latest PTT, which is 0.4.1, is a fair bit behind that - mostly the continent contouring - and so conda and pip versions of PTT are missing that. There are some workflows (like optAPM) that require the latest dev version of PTT (ie, don't work with PTT 0.4.1). I suppose it's not really necessary - could just switch them to use GPlately instead - but might be easier to just do one final PTT release.

We can discuss in-person at the next meeting.

The PTT examples are not in gplately repository. Should we copy them into the ptt folder?

I guess we might as well. Looks like they're all notebooks, so could just simply copy to them to a new ptt sub-directory of gplately/Notebooks/Example/ (which could just contain the PTT 'data' and 'notebooks' directories)?

Do we still need this install_documentation() function?

I'm guessing not, since you don't install the gplately examples, AFAIK, so ptt probably doesn't need it either.

However, if we do keep it then I guess could replace pkg_resources with importlib.resources (added in Python 3.7).

If the PTT is already a part of gplately, should we archive the PTT repository?

Yes definitely, I should've done that before actually.

Someone recently brought that to my attention, and I decided I should first do one final PTT release (when pyGPlates is released, soon) just to bring PTT up-to-date with what it was when it got copied into GPlately. Currently the latest PTT, which is 0.4.1, is a fair bit behind that - mostly the continent contouring - and so conda and pip versions of PTT are missing that. There are some workflows (like optAPM) that require the latest dev version of PTT (ie, don't work with PTT 0.4.1). I suppose it's not really necessary - could just switch them to use GPlately instead - but might be easier to just do one final PTT release.

We can discuss in-person at the next meeting.

Currently the gplately notebooks are excluded from the package. The reason is that the notebooks and associated data files are large. And users may have trouble in finding them. For example, in my computer, they are at ~/micromamba/envs/gplately/lib/python3.11/site-packages/gplately/notebooks. I can find them, but I guess other people might find it easier to just download them from somewhere.

I think we should create a topic in github Discussion to decide if the notebooks should be included and where to put them.

By the way, my memory failed me again. Could you remind me what was the reason to put PTT inside GPlately?

Now I see that install_documentation() was designed to copy notebooks from ~/micromamba/envs/gplately/lib/python3.11/site-packages/ptt/notebooks to a user specified folder.

Can we just grab the notebooks and data from Internet, instead of installing them in users' site-packages folder by default?

actionable tasks:

  1. I will copy PTT examples to gplately/Notebooks/Example/ptt
  2. John will do a final PTT release and archive PTT repository
  3. discuss and decide how to deliver examples, notebooks and data files #202

task 1 is done in 4237ca0

pending on task 2 and 3

task 1 is done in 4237ca0

Thanks for that. I've made comments on task 3 in your discussion #202

Per discuss #202, I think we should delete https://github.com/GPlates/gplately/blob/master/gplately/ptt/documentation.py.

@GPlates/gplately-dev
I will delete https://github.com/GPlates/gplately/blob/master/gplately/ptt/documentation.py in 7 days if there is no objection.

task 1 is done in 4237ca0

task 2 will be tracked in EarthByte/PlateTectonicTools#8

task 3 will be tracked in #202

close this issue once #221 is approved and merged