def test_serve_daemon(self): port = network_util.get_free_port() pid_file = os.path.join(self._home, "test.pid") extra_args = ["--daemon", "--pid_file", pid_file] serve = functools.partial(self._run, port, extra_args) self._launch_thread_and_wait(serve, port) admin_gi = api.gi(port) user_api_key = api.user_api_key(admin_gi) user_gi = api.gi(port, user_api_key) assert len(user_gi.histories.get_histories(name=TEST_HISTORY_NAME)) == 0 user_gi.histories.create_history(TEST_HISTORY_NAME)
def test_serve_daemon(self): port = network_util.get_free_port() pid_file = os.path.join(self._home, "test.pid") extra_args = ["--daemon", "--pid_file", pid_file] serve = functools.partial(self._run, port, extra_args) self._launch_thread_and_wait(serve, port) admin_gi = api.gi(port) user_api_key = api.user_api_key(admin_gi) user_gi = api.gi(port, user_api_key) assert len( user_gi.histories.get_histories(name=TEST_HISTORY_NAME)) == 0 user_gi.histories.create_history(TEST_HISTORY_NAME)
def _job_outputs_template_from_invocation(invocation_id, galaxy_url, galaxy_api_key): user_gi = gi(url=galaxy_url, key=galaxy_api_key) invocation = user_gi.invocations.show_invocation(invocation_id) outputs = {} for label, output in invocation["outputs"].items(): ext = user_gi.datasets.show_dataset(output["id"])["extension"] user_gi.datasets.download_dataset(output["id"], use_default_filename=False, file_path=f"test-data/{label}.{ext}") outputs[label] = {'file': f"test-data/{label}.{ext}"} for label, output in invocation["output_collections"].items(): collection = user_gi.dataset_collections.show_dataset_collection( output['id']) if ':' not in collection["collection_type"]: user_gi.datasets.download_dataset( collection["elements"][0]["object"]["id"], use_default_filename=False, file_path= f"test-data/{label}.{collection['elements'][0].get('extension', 'txt')}" ) outputs[label] = { 'element_tests': { # only check the first element collection["elements"][0]["element_identifier"]: f"test-data/{label}.{collection['elements'][0]['extension']}" } } else: outputs[label] = {'element_tests': 'nested_collection_todo'} return outputs
def _job_inputs_template_from_invocation(invocation_id, galaxy_url, galaxy_api_key): def _template_from_collection(user_gi, collection_id): collection = user_gi.dataset_collections.show_dataset_collection( collection_id) template = { "class": "Collection", "collection_type": collection["collection_type"], "elements": [] } for element in collection["elements"]: if element["element_type"] == "hdca": template['elements'].append( _template_from_collection(element["object"]["id"])) elif element["element_type"] == "hda": user_gi.datasets.download_dataset( element["object"]["id"], use_default_filename=False, file_path= f"test-data/{input_step['label']}_{element['element_identifier']}.{ext}" ) template['elements'].append({ "class": "File", "identifier": element['element_identifier'], "path": f"test-data/{input_step['label']}_{element['element_identifier']}.{ext}", }) return template user_gi = gi(url=galaxy_url, key=galaxy_api_key) invocation = user_gi.invocations.show_invocation(invocation_id) template = {} for input_step in invocation['inputs'].values(): if input_step["src"] == "hda": ext = user_gi.datasets.show_dataset(input_step["id"])["extension"] user_gi.datasets.download_dataset( input_step["id"], use_default_filename=False, file_path=f"test-data/{input_step['label']}.{ext}") template[input_step['label']] = { "class": "File", "path": f"test-data/{input_step['label']}.{ext}", "filetype": ext } elif input_step["src"] == "hdca": template[input_step['label']] = _template_from_collection( user_gi, input_step["id"]) for param, param_step in invocation['input_step_parameters'].items(): template[param] = param_step["parameter_value"] return template
def get_workflow_from_invocation_id(invocation_id, galaxy_url, galaxy_api_key): user_gi = gi(url=galaxy_url, key=galaxy_api_key) workflow_id = user_gi.invocations.show_invocation( invocation_id)['workflow_id'] workflow = user_gi.workflows._get(workflow_id, params={'instance': 'true'}) workflow_name = '-'.join(workflow["name"].split()) user_gi.workflows.export_workflow_to_local_path( use_default_filename=False, file_local_path=f'./{workflow_name}.ga', workflow_id=workflow["id"]) return workflow_name
def _user_gi(self): admin_gi = api.gi(self._port) user_api_key = api.user_api_key(admin_gi) user_gi = api.gi(self._port, key=user_api_key) return user_gi