Add API to install resolver tool dependencies#3222
Add API to install resolver tool dependencies#3222jmchilton merged 7 commits intogalaxyproject:devfrom
Conversation
and to build a tool dependency cache (if activated in galaxy.ini).
An example to install dependencies for the twobit converter:
```
import bioblend.galaxy
url = 'http://localhost:8080/'
api_key = 'admin_api_key'
tool_id = 'CONVERTER_fasta_to_2bit'
endpoint = "api/tools/%s/install_dependencies" % tool_id
gi = bioblend.galaxy.GalaxyInstance(url, api_key)
gi.make_post_request("/".join((url, endpoint)), payload={'id': tool_id})
```
If `use_cached_dependency_manager` is activated in the galaxy.ini,
a cached environment can be built like this:
```
endpoint = "api/tools/%s/build_dependency_cache" % tool_id
gi.make_post_request("/".join((url, endpoint)), payload={'id': tool_id})
```
|
@mvdbeek this is a great idea! Can we include an automatics |
I don't know, I guess I would put this under the resolvers endpoint. In there we could have a general cleanup function, that would map to conda clean, or in the case of docker to docker rm/rmi. Does that make sense? |
|
Mh ... I think we need to clean at the end of bulk-installations and not after every single installation. |
|
Overall, this is a nice PR and needed, so +1 from me. |
|
Then again, I'm just hacking away here, input from people that know something about API design is more than welcome. |
|
|
This will remove a pre-existing cached dependency directory.
|
@bgruening Alright, I've added the |
|
Cool, thanks! |
|
Awesome sauce - thanks a bunch @mvdbeek! |
|
does merging this make #2931 obsolete? |
|
Do these changes need to be reflected in Conda FAQ https://docs.galaxyproject.org/en/master/admin/conda_faq.html ? We need to keep that resource up to date and top notch. |
|
Yes, I'll try to get to this. |
| resolved_dependencies = self.requirements_to_dependencies(requirements, **kwds) | ||
| cacheable_dependencies = [dep for req, dep in resolved_dependencies.items() if dep.cacheable] | ||
| hashed_requirements_dir = self.get_hashed_requirements_path(cacheable_dependencies) | ||
| if kwds.get('force_rebuild', False) and os.path.exists(hashed_requirements_dir): |
There was a problem hiding this comment.
@mvdbeek What happens if an admin installs a tool which has the same set of requirements of a previously installed-and-cached environment (and force_rebuild is False)?
There was a problem hiding this comment.
This is actually a bit inconsistent now (given that initially there was no way to build/rebuild a cache):
If you install a tool with the same set of requirements, you do build the cache again, since this was the only way to fix a broken cache or update a cache with new packages (short of deleting the cache).
But now I think we should expose this in the details section of the tool installation and extend the install repository API endpoint for this parameter. Does that sound like a good idea?
There was a problem hiding this comment.
In fact we should have a UI to manage these things independently of the install process. The pieces are all there, but I don't feel up to the task of building a "Manage tool dependencies" page. That would be a huge win IMO. I have a clear picture in my head how this should look like, but looking through the codebase I don't really see something that I could base my work on like I did for the conda install process.
There was a problem hiding this comment.
If you install a tool with the same set of requirements, you do build the cache again, since this was the only way to fix a broken cache
I think that should be done only when using the new force_rebuild option, and yes, we need an UI for that!
or update a cache with new packages (short of deleting the cache).
Do you mean updating a package that is already in the cached env or adding a new package to it? I don't think the second should happen, because that should have a different hash. And for the first, rebuilding is probably better.
So, I'd change this code to be:
if os.path.exists(hashed_requirements_dir):
if kwds.get('force_rebuild', False):
try:
shutil.rmtree(hashed_requirements_dir)
except Exception:
log.warning("Could not delete cached requirements directory '%s'" % hashed_requirements_dir)
pass
else:
log.debug("Cached environment %s already exists, skipping build", hashed_requirements_dir)
return
[dep.build_cache(hashed_requirements_dir) for dep in cacheable_dependencies]In fact we should have a UI to manage these things independently of the install process. The pieces are all there, but I don't feel up to the task of building a "Manage tool dependencies" page.
I'd love that! Hopefully someone from the core Galaxy Team can help?
There was a problem hiding this comment.
So, I'd change this code to be:
yep, that looks pefect. Do you want to open a PR? Otherwise I can include this with a Documentation update.
and to build a tool dependency cache (if activated in galaxy.ini).
This brings us closer to managing tool dependencies for non-toolshed tools.
In addition this is currently the only way to build a cached environment, except for re-installing a tool.
An example to install dependencies for the twobit converter:
If
use_cached_dependency_manageris activated in the galaxy.ini,a cached environment can be built like this: