Skip to content

Commit 11ce744

Browse files
committed
Finish hooking the pieces together for Conda resolution.
With a test case.
1 parent 0b78e5a commit 11ce744

File tree

9 files changed

+61
-7
lines changed

9 files changed

+61
-7
lines changed

Makefile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,7 @@ test-install-pypi:
8383
bash install_test/test_install.bash
8484

8585
test-install-wheel: dist
86-
PULSAR_INSTALL_TARGET=$(shell pwd)/dist/pulsar_app*.whl bash install_test/test_install.bash
86+
PULSAR_INSTALL_TARGET=$(shell pwd)/dist/pulsar_app*.whl bash install_test/test_install_conda.bash
8787

8888
coverage:
8989
coverage run --source $(SOURCE_DIR) setup.py $(TEST_DIR)

install_test/common_functions.bash

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ set -e
22

33
shopt -s nullglob
44

5+
PULSAR_TARGET_POORT="${PULSAR_TARGET_POORT:-8913}"
56
PULSAR_INSTALL_TARGET="${PULSAR_INSTALL_TARGET:-pulsar-app}"
67
PLANEMO_INSTALL_TARGET="${PLANEMO_INSTALL_TARGET:-planemo==0.36.1}"
78

@@ -38,9 +39,20 @@ stop_pulsar() {
3839
check_pulsar() {
3940
cd pulsar
4041

42+
if curl -s "http://localhost:$PULSAR_TARGET_POORT"
43+
then
44+
echo "Port $PULSAR_TARGET_POORT already bound, Pulsar will fail to start."
45+
exit 1;
46+
fi
47+
4148
echo "Starting Pulsar in daemon mode."
4249
pulsar --daemon
4350
echo "Waiting for Pulsar to start."
51+
while ! curl -s "http://localhost:$PULSAR_TARGET_POORT";
52+
do
53+
printf "."
54+
sleep 1;
55+
done
4456
sleep 2
4557
echo "Running a standalone Pulsar job."
4658
pulsar-check # runs a test job

install_test/test_install_conda.bash

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
#!/bin/bash
2+
3+
set -e
4+
5+
SCRIPT_DIR="$( cd "$(dirname "$0")" ; pwd )"
6+
. "$SCRIPT_DIR/common_functions.bash"
7+
8+
init_temp_dir
9+
10+
init_pulsar
11+
12+
cd pulsar
13+
echo "Running pulsar-config with --auto_conda"
14+
pulsar-config --auto_conda
15+
16+
cd ..
17+
18+
check_pulsar
19+
20+
init_planemo "conda_testing"
21+
22+
run_planemo --job_config_file "$SCRIPT_DIR/galaxy_job_conf.xml" test_tools/bwa.xml
23+
24+
stop_pulsar

pulsar/core.py

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -124,7 +124,11 @@ def __setup_object_store(self, conf):
124124
def __setup_dependency_manager(self, conf):
125125
dependencies_dir = conf.get("tool_dependency_dir", "dependencies")
126126
resolvers_config_file = conf.get("dependency_resolvers_config_file", "dependency_resolvers_conf.xml")
127-
self.dependency_manager = DependencyManager(dependencies_dir, resolvers_config_file)
127+
conda_config = {}
128+
for key, value in conf.items():
129+
if key.startswith("conda_"):
130+
conda_config[key] = value
131+
self.dependency_manager = DependencyManager(dependencies_dir, resolvers_config_file, **conda_config)
128132

129133
def __setup_job_metrics(self, conf):
130134
job_metrics = conf.get("job_metrics", None)

pulsar/managers/base/__init__.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -176,15 +176,16 @@ def _list_dir(self, directory_or_none):
176176
else:
177177
return listdir(directory_or_none)
178178

179-
def _expand_command_line(self, command_line, dependencies_description):
179+
def _expand_command_line(self, command_line, dependencies_description, job_directory=None):
180180
if dependencies_description is None:
181181
return command_line
182182

183183
requirements = dependencies_description.requirements
184184
installed_tool_dependencies = dependencies_description.installed_tool_dependencies
185185
dependency_commands = self.dependency_manager.dependency_shell_commands(
186186
requirements=requirements,
187-
installed_tool_dependencies=installed_tool_dependencies
187+
installed_tool_dependencies=installed_tool_dependencies,
188+
job_directory=job_directory,
188189
)
189190
if dependency_commands:
190191
command_line = "%s; %s" % ("; ".join(dependency_commands), command_line)

pulsar/managers/base/directory.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -105,7 +105,7 @@ def _tool_id(self, job_id):
105105

106106
# Helpers methods related to setting up job script files.
107107
def _setup_job_file(self, job_id, command_line, dependencies_description=None, env=[]):
108-
command_line = self._expand_command_line(command_line, dependencies_description)
108+
command_line = self._expand_command_line(command_line, dependencies_description, job_directory=self.job_directory(job_id).job_directory)
109109
script_env = self._job_template_env(job_id, command_line=command_line, env=env)
110110
script = job_script(**script_env)
111111
return self._write_job_script(job_id, script)

pulsar/managers/queued_cli.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ def launch(self, job_id, command_line, submit_params={}, dependencies_descriptio
2626
stdout_path = self._stdout_path(job_id)
2727
stderr_path = self._stderr_path(job_id)
2828
job_name = self._job_name(job_id)
29-
command_line = self._expand_command_line(command_line, dependencies_description)
29+
command_line = self._expand_command_line(command_line, dependencies_description, job_directory=self.job_directory(job_id).job_directory)
3030
job_script_kwargs = self._job_template_env(job_id, command_line=command_line, env=env)
3131
extra_kwargs = job_interface.job_script_kwargs(stdout_path, stderr_path, job_name)
3232
job_script_kwargs.update(extra_kwargs)

pulsar/managers/unqueued.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -152,7 +152,7 @@ def _prepare_run(self, job_id, command_line, dependencies_description, env):
152152
if platform.system().lower() == "windows":
153153
# TODO: Don't ignore requirements and env without warning. Ideally
154154
# process them or at least warn about them being ignored.
155-
command_line = self._expand_command_line(command_line, dependencies_description)
155+
command_line = self._expand_command_line(command_line, dependencies_description, job_directory=self.job_directory(job_id).job_directory)
156156
else:
157157
command_line = self._setup_job_file(job_id, command_line, dependencies_description=dependencies_description, env=env)
158158
return command_line

pulsar/scripts/config.py

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,8 @@
2929
HELP_DIRECTORY = "Directory containing the configuration files for Pulsar."
3030
HELP_MQ = ("Write configuration files for message queue server deployment "
3131
"instead of more traditional RESTful web based pulsar.")
32+
HELP_AUTO_CONDA = ("Auto initialize Conda for tool resolution and auto install "
33+
"dependencies on demand.")
3234
HELP_NO_LOGGING = ("Do not write Pulsar's default logging configuration to server.ini "
3335
"and if uwsgi is configured do not configure its logging either.")
3436
HELP_SUPERVISOR = ("Write a supervisord configuration file for "
@@ -145,6 +147,10 @@ def main(argv=None):
145147
arg_parser.add_argument("--directory",
146148
default=".",
147149
help=HELP_DIRECTORY)
150+
arg_parser.add_argument("--auto_conda",
151+
action="store_true",
152+
default=False,
153+
help=HELP_AUTO_CONDA)
148154
arg_parser.add_argument("--mq",
149155
action="store_true",
150156
default=False,
@@ -198,6 +204,10 @@ def main(argv=None):
198204
if not os.path.exists(directory):
199205
os.makedirs(directory)
200206

207+
default_dependencies_dir = os.path.join(directory, "dependencies")
208+
if not os.path.exists(default_dependencies_dir):
209+
os.makedirs(default_dependencies_dir)
210+
201211
print("Bootstrapping pulsar configuration into directory %s" % relative_directory)
202212
_handle_app_yaml(args, directory)
203213
_handle_server_ini(args, directory)
@@ -298,6 +308,9 @@ def _handle_app_yaml(args, directory):
298308
contents += 'private_token: %s\n' % args.private_token
299309
if args.mq:
300310
contents += 'message_queue_url: "amqp://guest:guest@localhost:5672//"\n'
311+
if args.auto_conda:
312+
contents += 'conda_auto_init: true\n'
313+
contents += 'conda_auto_install: true\n'
301314
else:
302315
if not IS_WINDOWS and args.libdrmaa_path:
303316
contents += 'manager:\n type: queued_drmaa\n'

0 commit comments

Comments
 (0)