-
Notifications
You must be signed in to change notification settings - Fork 1.1k
Install via conda #2554
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
Merged
Merged
Install via conda #2554
Changes from 52 commits
Commits
Show all changes
58 commits
Select commit
Hold shift + click to select a range
fd9eb82
WIP re #39 - run dependency management during repository installation
bwlang dcb57a6
Need to unnpack kwargs (ping @bwlang)
mvdbeek de6bbf1
Move get_unique_requirements to shed_util_common
mvdbeek 179d02c
Iterate over all tools in a repository
mvdbeek f7d5f5d
Fix the parsing logic
mvdbeek 07ed963
Be a bit more defensive about parsing requirements
mvdbeek f0f6d88
Fix indentation
mvdbeek e7aaf99
passed a “manual install” argument to the dependency resolve
bwlang 523baf3
Probably better not to have a fake directory here…
bwlang 0252acc
ask for tool dependency installation always.
bwlang dade96c
this view is not necessary for the current implementation
bwlang 609898b
strangely… we need
bwlang c59fd5e
resolving style issue
bwlang 7535879
Add api route to fetch all requirements
mvdbeek 1a9e2e7
Continue dependency resolver API routes and start work on displaying…
mvdbeek 672480f
Add first pass for displaying dependency status info
bwlang a806867
Add name and version to returned dependency
mvdbeek 2a7f67b
Hack in name and version into dictified representation of Dependency …
mvdbeek 4bd0013
add status field with icons
bwlang ee33ad8
whitespace fix
bwlang e7f8a13
Address @nsoranzo's review.
mvdbeek cc085cb
Work on conda install revision
mvdbeek 69480a6
Fix dependency typo
mvdbeek 7a8265b
Make api return more detailed requirements status, move tool_requirem…
mvdbeek 983f4a0
Use list comprehension to generate list of all requirements
mvdbeek 2e7099c
Fix logic error in message
mvdbeek 93579a6
Display whether dependency is exactly resolved (check), inexactly res…
mvdbeek 602ced8
Close docstring example list
mvdbeek f75a28e
Trigger requirement install for new install method
mvdbeek 414bc87
flake8 fixes
mvdbeek 4eadf05
Add API endpoint to install (resolver) dependencies
mvdbeek 503915f
Correct module description
mvdbeek db05313
Trigger dependency installation in InstallRepositoryManager
mvdbeek dcba018
Add docstring to install_dependency
mvdbeek a8670a2
Revert manual_install mode (unncessary, better to use install_depende…
mvdbeek 6901cb1
Introduce installable_resolver property
mvdbeek 33b83e5
Add install resolver dependency button
mvdbeek 4ed151a
Revert mako hack to always display install_tool_dependency button
mvdbeek 886d074
Make conda verbose install check configurable
mvdbeek 2018632
Only return requirements of type package (for now)
mvdbeek 0b24283
Use resolver.find_dep to determine dependency status
mvdbeek b59b797
Update INDETERMINATE_DEPENDENCY use to NullDependency instance
mvdbeek c10d1cb
Remove unused DependencyResolver view from ToolBox
mvdbeek 49dee6a
Flake8 fix
mvdbeek 6b135c6
Drop INDETERMINATE_DEPENDENCY alias
mvdbeek dd8f8f1
Fix NullDependency use
mvdbeek b5fad4a
Add api test for conda dependency resolution
mvdbeek deef480
Add more API tests for resolver dependencies
mvdbeek e53a81c
Fix syntax, return None if dependency not found
mvdbeek 9917512
Revert svgwrite import, fixed in #2656
mvdbeek 645a891
Remove reference to /tmp
mvdbeek 06e409a
Use continue instead of unused NullDependency
mvdbeek 2a5b043
Simplify conda install logic
mvdbeek 8cca7be
Show conda install option even when no tool_dependencies.xml is avail…
jmchilton 483b66b
Address @nsoranzo's review
mvdbeek 924a913
Mark conda install beta and move after TS options.
jmchilton 88fac71
Merge remote-tracking branch 'bxlab/install_via_conda' into install_v…
jmchilton 12209ab
Merge pull request #56 from jmchilton/install_via_conda
martenson File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -6,11 +6,9 @@ | |
|
||
import os | ||
|
||
from galaxy.exceptions import NotImplemented | ||
|
||
from ..resolvers import ( | ||
DependencyResolver, | ||
INDETERMINATE_DEPENDENCY, | ||
NullDependency, | ||
Dependency, | ||
ListableDependencyResolver, | ||
InstallableDependencyResolver, | ||
|
@@ -65,6 +63,7 @@ def get_option(name): | |
|
||
conda_exec = get_option("exec") | ||
debug = _string_as_bool(get_option("debug")) | ||
verbose_install_check = _string_as_bool(get_option("verbose_install_check")) | ||
ensure_channels = get_option("ensure_channels") | ||
use_path_exec = get_option("use_path_exec") | ||
if use_path_exec is None: | ||
|
@@ -89,53 +88,57 @@ def get_option(name): | |
auto_install = _string_as_bool(get_option("auto_install")) | ||
copy_dependencies = _string_as_bool(get_option("copy_dependencies")) | ||
|
||
if auto_init and not os.path.exists(conda_context.conda_prefix): | ||
if install_conda(conda_context): | ||
raise Exception("Conda installation requested and failed.") | ||
if not os.path.exists(conda_context.conda_prefix): | ||
if auto_init: | ||
if install_conda(conda_context): | ||
self.disabled = True | ||
log.warning("Conda installation requested and failed.") | ||
else: | ||
self.disabled = True | ||
log.warning("Conda not installed and auto-installation disabled.") | ||
|
||
self.conda_context = conda_context | ||
self.auto_install = auto_install | ||
self.copy_dependencies = copy_dependencies | ||
self.verbose_install_check = verbose_install_check | ||
|
||
def resolve(self, name, version, type, **kwds): | ||
# Check for conda just not being there, this way we can enable | ||
# conda by default and just do nothing in not configured. | ||
if not os.path.isdir(self.conda_context.conda_prefix): | ||
return INDETERMINATE_DEPENDENCY | ||
return NullDependency(version=version, name=name) | ||
|
||
if type != "package": | ||
return INDETERMINATE_DEPENDENCY | ||
|
||
job_directory = kwds.get("job_directory", None) | ||
if job_directory is None: | ||
log.warning("Conda dependency resolver not sent job directory.") | ||
return INDETERMINATE_DEPENDENCY | ||
return NullDependency(version=version, name=name) | ||
|
||
exact = not self.versionless or version is None | ||
if self.versionless: | ||
version = None | ||
|
||
conda_target = CondaTarget(name, version=version) | ||
is_installed = is_conda_target_installed( | ||
conda_target, conda_context=self.conda_context | ||
conda_target, conda_context=self.conda_context, verbose_install_check=self.verbose_install_check | ||
) | ||
if not is_installed and self.auto_install: | ||
return_code = install_conda_target(conda_target, conda_context=self.conda_context) | ||
if return_code != 0: | ||
is_installed = False | ||
log.debug('Cleaning up after failed install of {}, {}'.format(name, version)) | ||
cleanup_failed_install(conda_target, conda_context=self.conda_context) | ||
else: | ||
# Recheck if installed | ||
is_installed = is_conda_target_installed( | ||
conda_target, conda_context=self.conda_context | ||
|
||
job_directory = kwds.get("job_directory", None) | ||
if job_directory is None: # Job directory is None when resolve() called by find_dep() | ||
if is_installed: | ||
return CondaDependency( | ||
False, | ||
os.path.join(self.conda_context.envs_path, conda_target.install_environment), | ||
exact, | ||
name=name, | ||
version=version | ||
) | ||
if not is_installed: | ||
log.debug('Cleaning up after failing to verify installed environment for {}, {}'.format(name, version)) | ||
cleanup_failed_install(conda_target, conda_context=self.conda_context) | ||
else: | ||
log.warning("Conda dependency resolver not sent job directory.") | ||
return NullDependency(version=version, name=name) | ||
|
||
if not is_installed and self.auto_install: | ||
is_installed = self.install_dependency(name, version, type) | ||
|
||
if not is_installed: | ||
return INDETERMINATE_DEPENDENCY | ||
return NullDependency(version=version, name=name) | ||
|
||
# Have installed conda_target and job_directory to send it too. | ||
# If dependency is for metadata generation, store environment in conda-metadata-env | ||
|
@@ -150,8 +153,9 @@ def resolve(self, name, version, type, **kwds): | |
copy=self.copy_dependencies, | ||
conda_context=self.conda_context, | ||
) | ||
|
||
if not exit_code: | ||
return CondaDepenency( | ||
return CondaDependency( | ||
self.conda_context.activate, | ||
conda_environment, | ||
exact, | ||
|
@@ -166,34 +170,67 @@ def list_dependencies(self): | |
yield self._to_requirement(name, version) | ||
|
||
def install_dependency(self, name, version, type, **kwds): | ||
"Returns True on (seemingly) successfull installation" | ||
if type != "package": | ||
raise NotImplemented("Can only install dependencies of type '%s'" % type) | ||
log.warning("Cannot install dependencies of type '%s'" % type) | ||
return False | ||
|
||
if self.versionless: | ||
version = None | ||
|
||
conda_target = CondaTarget(name, version=version) | ||
|
||
if install_conda_target(conda_target, conda_context=self.conda_context): | ||
raise Exception("Failed to install conda recipe.") | ||
is_installed = is_conda_target_installed( | ||
conda_target, conda_context=self.conda_context, verbose_install_check=self.verbose_install_check | ||
) | ||
|
||
if is_installed: | ||
return is_installed | ||
|
||
return_code = install_conda_target(conda_target, conda_context=self.conda_context) | ||
if return_code != 0: | ||
is_installed = False | ||
log.debug("Remove failed conda install of {}, version '{}'".format(name, version)) | ||
cleanup_failed_install(conda_target, conda_context=self.conda_context) | ||
else: | ||
# Recheck if installed | ||
is_installed = is_conda_target_installed( | ||
conda_target, conda_context=self.conda_context, verbose_install_check=self.verbose_install_check | ||
) | ||
if not is_installed: | ||
log.debug("Remove failed conda install of {}, version '{}'".format(name, version)) | ||
cleanup_failed_install(conda_target, conda_context=self.conda_context) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
|
||
|
||
return is_installed | ||
|
||
@property | ||
def prefix(self): | ||
return self.conda_context.conda_prefix | ||
|
||
|
||
class CondaDepenency(Dependency): | ||
dict_collection_visible_keys = Dependency.dict_collection_visible_keys + ['environment_path'] | ||
class CondaDependency(Dependency): | ||
dict_collection_visible_keys = Dependency.dict_collection_visible_keys + ['environment_path', 'name', 'version'] | ||
dependency_type = 'conda' | ||
|
||
def __init__(self, activate, environment_path, exact): | ||
def __init__(self, activate, environment_path, exact, name=None, version=None): | ||
self.activate = activate | ||
self.environment_path = environment_path | ||
self._exact = exact | ||
self._name = name | ||
self._version = version | ||
|
||
@property | ||
def exact(self): | ||
return self._exact | ||
|
||
@property | ||
def name(self): | ||
return self._name | ||
|
||
@property | ||
def version(self): | ||
return self._version | ||
|
||
def shell_commands(self, requirement): | ||
return """[ "$CONDA_DEFAULT_ENV" = "%s" ] || . %s '%s' 2>&1 """ % ( | ||
self.environment_path, | ||
|
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
name=name, version=version, type=type