Skip to content

Commit 4595953

Browse files
committed
Various improvements and bug fixes for Conda.
Fixes #616.
1 parent f08375a commit 4595953

File tree

5 files changed

+71
-39
lines changed

5 files changed

+71
-39
lines changed

HISTORY.rst

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,13 @@ History
99
0.37.0.dev0
1010
---------------------
1111

12-
12+
* Update to the latest `galaxy-lib`_ release. This means new installs start with
13+
Miniconda 3 instaed of Minicoda 2 and at a newer version. This fixes many
14+
Conda_ related bugs.
15+
* Change defaults so that Conda auto initializes and aut install tools by default
16+
from within Galaxy. The trio of flags ``--conda_dependency_resolution``,
17+
``--conda_auto_install``, and ``--conda_auto_init`` are effectively the new
18+
defaults.
1319

1420
---------------------
1521
0.36.1 (2016-12-12)

planemo/galaxy/config.py

Lines changed: 57 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -93,6 +93,16 @@
9393
"""
9494

9595

96+
# Like Conda resolution above, but allow tool shed packages to be used for
97+
# shed_serve and shed_test.
98+
DEFAULT_DEPENDENCY_RESOLUTION_CONF = """<dependency_resolvers>
99+
<tool_shed_packages />
100+
<conda ${attributes} />
101+
<conda versionless="true" ${attributes} />
102+
</dependency_resolvers>
103+
"""
104+
105+
96106
BREW_DEPENDENCY_RESOLUTION_CONF = """<dependency_resolvers>
97107
<homebrew />
98108
<!--
@@ -143,6 +153,7 @@
143153
"brew_dependency_resolution": BREW_DEPENDENCY_RESOLUTION_CONF,
144154
"shed_dependency_resolution": SHED_DEPENDENCY_RESOLUTION_CONF,
145155
"conda_dependency_resolution": CONDA_DEPENDENCY_RESOLUTION_CONF,
156+
"default_dependency_resolution": DEFAULT_DEPENDENCY_RESOLUTION_CONF,
146157
}
147158

148159
EMPTY_TOOL_CONF_TEMPLATE = """<toolbox></toolbox>"""
@@ -1145,29 +1156,16 @@ def _handle_job_config_file(config_directory, server_name, kwds):
11451156

11461157

11471158
def _handle_dependency_resolution(ctx, config_directory, kwds):
1148-
resolutions_strategies = [
1149-
"brew_dependency_resolution",
1150-
"dependency_resolvers_config_file",
1151-
"shed_dependency_resolution",
1152-
"conda_dependency_resolution",
1153-
]
1154-
1155-
selected_strategies = 0
1156-
for key in resolutions_strategies:
1157-
if kwds.get(key):
1158-
selected_strategies += 1
1159-
1160-
if selected_strategies > 1:
1161-
message = "At most one option from [%s] may be specified"
1162-
raise click.UsageError(message % resolutions_strategies)
1159+
_validate_dependency_resolution_options(kwds)
1160+
always_specify_attribute = object()
11631161

11641162
dependency_attribute_kwds = {
11651163
'conda_prefix': None,
11661164
'conda_exec': None,
11671165
'conda_debug': False,
11681166
'conda_copy_dependencies': False,
1169-
'conda_auto_init': False,
1170-
'conda_auto_install': False,
1167+
'conda_auto_init': always_specify_attribute,
1168+
'conda_auto_install': always_specify_attribute,
11711169
'conda_ensure_channels': '',
11721170
}
11731171
attributes = []
@@ -1191,23 +1189,49 @@ def add_attribute(key, value):
11911189

11921190
attribute_str = " ".join(attributes)
11931191

