コード例 #1
0
ファイル: shed_tools.py プロジェクト: blankenberg/ephemeris
            def run_test(index, test_id):
                def register(job_data):
                    tool_test_results.append({
                        'id': test_id,
                        'has_data': True,
                        'data': job_data,
                    })

                try:
                    if log:
                        log.info("Executing test '%s'", test_id)
                    verify_tool(
                        tool_id,
                        galaxy_interactor,
                        test_index=index,
                        tool_version=tool_version,
                        register_job_data=register,
                        quiet=True,
                        test_history=test_history,
                    )
                    tests_passed.append(test_id)
                    if log:
                        log.info("Test '%s' passed", test_id)
                except Exception as e:
                    if log:
                        log.warning("Test '%s' failed", test_id, exc_info=True)
                    test_exceptions.append((test_id, e))
コード例 #2
0
    def do_it(self, tool_id=None, tool_version=None, test_index=0, resource_parameters={}):
        """
        Run through a tool test case.
        """
        if tool_id is None:
            tool_id = self.tool_id
        assert tool_id

        verify_tool(tool_id, self.galaxy_interactor, resource_parameters=resource_parameters, test_index=test_index, tool_version=tool_version, register_job_data=register_job_data)
コード例 #3
0
ファイル: test_toolbox.py プロジェクト: zero-raspberry/galaxy
    def do_it(self, tool_id=None, tool_version=None, test_index=0, resource_parameters={}):
        """
        Run through a tool test case.
        """
        if tool_id is None:
            tool_id = self.tool_id
        assert tool_id

        verify_tool(tool_id, self.galaxy_interactor, resource_parameters=resource_parameters, test_index=test_index, tool_version=tool_version, register_job_data=register_job_data)
コード例 #4
0
 def run_tool_test(self, tool_id, index=0, resource_parameters={}):
     host, port, url = target_url_parts()
     galaxy_interactor_kwds = {
         "galaxy_url": url,
         "master_api_key": get_master_api_key(),
         "api_key": get_user_api_key(),
         "keep_outputs_dir": None,
     }
     galaxy_interactor = GalaxyInteractorApi(**galaxy_interactor_kwds)
     verify_tool(tool_id=tool_id,
                 test_index=index,
                 galaxy_interactor=galaxy_interactor,
                 resource_parameters=resource_parameters)
コード例 #5
0
    def _test_tool(self, tool, test_user, test_user_api_key):

        if test_user_api_key is None:
            whoami = self.gi.make_get_request(self.gi.url + "/whoami").json()
            if whoami is not None:
                test_user_api_key = self.gi.key
        galaxy_interactor_kwds = {
            "galaxy_url": re.sub('/api', '', self.gi.url),
            "master_api_key": self.gi.key,
            "api_key": None,  # TODO
            "keep_outputs_dir": '',
        }
        if test_user_api_key is None:
            galaxy_interactor_kwds["test_user"] = test_user
        galaxy_interactor = GalaxyInteractorApi(**galaxy_interactor_kwds)
        tool_id = tool["id"]
        tool_version = tool["version"]
        tool_test_dicts = galaxy_interactor.get_tool_tests(
            tool_id, tool_version=tool_version)
        test_indices = list(range(len(tool_test_dicts)))
        tool_test_results = []
        tests_passed = []
        test_exceptions = []

        for test_index in test_indices:
            test_id = tool_id + "-" + str(test_index)

            def register(job_data):
                tool_test_results.append({
                    'id': test_id,
                    'has_data': True,
                    'data': job_data,
                })

            try:
                verify_tool(tool_id,
                            galaxy_interactor,
                            test_index=test_index,
                            tool_version=tool_version,
                            register_job_data=register,
                            quiet=True)
                tests_passed.append(test_id)
            except Exception as e:
                test_exceptions.append((test_id, e))
        Results = namedtuple(
            "Results",
            ["tool_test_results", "tests_passed", "test_exceptions"])
        return Results(tool_test_results=tool_test_results,
                       tests_passed=tests_passed,
                       test_exceptions=test_exceptions)
