def startup_command(self, ctx, **kwds): """Return a shell command used to startup this instance. Among other common planmo kwds, this should respect the ``daemon`` keyword. """ daemon = kwds.get("daemon", False) pid_file = self._pid_file # TODO: Allow running dockerized Galaxy here instead. setup_venv_command = setup_venv(ctx, kwds) run_script = os.path.join(self.galaxy_root, "run.sh") run_script += " $COMMON_STARTUP_ARGS" if daemon: run_script += " --pid-file '%s' --daemon" % pid_file self.env["GALAXY_RUN_ALL"] = "1" else: run_script += " --server-name '%s' --reload" % self.server_name server_ini = os.path.join(self.config_directory, "galaxy.ini") self.env["GALAXY_CONFIG_FILE"] = server_ini cd_to_galaxy_command = "cd %s" % self.galaxy_root return shell_join( cd_to_galaxy_command, setup_venv_command, run_script, )
def startup_command(self, ctx, **kwds): """Return a shell command used to startup this instance. Among other common planemo kwds, this should respect the ``daemon`` keyword. """ daemon = kwds.get("daemon", False) # TODO: Allow running dockerized Galaxy here instead. setup_venv_command = setup_venv(ctx, kwds) run_script = "%s $COMMON_STARTUP_ARGS" % shlex_quote(os.path.join(self.galaxy_root, "run.sh")) if daemon: run_script += " --daemon" self.env["GALAXY_RUN_ALL"] = "1" else: run_script += " --server-name %s" % shlex_quote(self.server_name) server_ini = os.path.join(self.config_directory, "galaxy.ini") self.env["GALAXY_CONFIG_FILE"] = server_ini if parse_version(kwds.get('galaxy_python_version') or DEFAULT_PYTHON_VERSION) >= parse_version('3'): # We need to start under gunicorn self.env['APP_WEBSERVER'] = 'gunicorn' self.env['GUNICORN_CMD_ARGS'] = "--bind={host}:{port} --name={server_name}".format( host=kwds.get('host', '127.0.0.1'), port=kwds['port'], server_name=self.server_name, ) cd_to_galaxy_command = ['cd', self.galaxy_root] return shell_join( cd_to_galaxy_command, setup_venv_command, setup_common_startup_args(), run_script, )
def startup_command(self, ctx, **kwds): """Return a shell command used to startup this instance. Among other common planmo kwds, this should respect the ``daemon`` keyword. """ daemon = kwds.get("daemon", False) daemon_str = "" if not daemon else " -d" docker_run_extras = "-p %s:80%s" % (self.port, daemon_str) env_directives = ["%s='%s'" % item for item in self.env.items()] image = kwds.get("docker_galaxy_image", "bgruening/galaxy-stable") run_command = docker_util.build_docker_run_command( "", image, interactive=False, env_directives=env_directives, working_directory=None, name=self.server_name, run_extra_arguments=docker_run_extras, set_user=False, volumes=self.volumes, **self.docker_target_kwds ) chmod_command = [ "chmod", "-R", "o+rwx", self.config_directory, ] if self.export_directory: chmod_command.append(self.export_directory) return shell_join( argv_to_str(chmod_command), run_command, )
def startup_command(self, ctx, **kwds): """Return a shell command used to startup this instance. Among other common planmo kwds, this should respect the ``daemon`` keyword. """ daemon = kwds.get("daemon", False) daemon_str = "" if not daemon else " -d" docker_run_extras = "-p %s:80%s" % (self.port, daemon_str) env_directives = ["%s='%s'" % item for item in self.env.items()] image = kwds.get("docker_galaxy_image", "bgruening/galaxy-stable") run_command = docker_util.build_docker_run_command( "", image, interactive=False, env_directives=env_directives, working_directory=None, name=self.server_name, run_extra_arguments=docker_run_extras, set_user=False, volumes=self.volumes, **self.docker_target_kwds) chmod_command = [ "chmod", "-R", "o+rwx", self.config_directory, ] if self.export_directory: chmod_command.append(self.export_directory) return shell_join( argv_to_str(chmod_command), run_command, )
def setup_venv(ctx, kwds): return shell_join( locate_galaxy_virtualenv(ctx, kwds), PRINT_VENV_COMMAND if ctx.verbose else None, CREATE_COMMAND, PRINT_VENV_COMMAND if ctx.verbose else None, ACTIVATE_COMMAND, )
def locate_galaxy_virtualenv(ctx, kwds): if not kwds.get("no_cache_galaxy", False): workspace = ctx.workspace shared_venv_path = os.path.join(workspace, "gx_venv") venv_command = CACHED_VIRTUAL_ENV_COMMAND % shared_venv_path else: venv_command = UNCACHED_VIRTUAL_ENV_COMMAND return shell_join(venv_command, "export GALAXY_VIRTUAL_ENV")
def setup_venv(ctx, kwds): create_template_params = {"create_virtualenv": create_command("$GALAXY_VIRTUAL_ENV")} return shell_join( locate_galaxy_virtualenv(ctx, kwds), PRINT_VENV_COMMAND if ctx.verbose else None, CREATE_COMMAND_TEMPLATE.safe_substitute(create_template_params), PRINT_VENV_COMMAND if ctx.verbose else None, ACTIVATE_COMMAND, )
def _install_with_command(ctx, galaxy_root, env, kwds): setup_venv_command = setup_venv(ctx, kwds) env['__PYVENV_LAUNCHER__'] = '' install_cmd = shell_join( setup_venv_command, setup_common_startup_args(), COMMAND_STARTUP_COMMAND, ) shell(install_cmd, cwd=galaxy_root, env=env)
def _install_with_command(ctx, command, galaxy_root, env, kwds): setup_venv_command = setup_venv(ctx, kwds) env['__PYVENV_LAUNCHER__'] = '' install_cmd = shell_join( command, ['cd', galaxy_root], setup_venv_command, setup_common_startup_args(), COMMAND_STARTUP_COMMAND, ) shell(install_cmd, env=env)
def locate_galaxy_virtualenv(ctx, kwds): if not kwds.get("no_cache_galaxy", False): workspace = ctx.workspace shared_venv_path = os.path.join(workspace, "gx_venv") venv_command = CACHED_VIRTUAL_ENV_COMMAND % shared_venv_path else: venv_command = UNCACHED_VIRTUAL_ENV_COMMAND return shell_join( venv_command, "export GALAXY_VIRTUAL_ENV", )
def _install_with_command(ctx, config_directory, command, env, kwds): setup_venv_command = setup_venv(ctx, kwds) env['__PYVENV_LAUNCHER__'] = '' install_cmd = shell_join( ['cd', config_directory], command, ['cd', 'galaxy-dev'], setup_venv_command, setup_common_startup_args(), COMMAND_STARTUP_COMMAND, ) shell(install_cmd, env=env)
def _install_with_command(ctx, galaxy_root, env, kwds): setup_venv_command = setup_venv(ctx, kwds) install_cmd = shell_join( setup_venv_command, setup_common_startup_args(), COMMAND_STARTUP_COMMAND, ) exit_code = shell(install_cmd, cwd=galaxy_root, env=env) if exit_code != 0: raise Exception("Failed to install Galaxy via command [%s]" % install_cmd) if not os.path.exists(galaxy_root): raise Exception("Failed to create Galaxy directory [%s]" % galaxy_root) if not os.path.exists(os.path.join(galaxy_root, "lib")): raise Exception("Failed to create Galaxy directory [%s], lib missing" % galaxy_root)
def setup_venv(ctx, kwds): if kwds.get("skip_venv", False): return "" create_template_params = { 'create_virtualenv': create_command("$GALAXY_VIRTUAL_ENV", kwds.get('galaxy_python_version')) } return shell_join( locate_galaxy_virtualenv(ctx, kwds), PRINT_VENV_COMMAND if ctx.verbose else None, CREATE_COMMAND_TEMPLATE.safe_substitute(create_template_params), PRINT_VENV_COMMAND if ctx.verbose else None, ACTIVATE_COMMAND, )
def locate_galaxy_virtualenv(ctx, kwds): if not kwds.get("no_cache_galaxy", False): workspace = ctx.workspace galaxy_branch = kwds.get("galaxy_branch") or "master" shared_venv_path = os.path.join(workspace, "gx_venv") if galaxy_branch != "master": shared_venv_path = "%s_%s" % (shared_venv_path, galaxy_branch) venv_command = CACHED_VIRTUAL_ENV_COMMAND % shlex_quote( shared_venv_path) else: venv_command = UNCACHED_VIRTUAL_ENV_COMMAND return shell_join( venv_command, "export GALAXY_VIRTUAL_ENV", )
def locate_galaxy_virtualenv(ctx, kwds): if not kwds.get("no_cache_galaxy", False): workspace = ctx.workspace galaxy_branch = kwds.get("galaxy_branch") or "master" shared_venv_path = os.path.join(workspace, "gx_venv") galaxy_python_version = kwds.get('galaxy_python_version') or DEFAULT_PYTHON_VERSION if galaxy_python_version != DEFAULT_PYTHON_VERSION: shared_venv_path = "%s_%s" % (shared_venv_path, galaxy_python_version) if galaxy_branch != "master": shared_venv_path = "%s_%s" % (shared_venv_path, galaxy_branch) venv_command = CACHED_VIRTUAL_ENV_COMMAND % shlex_quote(shared_venv_path) else: venv_command = UNCACHED_VIRTUAL_ENV_COMMAND return shell_join( venv_command, "export GALAXY_VIRTUAL_ENV", )
def _install_with_command(ctx, config_directory, command, env, kwds): # TODO: --watchdog pip_installs = [] if pip_installs: pip_install_command = PIP_INSTALL_CMD % " ".join(pip_installs) else: pip_install_command = "" setup_venv_command = setup_venv(ctx, kwds) install_cmd = shell_join( "cd %s" % config_directory, command, "cd galaxy-dev", setup_venv_command, pip_install_command, setup_common_startup_args(), COMMAND_STARTUP_COMMAND, ) shell(install_cmd, env=env)
def _install_with_command(ctx, config_directory, command, env, kwds): # TODO: --watchdog pip_installs = [] if pip_installs: pip_install_command = ['pip', 'install'] + pip_installs else: pip_install_command = "" setup_venv_command = setup_venv(ctx, kwds) install_cmd = shell_join( ['cd', config_directory], command, ['cd', 'galaxy-dev'], setup_venv_command, pip_install_command, setup_common_startup_args(), COMMAND_STARTUP_COMMAND, ) shell(install_cmd, env=env)
def locate_galaxy_virtualenv(ctx, kwds): if os.environ.get("GALAXY_VIRTUAL_ENV"): venv_command = "" elif not kwds.get("no_cache_galaxy", False): workspace = ctx.workspace galaxy_branch = kwds.get("galaxy_branch") or "master" shared_venv_path = os.path.join(workspace, "gx_venv") galaxy_python_version = kwds.get('galaxy_python_version') or DEFAULT_PYTHON_VERSION shared_venv_path = "%s_%s" % (shared_venv_path, galaxy_python_version) if galaxy_branch != "master": shared_venv_path = "%s_%s" % (shared_venv_path, galaxy_branch) venv_command = CACHED_VIRTUAL_ENV_COMMAND % shlex_quote(shared_venv_path) else: venv_command = UNCACHED_VIRTUAL_ENV_COMMAND return shell_join( venv_command, "export GALAXY_VIRTUAL_ENV", )
def _install_with_command(ctx, config_directory, command, kwds): # TODO: --watchdog pip_installs = [] if kwds.get("cwl", False): pip_installs.append("cwltool") if pip_installs: pip_install_command = PIP_INSTALL_CMD % " ".join(pip_installs) else: pip_install_command = "" setup_venv_command = galaxy_run.setup_venv(ctx, kwds) install_cmd = shell_join( "cd %s" % config_directory, command, "cd galaxy-dev", setup_venv_command, pip_install_command, galaxy_run.setup_common_startup_args(), COMMAND_STARTUP_COMMAND, ) shell(install_cmd)
def serve(ctx, paths, **kwds): # TODO: Preceate a user. # TODO: Setup an admin user. # TODO: Pass through more parameters. # TODO: Populate test-data directory as FTP directory. daemon = kwds.get("daemon", False) if daemon: kwds["no_cleanup"] = True with galaxy_config(ctx, paths, **kwds) as config: pid_file = config.pid_file # TODO: Allow running dockerized Galaxy here instead. setup_venv_command = setup_venv(ctx, kwds) run_script = os.path.join(config.galaxy_root, "run.sh") run_script += " $COMMON_STARTUP_ARGS" if daemon: run_script += " --pid-file '%s' --daemon" % pid_file config.env["GALAXY_RUN_ALL"] = "1" else: run_script += " --server-name '%s' --reload" % config.server_name server_ini = os.path.join(config.config_directory, "galaxy.ini") config.env["GALAXY_CONFIG_FILE"] = server_ini cd_to_galaxy_command = "cd %s" % config.galaxy_root cmd = io.shell_join( cd_to_galaxy_command, setup_venv_command, run_script, ) action = "Starting galaxy" run_galaxy_command( ctx, cmd, config.env, action, ) host = kwds.get("host", "127.0.0.1") port = kwds.get("port") assert network_util.wait_net_service(host, port) time.sleep(.1) assert network_util.wait_net_service(host, port) return config
def serve(ctx, paths, **kwds): # TODO: Preceate a user. # TODO: Setup an admin user. # TODO: Pass through more parameters. # TODO: Populate test-data directory as FTP directory. daemon = kwds.get("daemon", False) if daemon: kwds["no_cleanup"] = True with galaxy_config.galaxy_config(ctx, paths, **kwds) as config: # TODO: Allow running dockerized Galaxy here instead. setup_common_startup_args = galaxy_run.set_variable_if_wheels( "COMMON_STARTUP_ARGS", "--skip-venv" ) setup_venv_command = galaxy_run.setup_venv(ctx, kwds) run_script = os.path.join(config.galaxy_root, "run.sh") run_script += " $COMMON_STARTUP_ARGS" if daemon: run_script += " --daemon --wait" config.env["GALAXY_RUN_ALL"] = "1" else: run_script += " --server-name '%s' --reload" % config.server_name server_ini = os.path.join(config.config_directory, "galaxy.ini") config.env["GALAXY_CONFIG_FILE"] = server_ini cd_to_galaxy_command = "cd %s" % config.galaxy_root cmd = io.shell_join( cd_to_galaxy_command, setup_common_startup_args, setup_venv_command, run_script, ) action = "Starting galaxy" galaxy_run.run_galaxy_command( ctx, cmd, config.env, action, ) return config
create_command, DEFAULT_PYTHON_VERSION, ) # Activate galaxy's virtualenv if present (needed for tests say but not for # server because run.sh does this). ACTIVATE_COMMAND = ( 'if [ -e "$GALAXY_VIRTUAL_ENV" ]; then . "$GALAXY_VIRTUAL_ENV"/bin/activate; ' 'echo "Activated a virtualenv for Galaxy"; echo "$VIRTUAL_ENV"; ' 'else echo "Failed to activate virtualenv."; fi') CREATE_COMMAND_TEMPLATE = string.Template( 'if [ ! -e "$GALAXY_VIRTUAL_ENV" ]; then $create_virtualenv; echo "Created virtualenv"; fi', ) PRINT_VENV_COMMAND = shell_join( r'echo "Set \$GALAXY_VIRTUAL_ENV to $GALAXY_VIRTUAL_ENV"', ('if [ -e "$GALAXY_VIRTUAL_ENV" ]; ' 'then echo "Virtual environment directory exists."; ' 'else echo "Virtual environment directory does not exist."; fi'), ) CACHED_VIRTUAL_ENV_COMMAND = ("if [ -d .venv ] || [ -f dist-eggs.ini ]; " "then GALAXY_VIRTUAL_ENV=.venv; " "else GALAXY_VIRTUAL_ENV=%s; fi") UNCACHED_VIRTUAL_ENV_COMMAND = "GALAXY_VIRTUAL_ENV=.venv" def setup_venv(ctx, kwds): if kwds.get("skip_venv", False): return "" create_template_params = { 'create_virtualenv':
def run_in_config(ctx, config, run=run_galaxy_command, test_data_target_dir=None, **kwds): """Run Galaxy tests with the run_tests.sh command. The specified `config` object describes the context for tool execution. """ config_directory = config.config_directory html_report_file = kwds["test_output"] job_output_files = kwds.get("job_output_files", None) if job_output_files is None: job_output_files = os.path.join(config_directory, "jobfiles") xunit_report_file = _xunit_state(kwds, config) xunit_report_file_tracker = _FileChangeTracker(xunit_report_file) structured_report_file = _structured_report_file(kwds, config) structured_report_file_tracker = _FileChangeTracker(structured_report_file) info("Testing using galaxy_root %s", config.galaxy_root) # TODO: Allow running dockerized Galaxy here instead. server_ini = os.path.join(config_directory, "galaxy.ini") config.env["GALAXY_CONFIG_FILE"] = server_ini config.env["GALAXY_TEST_VERBOSE_ERRORS"] = "true" config.env["GALAXY_TEST_SAVE"] = job_output_files cd_to_galaxy_command = ['cd', config.galaxy_root] test_cmd = test_structures.GalaxyTestCommand( html_report_file, xunit_report_file, structured_report_file, failed=kwds.get("failed", False), installed=kwds.get("installed", False), ).build() setup_common_startup_args = "" if kwds.get("skip_venv", False): setup_common_startup_args = shell_join( 'COMMON_STARTUP_ARGS=--skip-venv', 'export COMMON_STARTUP_ARGS', 'echo "Set COMMON_STARTUP_ARGS to ${COMMON_STARTUP_ARGS}"', ) setup_venv_command = setup_venv(ctx, kwds) cmd = shell_join( cd_to_galaxy_command, setup_common_startup_args, setup_venv_command, test_cmd, ) action = "Testing tools" return_code = run(ctx, cmd, config.env, action) if kwds.get('update_test_data', False): copy_tree(job_output_files, test_data_target_dir or config.test_data_dir) _check_test_outputs(xunit_report_file_tracker, structured_report_file_tracker) test_results = test_structures.GalaxyTestResults( structured_report_file, xunit_report_file, html_report_file, return_code, ) structured_data = test_results.structured_data return handle_reports_and_summary(ctx, structured_data, exit_code=test_results.exit_code, kwds=kwds)
import os import string from planemo.io import info, shell_join from galaxy.tools.deps.commands import shell # Activate galaxy's virtualenv if present (needed for tests say but not for # server because run.sh does this). ACTIVATE_COMMAND = "[ -e $GALAXY_VIRTUAL_ENV ] && . $GALAXY_VIRTUAL_ENV/bin/activate" CREATE_COMMAND = shell_join( 'if [ ! -e $GALAXY_VIRTUAL_ENV ]', ' then type virtualenv >/dev/null 2>&1 && virtualenv $GALAXY_VIRTUAL_ENV', ' else echo "Reusing existing virtualenv $GALAXY_VIRTUAL_ENV"', ' fi', ) PRINT_VENV_COMMAND = shell_join( 'echo "Set \$GALAXY_VIRTUAL_ENV to $GALAXY_VIRTUAL_ENV"', 'if [ -e $GALAXY_VIRTUAL_ENV ]', 'then echo "Virtual environment directory exists."', 'else echo "Virtual environment directory does not exist."', 'fi', ) # TODO: Mac-y curl variant of this. DOWNLOAD_GALAXY = ( "wget https://codeload.github.com/galaxyproject/galaxy/tar.gz/dev" ) CACHED_VIRTUAL_ENV_COMMAND = ("if [ -d .venv ] || [ -f dist-eggs.ini ];"
def run_in_config(ctx, config, **kwds): config_directory = config.config_directory html_report_file = kwds["test_output"] job_output_files = kwds.get("job_output_files", None) if job_output_files is None: job_output_files = os.path.join(config_directory, "jobfiles") xunit_supported, xunit_report_file = __xunit_state(kwds, config) structured_report_file = __structured_report_file(kwds, config) info("Testing using galaxy_root %s", config.galaxy_root) # TODO: Allow running dockerized Galaxy here instead. server_ini = os.path.join(config_directory, "galaxy.ini") config.env["GALAXY_CONFIG_FILE"] = server_ini config.env["GALAXY_TEST_VERBOSE_ERRORS"] = "true" config.env["GALAXY_TEST_SAVE"] = job_output_files cd_to_galaxy_command = "cd %s" % config.galaxy_root test_cmd = test_structures.GalaxyTestCommand( html_report_file, xunit_report_file, structured_report_file, failed=kwds.get("failed", False), installed=kwds.get("installed", False), ).build() setup_common_startup_args = "" if kwds.get("skip_venv", False): setup_common_startup_args = ( 'COMMON_STARTUP_ARGS=--skip-venv; ' 'export COMMON_STARTUP_ARGS; ' 'echo "Set COMMON_STARTUP_ARGS to ${COMMON_STARTUP_ARGS}"') setup_venv_command = setup_venv(ctx, kwds) cmd = shell_join( cd_to_galaxy_command, setup_common_startup_args, setup_venv_command, test_cmd, ) action = "Testing tools" return_code = run_galaxy_command(ctx, cmd, config.env, action) if kwds.get('update_test_data', False): update_cp_args = (job_output_files, config.test_data_dir) shell('cp -r "%s"/* "%s"' % update_cp_args) if xunit_report_file and (not os.path.exists(xunit_report_file)): warn(NO_XUNIT_MESSAGE) xunit_report_file = None test_results = test_structures.GalaxyTestResults( structured_report_file, xunit_report_file, html_report_file, return_code, ) test_data = test_results.structured_data handle_reports(ctx, test_data, kwds) __handle_summary(test_results, **kwds) return return_code
def run_in_config(ctx, config, run=run_galaxy_command, **kwds): """Run Galaxy tests with the run_tests.sh command. The specified `config` object describes the context for tool execution. """ config_directory = config.config_directory html_report_file = kwds["test_output"] job_output_files = kwds.get("job_output_files", None) if job_output_files is None: job_output_files = os.path.join(config_directory, "jobfiles") xunit_report_file = _xunit_state(kwds, config) xunit_report_file_tracker = _FileChangeTracker(xunit_report_file) structured_report_file = _structured_report_file(kwds, config) structured_report_file_tracker = _FileChangeTracker(structured_report_file) info("Testing using galaxy_root %s", config.galaxy_root) # TODO: Allow running dockerized Galaxy here instead. server_ini = os.path.join(config_directory, "galaxy.ini") config.env["GALAXY_CONFIG_FILE"] = server_ini config.env["GALAXY_TEST_VERBOSE_ERRORS"] = "true" config.env["GALAXY_TEST_SAVE"] = job_output_files cd_to_galaxy_command = "cd %s" % config.galaxy_root test_cmd = test_structures.GalaxyTestCommand( html_report_file, xunit_report_file, structured_report_file, failed=kwds.get("failed", False), installed=kwds.get("installed", False), ).build() setup_common_startup_args = "" if kwds.get("skip_venv", False): setup_common_startup_args = ( 'COMMON_STARTUP_ARGS=--skip-venv; ' 'export COMMON_STARTUP_ARGS; ' 'echo "Set COMMON_STARTUP_ARGS to ${COMMON_STARTUP_ARGS}"' ) setup_venv_command = setup_venv(ctx, kwds) cmd = shell_join( cd_to_galaxy_command, setup_common_startup_args, setup_venv_command, test_cmd, ) action = "Testing tools" return_code = run( ctx, cmd, config.env, action ) if kwds.get('update_test_data', False): update_cp_args = (job_output_files, config.test_data_dir) shell('cp -r "%s"/* "%s"' % update_cp_args) _check_test_outputs(xunit_report_file_tracker, structured_report_file_tracker) test_results = test_structures.GalaxyTestResults( structured_report_file, xunit_report_file, html_report_file, return_code, ) structured_data = test_results.structured_data return handle_reports_and_summary( ctx, structured_data, exit_code=test_results.exit_code, kwds=kwds )
from planemo.io import info, shell_join from planemo.virtualenv import ( create_command, DEFAULT_PYTHON_VERSION, ) # Activate galaxy's virtualenv if present (needed for tests say but not for # server because run.sh does this). ACTIVATE_COMMAND = 'if [ -e "$GALAXY_VIRTUAL_ENV" ]; then . "$GALAXY_VIRTUAL_ENV"/bin/activate; fi' CREATE_COMMAND_TEMPLATE = string.Template( 'if [ ! -e "$GALAXY_VIRTUAL_ENV" ]; then $create_virtualenv; fi', ) PRINT_VENV_COMMAND = shell_join( r'echo "Set \$GALAXY_VIRTUAL_ENV to $GALAXY_VIRTUAL_ENV"', ('if [ -e "$GALAXY_VIRTUAL_ENV" ]; ' 'then echo "Virtual environment directory exists."; ' 'else echo "Virtual environment directory does not exist."; fi'), ) CACHED_VIRTUAL_ENV_COMMAND = ("if [ -d .venv ] || [ -f dist-eggs.ini ]; " "then GALAXY_VIRTUAL_ENV=.venv; " "else GALAXY_VIRTUAL_ENV=%s; fi") UNCACHED_VIRTUAL_ENV_COMMAND = "GALAXY_VIRTUAL_ENV=.venv" def setup_venv(ctx, kwds): if kwds.get("skip_venv", False): return "" create_template_params = {
import os import string from planemo.io import info, shell_join from planemo.virtualenv import create_command from galaxy.tools.deps.commands import shell # Activate galaxy's virtualenv if present (needed for tests say but not for # server because run.sh does this). ACTIVATE_COMMAND = "[ -e $GALAXY_VIRTUAL_ENV ] && . $GALAXY_VIRTUAL_ENV/bin/activate" CREATE_COMMAND_TEMPLATE = string.Template( 'if [ ! -e $GALAXY_VIRTUAL_ENV ]; then $create_virtualenv; fi', ) PRINT_VENV_COMMAND = shell_join( 'echo "Set \$GALAXY_VIRTUAL_ENV to $GALAXY_VIRTUAL_ENV"', 'if [ -e $GALAXY_VIRTUAL_ENV ]', 'then echo "Virtual environment directory exists."', 'else echo "Virtual environment directory does not exist."', 'fi', ) # TODO: Mac-y curl variant of this. DOWNLOAD_GALAXY = ( "wget https://codeload.github.com/galaxyproject/galaxy/tar.gz/dev") CACHED_VIRTUAL_ENV_COMMAND = ("if [ -d .venv ] || [ -f dist-eggs.ini ];" " then GALAXY_VIRTUAL_ENV=.venv; " " else GALAXY_VIRTUAL_ENV=%s; fi") UNCACHED_VIRTUAL_ENV_COMMAND = "GALAXY_VIRTUAL_ENV=.venv" def setup_venv(ctx, kwds):
def run_in_config(ctx, config, **kwds): config_directory = config.config_directory html_report_file = kwds["test_output"] job_output_files = kwds.get("job_output_files", None) if job_output_files is None: job_output_files = os.path.join(config_directory, "jobfiles") xunit_supported, xunit_report_file = __xunit_state(kwds, config) structured_report_file = __structured_report_file(kwds, config) info("Testing using galaxy_root %s", config.galaxy_root) # TODO: Allow running dockerized Galaxy here instead. server_ini = os.path.join(config_directory, "galaxy.ini") config.env["GALAXY_CONFIG_FILE"] = server_ini config.env["GALAXY_TEST_VERBOSE_ERRORS"] = "true" config.env["GALAXY_TEST_SAVE"] = job_output_files cd_to_galaxy_command = "cd %s" % config.galaxy_root test_cmd = test_structures.GalaxyTestCommand( html_report_file, xunit_report_file, structured_report_file, failed=kwds.get("failed", False), installed=kwds.get("installed", False), ).build() setup_common_startup_args = "" if kwds.get("skip_venv", False): setup_common_startup_args = ( 'COMMON_STARTUP_ARGS=--skip-venv; ' 'export COMMON_STARTUP_ARGS; ' 'echo "Set COMMON_STARTUP_ARGS to ${COMMON_STARTUP_ARGS}"' ) setup_venv_command = setup_venv(ctx, kwds) cmd = shell_join( cd_to_galaxy_command, setup_common_startup_args, setup_venv_command, test_cmd, ) action = "Testing tools" return_code = run_galaxy_command( ctx, cmd, config.env, action ) if kwds.get('update_test_data', False): update_cp_args = (job_output_files, config.test_data_dir) shell('cp -r "%s"/* "%s"' % update_cp_args) if xunit_report_file and (not os.path.exists(xunit_report_file)): warn(NO_XUNIT_MESSAGE) xunit_report_file = None test_results = test_structures.GalaxyTestResults( structured_report_file, xunit_report_file, html_report_file, return_code, ) test_data = test_results.structured_data handle_reports(ctx, test_data, kwds) __handle_summary( test_results, **kwds ) return return_code
def run_in_config(ctx, config, **kwds): config_directory = config.config_directory html_report_file = kwds["test_output"] job_output_files = kwds.get("job_output_files", None) if job_output_files is None: job_output_files = os.path.join(config_directory, "jobfiles") xunit_supported, xunit_report_file = __xunit_state(kwds, config) structured_report_file = __structured_report_file(kwds, config) info("Testing using galaxy_root %s", config.galaxy_root) # TODO: Allow running dockerized Galaxy here instead. server_ini = os.path.join(config_directory, "galaxy.ini") config.env["GALAXY_CONFIG_FILE"] = server_ini config.env["GALAXY_TEST_VERBOSE_ERRORS"] = "true" config.env["GALAXY_TEST_SAVE"] = job_output_files cd_to_galaxy_command = "cd %s" % config.galaxy_root test_cmd = test_structures.GalaxyTestCommand( html_report_file, xunit_report_file, structured_report_file, failed=kwds.get("failed", False), installed=kwds.get("installed", False), ).build() setup_common_startup_args = galaxy_run.set_variable_if_wheels( "COMMON_STARTUP_ARGS", "--skip-venv --skip-common-startup" ) setup_venv_command = galaxy_run.setup_venv(ctx, kwds) cmd = shell_join( cd_to_galaxy_command, setup_common_startup_args, setup_venv_command, test_cmd, ) action = "Testing tools" return_code = galaxy_run.run_galaxy_command( ctx, cmd, config.env, action ) if kwds.get('update_test_data', False): update_cp_args = (job_output_files, config.test_data_dir) shell('cp -r "%s"/* "%s"' % update_cp_args) if xunit_report_file and (not os.path.exists(xunit_report_file)): warn(NO_XUNIT_MESSAGE) xunit_report_file = None test_results = test_structures.GalaxyTestResults( structured_report_file, xunit_report_file, html_report_file, return_code, ) try: test_data = test_results.structured_data if 'test_output' in kwds: output_path = kwds['test_output'] if output_path is not None: with open(output_path, 'w') as handle: handle.write(build_report.build_report(test_data)) for kw_name in ('markdown', 'text'): if 'test_output_%s' % kw_name in kwds: output_path = kwds['test_output_%s' % kw_name] if output_path is None: continue with open(output_path, 'w') as handle: handle.write(build_report.build_report(test_data, report_type=kw_name)) except Exception: ctx.vlog("Problem producing test output.", exception=True) __handle_summary( test_results, **kwds ) return return_code
import os import string from planemo.io import info, shell_join from planemo.virtualenv import create_command from galaxy.tools.deps.commands import shell # Activate galaxy's virtualenv if present (needed for tests say but not for # server because run.sh does this). ACTIVATE_COMMAND = "[ -e $GALAXY_VIRTUAL_ENV ] && . $GALAXY_VIRTUAL_ENV/bin/activate" CREATE_COMMAND_TEMPLATE = string.Template("if [ ! -e $GALAXY_VIRTUAL_ENV ]; then $create_virtualenv; fi") PRINT_VENV_COMMAND = shell_join( 'echo "Set \$GALAXY_VIRTUAL_ENV to $GALAXY_VIRTUAL_ENV"', "if [ -e $GALAXY_VIRTUAL_ENV ]", 'then echo "Virtual environment directory exists."', 'else echo "Virtual environment directory does not exist."', "fi", ) # TODO: Mac-y curl variant of this. DOWNLOAD_GALAXY = "wget https://codeload.github.com/galaxyproject/galaxy/tar.gz/dev" CACHED_VIRTUAL_ENV_COMMAND = ( "if [ -d .venv ] || [ -f dist-eggs.ini ];" " then GALAXY_VIRTUAL_ENV=.venv; " " else GALAXY_VIRTUAL_ENV=%s; fi" ) UNCACHED_VIRTUAL_ENV_COMMAND = "GALAXY_VIRTUAL_ENV=.venv" def setup_venv(ctx, kwds):