1194-
for key in STOCK_DEPENDENCY_RESOLUTION_STRATEGIES:
1192+
if kwds.get("dependency_resolvers_config_file", None):
1193+
resolution_type = "__explicit__"
1194+
else:
1195+
resolution_type = "default_dependency_resolution"
1196+
for key in STOCK_DEPENDENCY_RESOLUTION_STRATEGIES:
1197+
if kwds.get(key):
1198+
resolution_type = key
1199+
1200+
if resolution_type != "__explicit__":
1201+
# Planemo manages the dependency resolve conf file.
1202+
resolvers_conf = os.path.join(
1203+
config_directory,
1204+
"resolvers_conf.xml"
1205+
)
1206+
template_str = STOCK_DEPENDENCY_RESOLUTION_STRATEGIES[resolution_type]
1207+
conf_contents = Template(template_str).safe_substitute({
1208+
'attributes': attribute_str
1209+
})
1210+
open(resolvers_conf, "w").write(conf_contents)
1211+
ctx.vlog(
1212+
"Writing dependency_resolvers_config_file to path %s with contents [%s]",
1213+
resolvers_conf,
1214+
conf_contents,
1215+
)
1216+
kwds["dependency_resolvers_config_file"] = resolvers_conf
1217+
1218+
1219+
def _validate_dependency_resolution_options(kwds):
1220+
resolutions_strategies = [
1221+
"brew_dependency_resolution",
1222+
"dependency_resolvers_config_file",
1223+
"shed_dependency_resolution",
1224+
"conda_dependency_resolution",
1225+
]
1226+
1227+
selected_strategies = 0
1228+
for key in resolutions_strategies:
11951229
if kwds.get(key):
1196-
resolvers_conf = os.path.join(
1197-
config_directory,
1198-
"resolvers_conf.xml"
1199-
)
1200-
template_str = STOCK_DEPENDENCY_RESOLUTION_STRATEGIES[key]
1201-
conf_contents = Template(template_str).safe_substitute({
1202-
'attributes': attribute_str
1203-
})
1204-
open(resolvers_conf, "w").write(conf_contents)
1205-
ctx.vlog(
1206-
"Writing dependency_resolvers_config_file to path %s with contents [%s]",
1207-
resolvers_conf,
1208-
conf_contents,
1209-
)
1210-
kwds["dependency_resolvers_config_file"] = resolvers_conf
1230+
selected_strategies += 1
1231+
1232+
if selected_strategies > 1:
1233+
message = "At most one option from [%s] may be specified"
1234+
raise click.UsageError(message % resolutions_strategies)
12111235

12121236

12131237
def _handle_container_resolution(ctx, kwds, galaxy_properties):

planemo/options.py

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -448,7 +448,7 @@ def conda_ensure_channels_option():
448448
use_env_var=True,
449449
help=("Ensure conda is configured with specified comma separated "
450450
"list of channels."),
451-
default="conda-forge,r,bioconda,iuc",
451+
default="iuc,bioconda,r,defaults,conda-forge",
452452
)
453453

454454

@@ -463,17 +463,19 @@ def conda_copy_dependencies_option():
463463

464464
def conda_auto_install_option():
465465
return planemo_option(
466-
"--conda_auto_install",
466+
"--conda_auto_install/--no_conda_auto_install",
467467
is_flag=True,
468+
default=True,
468469
help=("Conda dependency resolution for Galaxy will auto install "
469470
"will attempt to install requested but missing packages.")
470471
)
471472

472473

473474
def conda_auto_init_option():
474475
return planemo_option(
475-
"--conda_auto_init",
476+
"--conda_auto_init/--no_conda_auto_init",
476477
is_flag=True,
478+
default=True,
477479
help=("Conda dependency resolution for Galaxy will auto install "
478480
"conda itself using miniconda if not availabe on conda_prefix.")
479481
)

requirements.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,6 @@ virtualenv
1313
lxml
1414
gxformat2>=0.1.1
1515
ephemeris>=0.2.0
16-
galaxy-lib>=16.10.5
16+
galaxy-lib>=17.01.2
1717
html5lib>=0.9999999,!=0.99999999,!=0.999999999,!=1.0b10,!=1.0b09 ; python_version == '2.7'
1818
cwltool==1.0.20160726135535 ; python_version == '2.7'

tests/test_cmd_test_conda.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
)
1010

1111

12-
class CmdTestTestCase(CliTestCase):
12+
class CmdTestCondaTestCase(CliTestCase):
1313
"""Integration tests for the ``test`` command."""
1414

1515
@skip_if_environ("PLANEMO_SKIP_GALAXY_TESTS")

0 commit comments

Comments
 (0)