コード例 #6
0
 def run_tool_test(self, tool_id, index=0, resource_parameters={}):
     host, port, url = target_url_parts()
     galaxy_interactor_kwds = {
         "galaxy_url": url,
         "master_api_key": get_master_api_key(),
         "api_key": get_user_api_key(),
         "keep_outputs_dir": None,
     }
     galaxy_interactor = GalaxyInteractorApi(**galaxy_interactor_kwds)
     verify_tool(
         tool_id=tool_id,
         test_index=index,
         galaxy_interactor=galaxy_interactor,
         resource_parameters=resource_parameters
     )
コード例 #7
0
    def _run_test_case(self, test_case):
        if hasattr(test_case, "job_path"):
            # Simple file-based job path.
            return super(GalaxyEngine, self)._run_test_case(test_case)
        else:
            with self.ensure_runnables_served([test_case.runnable]) as config:
                galaxy_interactor_kwds = {
                    "galaxy_url": config.galaxy_url,
                    "master_api_key": config.master_api_key,
                    "api_key": config.user_api_key,
                    "keep_outputs_dir": "",  # TODO: this...
                }
                tool_id = test_case.tool_id
                test_index = test_case.test_index
                tool_version = test_case.tool_version
                galaxy_interactor = interactor.GalaxyInteractorApi(
                    **galaxy_interactor_kwds)

                test_results = []

                def _register_job_data(job_data):
                    test_results.append({
                        'id': tool_id + "-" + str(test_index),
                        'has_data': True,
                        'data': job_data,
                    })

                verbose = self._ctx.verbose
                try:
                    if verbose:
                        # TODO: this is pretty hacky, it'd be better to send a stream
                        # and capture the output information somehow.
                        interactor.VERBOSE_GALAXY_ERRORS = True

                    interactor.verify_tool(
                        tool_id,
                        galaxy_interactor,
                        test_index=test_index,
                        tool_version=tool_version,
                        register_job_data=_register_job_data,
                        quiet=not verbose,
                    )
                except Exception:
                    pass

                return test_results[0]
コード例 #8
0
ファイル: galaxy.py プロジェクト: galaxyproject/planemo
    def _run_test_case(self, test_case):
        if hasattr(test_case, "job_path"):
            # Simple file-based job path.
            return super(GalaxyEngine, self)._run_test_case(test_case)
        else:
            with self.ensure_runnables_served([test_case.runnable]) as config:
                galaxy_interactor_kwds = {
                    "galaxy_url": config.galaxy_url,
                    "master_api_key": config.master_api_key,
                    "api_key": config.user_api_key,
                    "keep_outputs_dir": "",  # TODO: this...
                }
                tool_id = test_case.tool_id
                test_index = test_case.test_index
                tool_version = test_case.tool_version
                galaxy_interactor = interactor.GalaxyInteractorApi(**galaxy_interactor_kwds)

                test_results = []

                def _register_job_data(job_data):
                    test_results.append({
                        'id': tool_id + "-" + str(test_index),
                        'has_data': True,
                        'data': job_data,
                    })

                verbose = self._ctx.verbose
                try:
                    if verbose:
                        # TODO: this is pretty hacky, it'd be better to send a stream
                        # and capture the output information somehow.
                        interactor.VERBOSE_GALAXY_ERRORS = True

                    interactor.verify_tool(
                        tool_id,
                        galaxy_interactor,
                        test_index=test_index,
                        tool_version=tool_version,
                        register_job_data=_register_job_data,
                        quiet=not verbose,
                    )
                except Exception:
                    pass

                return test_results[0]
