コード例 #1
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.
        run_script = os.path.join(config.galaxy_root, "run.sh")
        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
        cmds = [
            run_script,
        ]
        cmd = "; ".join(cmds)
        action = "Starting galaxy"
        galaxy_run.run_galaxy_command(
            ctx,
            cmd,
            config.env,
            action,
        )
        return config
コード例 #2
0
ファイル: galaxy_serve.py プロジェクト: adefelicibus/planemo
def serve(ctx, path, **kwds):
    # TODO: Preceate a user.
    # TODO: Setup an admin user.
    # TODO: Pass through more parameters.
    # TODO: Populate test-data directory as FTP directory.
    with galaxy_config.galaxy_config(ctx, path, **kwds) as config:
        # TODO: Allow running dockerized Galaxy here instead.
        run_script = os.path.join(config.galaxy_root, "run.sh") + " --reload"
        server_ini = os.path.join(config.config_directory, "galaxy.ini")
        config.env["GALAXY_CONFIG_FILE"] = server_ini
        cmds = [
            run_script,
        ]
        cmd = "; ".join(cmds)
        action = "Starting galaxy"
        galaxy_run.run_galaxy_command(ctx, cmd, config.env, action)
コード例 #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()
    cmd = "; ".join([
        cd_to_galaxy_command,
        galaxy_run.ACTIVATE_COMMAND,  # TODO: this should be moved to
        # run_tests.sh to match run.sh.
        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
        new_report = build_report.build_report(test_data)
        open(test_results.output_html_path, "w").write(new_report)
    except Exception:
        pass

    __handle_summary(test_results, **kwds)

    return return_code
コード例 #4
0
ファイル: galaxy_serve.py プロジェクト: einon/planemo
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
コード例 #5
0
ファイル: actions.py プロジェクト: davebx/planemo
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()
    cmd = "; ".join([
        cd_to_galaxy_command,
        galaxy_run.ACTIVATE_COMMAND,  # TODO: this should be moved to
                                      # run_tests.sh to match run.sh.
        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
コード例 #6
0
ファイル: cmd_test.py プロジェクト: peterjc/planemo
def cli(ctx, path, **kwds):
    """Run the tests in the specified tool tests in a Galaxy instance.

    All referenced tools (by default all the tools in the current working
    directory) will be tested and the results quickly summarized.

    To run these tests planemo needs a Galaxy instance to utilize, planemo
    will search parent directories to see if any is a Galaxy instance
    - but one can pick the Galaxy instance to use with the --galaxy_root
    option or force planemo to download a disposable instance with the
    ``--install_galaxy`` flag.

    In additon to to quick summary printed to the console - various detailed
    output summaries can be configured. ``tool_test_output.html`` (settable
    via ``--test_output``) will contain a human consumable HTML report
    describing the test run. A JSON file (settable via ``--test_output_json``
    and defaulting to ``tool_test_output.json``) will also be created. These
    files can can be disabled by passing in empty arguments or globally by
    setting the values ``default_test_output`` and/or
    ``default_test_output_json`` in ``~/.planemo.yml`` to ``null``. For
    continuous integration testing a xUnit-style report can be confiured using
    the ``--test_output_xunit``.

    planemo uses temporarily generated config files and environment variables
    to attempt to shield this execution of Galaxy from manually launched runs
    against that same Galaxy root - but this may not be bullet proof yet so
    please careful and do not try this against production Galaxy instances.
    """
    for name, default in OUTPUT_DFEAULTS.items():
        __populate_default_output(ctx, name, kwds, default)

    kwds["for_tests"] = True
    with galaxy_config.galaxy_config(ctx, path, **kwds) as config:
        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
        cmd = "; ".join([
            cd_to_galaxy_command,
            galaxy_run.ACTIVATE_COMMAND,  # TODO: this should be moved to
                                          # run_tests.sh to match run.sh.
            __run_tests_cmd(
                html_report_file,
                xunit_report_file,
                structured_report_file,
            ),
        ])
        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 = galaxy_test.GalaxyTestResults(
            structured_report_file,
            xunit_report_file,
            html_report_file,
            return_code,
        )

        try:
            test_data = test_results.structured_data
            new_report = build_report.build_report(test_data)
            open(test_results.output_html_path, "w").write(new_report)
        except Exception:
            pass

        __handle_summary(
            test_results,
            **kwds
        )

        if return_code:
            sys.exit(1)
コード例 #7
0
def cli(ctx, path, **kwds):
    """Run the tests in the specified tool tests in a Galaxy instance.

    All referenced tools (by default all the tools in the current working
    directory) will be tested and the results quickly summarized.

    To run these tests planemo needs a Galaxy instance to utilize, planemo
    will search parent directories to see if any is a Galaxy instance
    - but one can pick the Galaxy instance to use with the --galaxy_root
    option or force planemo to download a disposable instance with the
    ``--install_galaxy`` flag.

    In additon to to quick summary printed to the console - various detailed
    output summaries can be configured. ``tool_test_output.html`` (settable
    via ``--test_output``) will contain a human consumable HTML report
    describing the test run. A JSON file (settable via ``--test_output_json``
    and defaulting to ``tool_test_output.json``) will also be created. These
    files can can be disabled by passing in empty arguments or globally by
    setting the values ``default_test_output`` and/or
    ``default_test_output_json`` in ``~/.planemo.yml`` to ``null``. For
    continuous integration testing a xUnit-style report can be confiured using
    the ``--test_output_xunit``.

    planemo uses temporarily generated config files and environment variables
    to attempt to shield this execution of Galaxy from manually launched runs
    against that same Galaxy root - but this may not be bullet proof yet so
    please careful and do not try this against production Galaxy instances.
    """
    for name, default in OUTPUT_DFEAULTS.items():
        __populate_default_output(ctx, name, kwds, default)

    kwds["for_tests"] = True
    with galaxy_config.galaxy_config(ctx, path, **kwds) as config:
        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
        cmd = "; ".join([
            cd_to_galaxy_command,
            galaxy_run.ACTIVATE_COMMAND,  # TODO: this should be moved to
            # run_tests.sh to match run.sh.
            __run_tests_cmd(
                html_report_file,
                xunit_report_file,
                structured_report_file,
            ),
        ])
        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 = galaxy_test.GalaxyTestResults(
            structured_report_file,
            xunit_report_file,
            html_report_file,
            return_code,
        )

        try:
            test_data = test_results.structured_data
            new_report = build_report.build_report(test_data)
            open(test_results.output_html_path, "w").write(new_report)
        except Exception:
            pass

        __handle_summary(test_results, **kwds)

        if return_code:
            sys.exit(1)
コード例 #8
0
ファイル: actions.py プロジェクト: einon/planemo
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