Exemplo n.º 1
0
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)
Exemplo n.º 2
0
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
Exemplo n.º 3
0
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,
    )

    test_data = test_results.structured_data
    handle_reports(ctx, test_data, kwds)
    __handle_summary(
        test_results,
        **kwds
    )

    return return_code
Exemplo n.º 4
0
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