def main(argv=None):
    if argv is None:
        argv = sys.argv[1:]

    args = _arg_parser().parse_args(argv)
    galaxy_interactor_kwds = {
        "galaxy_url": args.galaxy_url,
        "master_api_key": args.admin_key,
        "api_key": args.key,
        "keep_outputs_dir": args.output,
    }
    tool_id = args.tool_id
    tool_version = args.tool_version

    galaxy_interactor = GalaxyInteractorApi(**galaxy_interactor_kwds)
    raw_test_index = args.test_index
    if raw_test_index == ALL_TESTS:
        tool_test_dicts = galaxy_interactor.get_tool_tests(
            tool_id, tool_version=tool_version)
        test_indices = list(range(len(tool_test_dicts)))
    else:
        test_indices = [int(raw_test_index)]

    test_results = []

    if args.append:
        with open(args.output_json, "r") as f:
            previous_results = json.load(f)
            test_results = previous_results["tests"]

    exceptions = []
    verbose = args.verbose
    for test_index in test_indices:
        if tool_version:
            tool_id_and_version = "%s/%s" % (tool_id, tool_version)
        else:
            tool_id_and_version = tool_id

        test_identifier = "tool %s test # %d" % (tool_id_and_version,
                                                 test_index)

        def register(job_data):
            test_results.append({
                'id': tool_id + "-" + str(test_index),
                'has_data': True,
                'data': job_data,
            })

        try:
            verify_tool(tool_id,
                        galaxy_interactor,
                        test_index=test_index,
                        tool_version=tool_version,
                        register_job_data=register,
                        quiet=not verbose,
                        force_path_paste=args.force_path_paste)

            if verbose:
                print("%s passed" % test_identifier)

        except Exception as e:
            if verbose:
                print("%s failed, %s" % (test_identifier, e))
            exceptions.append(e)

    report_obj = {
        'version': '0.1',
        'tests': test_results,
    }
    output_json = args.output_json
    if output_json:
        if args.output_json == "-":
            assert not args.append
            print(json.dumps(report_obj))
        else:
            with open(args.output_json, "w") as f:
                json.dump(report_obj, f)

    if exceptions:
        raise exceptions[0]
コード例 #10
0
ファイル: script.py プロジェクト: ImmPortDB/immport-galaxy
def main(argv=None):
    if argv is None:
        argv = sys.argv[1:]

    args = _arg_parser().parse_args(argv)
    galaxy_interactor_kwds = {
        "galaxy_url": args.galaxy_url,
        "master_api_key": args.admin_key,
        "api_key": args.key,
        "keep_outputs_dir": args.output,
    }
    tool_id = args.tool_id
    tool_version = args.tool_version

    galaxy_interactor = GalaxyInteractorApi(**galaxy_interactor_kwds)
    raw_test_index = args.test_index
    if raw_test_index == ALL_TESTS:
        tool_test_dicts = galaxy_interactor.get_tool_tests(tool_id, tool_version=tool_version)
        test_indices = list(range(len(tool_test_dicts)))
    else:
        test_indices = [int(raw_test_index)]

    test_results = []

    if args.append:
        with open(args.output_json, "r") as f:
            previous_results = json.load(f)
            test_results = previous_results["tests"]

    exceptions = []
    verbose = args.verbose
    for test_index in test_indices:
        if tool_version:
            tool_id_and_version = "%s/%s" % (tool_id, tool_version)
        else:
            tool_id_and_version = tool_id

        test_identifier = "tool %s test # %d" % (tool_id_and_version, test_index)

        def register(job_data):
            test_results.append({
                'id': tool_id + "-" + str(test_index),
                'has_data': True,
                'data': job_data,
            })

        try:
            verify_tool(
                tool_id, galaxy_interactor, test_index=test_index, tool_version=tool_version,
                register_job_data=register, quiet=not verbose
            )

            if verbose:
                print("%s passed" % test_identifier)

        except Exception as e:
            if verbose:
                print("%s failed, %s" % (test_identifier, e))
            exceptions.append(e)

    report_obj = {
        'version': '0.1',
        'tests': test_results,
    }
    output_json = args.output_json
    if output_json:
        if args.output_json == "-":
            assert not args.append
            print(json.dumps(report_obj))
        else:
            with open(args.output_json, "w") as f:
                json.dump(report_obj, f)

    if exceptions:
        raise exceptions[0]