empress icon indicating copy to clipboard operation
empress copied to clipboard

Should qiime2 dependencies for empress be explicitly documented?

Open gwarmstrong opened this issue 3 years ago • 2 comments

A little bit of a weird edge case, but I was working in an environment with only a partial install of Qiime2 (I often do this in cases where I am reading from QZA's but do not need to use any actions from qiime plugins).

When I pip installed empress, I got the following error

>>> import qiime2
>>> pm = qiime2.sdk.PluginManager()
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/Users/garmstro/miniconda3/envs/test-microsetta-public/lib/python3.6/site-packages/qiime2/sdk/plugin_manager.py", line 54, in __new__
    self._init(add_plugins=add_plugins)
  File "/Users/garmstro/miniconda3/envs/test-microsetta-public/lib/python3.6/site-packages/qiime2/sdk/plugin_manager.py", line 81, in _init
    plugin = entry_point.load()
  File "/Users/garmstro/miniconda3/envs/test-microsetta-public/lib/python3.6/site-packages/pkg_resources/__init__.py", line 2450, in load
    return self.resolve()
  File "/Users/garmstro/miniconda3/envs/test-microsetta-public/lib/python3.6/site-packages/pkg_resources/__init__.py", line 2456, in resolve
    module = __import__(self.module_name, fromlist=['__name__'], level=0)
  File "/Users/garmstro/miniconda3/envs/test-microsetta-public/lib/python3.6/site-packages/empress/plugin_setup.py", line 9, in <module>
    from ._plot import community_plot, tree_plot
  File "/Users/garmstro/miniconda3/envs/test-microsetta-public/lib/python3.6/site-packages/empress/_plot.py", line 18, in <module>
    from empress._plot_utils import get_bp, save_viz
  File "/Users/garmstro/miniconda3/envs/test-microsetta-public/lib/python3.6/site-packages/empress/_plot_utils.py", line 13, in <module>
    import q2templates
ModuleNotFoundError: No module named 'q2templates'

Which is happening because I had the qiime2 package installed, but not q2templates.

Is there any way to resolve this via the pip install?

gwarmstrong avatar Dec 17 '20 00:12 gwarmstrong

This is a really interesting question -- I can def relate to having broken various Q2 installs in this kinda way. Haven't thought about documenting this kind of thing, though.

Is there any way to resolve this via the pip install?

It doesn't look like q2templates is on PyPI, so I don't think so. I guess we could directly require q2templates by trying to pip install it from its GitHub URL, sorta like how we were requiring Emperor up untill recently, but then we run into the same problems we ran into when doing that with Emperor (having direct URLs in setup.py breaks Empress' PyPI installation, IIRC).

The most straightforward way to address this I can think of is just installing q2templates (or the other missing Q2 packages) from the dedicated conda channel(s) (e.g. q2templates conda page).

Should qiime2 dependencies for empress be explicitly documented?

Making a list of all the QIIME 2 dependencies that Empress needs right now would totally be doable, but (I think?) the main challenge might be in ensuring this list is kept up-to-date. Most Q2 plugins I've seen (...may be a biased subset) sort of make the hand-wavy assumption that all of the stuff in a QIIME 2 conda environment will be available (everything from q2-types to q2templates), and I'm not sure that trying to go against this will be easy or worth it.

For reference, here are all of the QIIME 2 Python dependencies I can find in Empress' code from some quick searching (may be more):

$ egrep -ri "(q2)|(qiime)" empress/* tests/* | grep import
empress/_plot.py:import qiime2
empress/_plot.py:from q2_types.tree import NewickFormat
empress/_plot_utils.py:import q2templates
empress/plugin_setup.py:from qiime2.plugin import (
empress/plugin_setup.py:from q2_types.tree import Phylogeny, Rooted
empress/plugin_setup.py:from q2_types.feature_table import (
empress/plugin_setup.py:from q2_types.ordination import PCoAResults
tests/python/test_cli.py:from qiime2 import Artifact
tests/python/make-dev-page.py:import qiime2 as q2
tests/python/make-dev-page.py:from q2_types.tree import NewickFormat
tests/python/test_integration.py:from qiime2 import Artifact, Metadata
tests/python/test_integration.py:from qiime2.sdk import Results, Visualization
tests/python/test_integration.py:from qiime2.plugin.testing import TestPluginBase

Making a list of these will be easy (I guess this comment kind of serves that purpose???), but updating it every time we need to rely on a new Q2 internal thing might be hard :(

fedarko avatar Dec 17 '20 09:12 fedarko

thanks @fedarko ! Makes sense. So something to keep in mind if we ever get a conda install going, but not really resolvable via pip?

but updating it every time we need to rely on a new Q2 internal thing might be hard :(

I do not see a reason why this is any more complex than updating dependencies when you require new packages in general? So long as the core qiime2 packages maintain their own dependencies.

gwarmstrong avatar Dec 17 '20 20:12 gwarmstrong