本文整理汇总了Python中base.populators.DatasetPopulator类的典型用法代码示例。如果您正苦于以下问题:Python DatasetPopulator类的具体用法?Python DatasetPopulator怎么用?Python DatasetPopulator使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了DatasetPopulator类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: MaximumWorkflowInvocationDurationTestCase
class MaximumWorkflowInvocationDurationTestCase(integration_util.IntegrationTestCase):
framework_tool_and_types = True
def setUp(self):
super(MaximumWorkflowInvocationDurationTestCase, self).setUp()
self.dataset_populator = DatasetPopulator(self.galaxy_interactor)
self.workflow_populator = WorkflowPopulator(self.galaxy_interactor)
@classmethod
def handle_galaxy_config_kwds(cls, config):
config["maximum_workflow_invocation_duration"] = 20
def do_test(self):
workflow = self.workflow_populator.load_workflow_from_resource("test_workflow_pause")
workflow_id = self.workflow_populator.create_workflow(workflow)
history_id = self.dataset_populator.new_history()
hda1 = self.dataset_populator.new_dataset(history_id, content="1 2 3")
index_map = {
'0': dict(src="hda", id=hda1["id"])
}
request = {}
request["history"] = "hist_id=%s" % history_id
request["inputs"] = dumps(index_map)
request["inputs_by"] = 'step_index'
url = "workflows/%s/invocations" % (workflow_id)
invocation_response = self._post(url, data=request)
invocation_url = url + "/" + invocation_response.json()["id"]
time.sleep(5)
state = self._get(invocation_url).json()["state"]
assert state != "failed", state
time.sleep(35)
state = self._get(invocation_url).json()["state"]
assert state == "failed", state
示例2: JobRecoveryAfterHandledIntegerationTestCase
class JobRecoveryAfterHandledIntegerationTestCase(integration_util.IntegrationTestCase):
framework_tool_and_types = True
def setUp(self):
super(JobRecoveryAfterHandledIntegerationTestCase, self).setUp()
self.dataset_populator = DatasetPopulator(self.galaxy_interactor)
@classmethod
def handle_galaxy_config_kwds(cls, config):
config["job_config_file"] = DELAY_JOB_CONFIG_FILE
def handle_reconfigure_galaxy_config_kwds(self, config):
config["job_config_file"] = SIMPLE_JOB_CONFIG_FILE
def test_recovery(self):
history_id = self.dataset_populator.new_history()
self.dataset_populator.run_tool(
"exit_code_oom",
{},
history_id,
assert_ok=False,
).json()
self.restart(handle_reconfig=self.handle_reconfigure_galaxy_config_kwds)
self.dataset_populator = DatasetPopulator(self.galaxy_interactor)
self.dataset_populator.wait_for_history(history_id, assert_ok=True)
示例3: TestProvenance
class TestProvenance(api.ApiTestCase):
def setUp(self):
super(TestProvenance, self).setUp()
self.dataset_populator = DatasetPopulator(self.galaxy_interactor)
def test_show_prov(self):
history_id = self.dataset_populator.new_history()
new_dataset1 = self.dataset_populator.new_dataset(history_id, content='for prov')
prov_response = self._get("histories/%s/contents/%s/provenance" % (history_id, new_dataset1["id"]))
self._assert_status_code_is(prov_response, 200)
self._assert_has_keys(prov_response.json(), "job_id", "id", "stdout", "stderr", "parameters", "tool_id")
示例4: BaseUploadContentConfigurationTestCase
class BaseUploadContentConfigurationTestCase(integration_util.IntegrationTestCase):
framework_tool_and_types = True
def setUp(self):
super(BaseUploadContentConfigurationTestCase, self).setUp()
self.dataset_populator = DatasetPopulator(self.galaxy_interactor)
self.library_populator = LibraryPopulator(self.galaxy_interactor)
self.history_id = self.dataset_populator.new_history()
示例5: test_legacy_r_mapping
def test_legacy_r_mapping(self):
"""
"""
tool_id = "legacy_R"
dataset_populator = DatasetPopulator(self.galaxy_interactor)
history_id = dataset_populator.new_history()
endpoint = "tools/%s/install_dependencies" % tool_id
data = {'id': tool_id}
create_response = self._post(endpoint, data=data, admin=True)
self._assert_status_code_is(create_response, 200)
payload = dataset_populator.run_tool_payload(
tool_id=tool_id,
inputs={},
history_id=history_id,
)
create_response = self._post("tools", data=payload)
self._assert_status_code_is(create_response, 200)
dataset_populator.wait_for_history(history_id, assert_ok=True)
示例6: BaseWorkflowHandlerConfigurationTestCase
class BaseWorkflowHandlerConfigurationTestCase(integration_util.IntegrationTestCase):
framework_tool_and_types = True
def setUp(self):
super(BaseWorkflowHandlerConfigurationTestCase, self).setUp()
self.dataset_populator = DatasetPopulator(self.galaxy_interactor)
self.workflow_populator = WorkflowPopulator(self.galaxy_interactor)
self.history_id = self.dataset_populator.new_history()
@classmethod
def handle_galaxy_config_kwds(cls, config):
config["job_config_file"] = WORKFLOW_HANDLER_CONFIGURATION_JOB_CONF
def _invoke_n_workflows(self, n):
workflow_id = self.workflow_populator.upload_yaml_workflow(PAUSE_WORKFLOW)
history_id = self.history_id
hda1 = self.dataset_populator.new_dataset(history_id, content="1 2 3")
index_map = {
'0': dict(src="hda", id=hda1["id"])
}
request = {}
request["history"] = "hist_id=%s" % history_id
request["inputs"] = dumps(index_map)
request["inputs_by"] = 'step_index'
url = "workflows/%s/invocations" % (workflow_id)
for i in range(n):
self._post(url, data=request)
def _get_workflow_invocations(self):
# Consider exposing handler via the API to reduce breaking
# into Galaxy's internal state.
app = self._app
history_id = app.security.decode_id(self.history_id)
sa_session = app.model.context.current
history = sa_session.query(app.model.History).get(history_id)
workflow_invocations = history.workflow_invocations
return workflow_invocations
@property
def is_app_workflow_scheduler(self):
return self._app.workflow_scheduling_manager.request_monitor is not None
示例7: test_recovery
def test_recovery(self):
history_id = self.dataset_populator.new_history()
self.dataset_populator.run_tool(
"exit_code_oom",
{},
history_id,
assert_ok=False,
).json()
self.restart(handle_reconfig=self.handle_reconfigure_galaxy_config_kwds)
self.dataset_populator = DatasetPopulator(self.galaxy_interactor)
self.dataset_populator.wait_for_history(history_id, assert_ok=True)
示例8: BaseUploadContentConfigurationTestCase
class BaseUploadContentConfigurationTestCase(integration_util.IntegrationTestCase):
framework_tool_and_types = True
def setUp(self):
super(BaseUploadContentConfigurationTestCase, self).setUp()
self.dataset_populator = DatasetPopulator(self.galaxy_interactor)
self.library_populator = LibraryPopulator(self.galaxy_interactor)
self.history_id = self.dataset_populator.new_history()
def fetch_target(self, target, assert_ok=False, attach_test_file=False):
payload = {
"history_id": self.history_id,
"targets": json.dumps([target]),
}
if attach_test_file:
payload["__files"] = {"files_0|file_data": open(self.test_data_resolver.get_filename("4.bed"))}
response = self.dataset_populator.fetch(payload, assert_ok=assert_ok)
return response
@classmethod
def temp_config_dir(cls, name):
# realpath here to get around problems with symlinks being blocked.
return os.path.realpath(os.path.join(cls._test_driver.galaxy_test_tmp_dir, name))
def _write_file(self, dir_path, content, filename="test"):
"""Helper for writing ftp/server dir files."""
self._ensure_directory(dir_path)
path = os.path.join(dir_path, filename)
with open(path, "w") as f:
f.write(content)
return path
def _ensure_directory(self, path):
if not os.path.exists(path):
os.makedirs(path)
示例9: ObjectStoreJobsIntegrationTestCase
class ObjectStoreJobsIntegrationTestCase(integration_util.IntegrationTestCase):
framework_tool_and_types = True
@classmethod
def handle_galaxy_config_kwds(cls, config):
temp_directory = cls._test_driver.mkdtemp()
cls.object_stores_parent = temp_directory
for disk_store_file_name in ["files1", "files2", "files3"]:
disk_store_path = os.path.join(temp_directory, disk_store_file_name)
os.makedirs(disk_store_path)
setattr(cls, "%s_path" % disk_store_file_name, disk_store_path)
config_path = os.path.join(temp_directory, "object_store_conf.xml")
with open(config_path, "w") as f:
f.write(DISTRIBUTED_OBJECT_STORE_CONFIG_TEMPLATE.safe_substitute({"temp_directory": temp_directory}))
config["object_store_config_file"] = config_path
def setUp(self):
super(ObjectStoreJobsIntegrationTestCase, self).setUp()
self.dataset_populator = DatasetPopulator(self.galaxy_interactor)
def test_tool_simple_constructs(self):
with self.dataset_populator.test_history() as history_id:
hda1 = self.dataset_populator.new_dataset(history_id, content="1 2 3")
create_10_inputs = {
"input1": {"src": "hda", "id": hda1["id"]},
"input2": {"src": "hda", "id": hda1["id"]},
}
self.dataset_populator.run_tool(
"create_10",
create_10_inputs,
history_id,
assert_ok=True,
)
self.dataset_populator.wait_for_history(history_id)
files_1_count = _files_count(self.files1_path)
files_2_count = _files_count(self.files2_path)
files_3_count = _files_count(self.files3_path)
# Ensure no files written to the secondary/inactive hierarchical disk store.
assert files_3_count == 0
# Ensure the 10 inputs were written to one of the distributed object store's disk
# stores (it will have either 10 or 11 depeending on whether the input was also
# written there. The other disk store may or may not have the input file so should
# have at most one file.
assert (files_1_count >= 10) or (files_2_count >= 10)
assert (files_1_count <= 1) or (files_2_count <= 1)
# Other sanity checks on the test - just make sure the test was setup as intended
# and not actually testing object store behavior.
assert (files_1_count <= 11) and (files_2_count <= 11)
assert (files_1_count >= 0) and (files_2_count >= 0)
示例10: DataManagerIntegrationTestCase
class DataManagerIntegrationTestCase(integration_util.IntegrationTestCase, UsesShed):
"""Test data manager installation and table reload through the API"""
framework_tool_and_types = True
def setUp(self):
super(DataManagerIntegrationTestCase, self).setUp()
self.dataset_populator = DatasetPopulator(self.galaxy_interactor)
@classmethod
def handle_galaxy_config_kwds(cls, config):
try:
import watchdog # noqa: F401
except ImportError:
raise SkipTest("watchdog library is not available")
cls.configure_shed_and_conda(config)
config["tool_data_path"] = cls.shed_tool_data_dir
config["watch_tool_data_dir"] = True
cls.username = cls.get_secure_ascii_digits()
config["admin_users"] = "%[email protected]" % cls.username
def test_data_manager_installation_table_reload(self):
"""
Test that we can install data managers, create a new dbkey, and use that dbkey in a downstream data manager.
"""
self.install_repository("devteam", "data_manager_fetch_genome_dbkeys_all_fasta", "b1bc53e9bbc5")
self.install_repository("devteam", "data_manager_sam_fasta_index_builder", "1865e693d8b2")
with self._different_user(email="%[email protected]" % self.username):
with self.dataset_populator.test_history() as history_id:
run_response = self.dataset_populator.run_tool(tool_id=FETCH_TOOL_ID,
inputs=FETCH_GENOME_DBKEYS_ALL_FASTA_INPUT,
history_id=history_id,
assert_ok=False)
self.dataset_populator.wait_for_tool_run(history_id=history_id, run_response=run_response, timeout=CONDA_AUTO_INSTALL_JOB_TIMEOUT)
run_response = self.dataset_populator.run_tool(tool_id=SAM_FASTA_ID,
inputs=SAM_FASTA_INPUT,
history_id=history_id,
assert_ok=False)
self.dataset_populator.wait_for_tool_run(history_id=history_id, run_response=run_response, timeout=CONDA_AUTO_INSTALL_JOB_TIMEOUT)
@classmethod
def get_secure_ascii_digits(cls, n=12):
return ''.join(random.SystemRandom().choice(string.ascii_lowercase + string.digits) for _ in range(12))
示例11: test_runs_on_mule
def test_runs_on_mule(self):
tool_id = 'config_vars'
expect_server_name = self.expected_server_name
dataset_populator = DatasetPopulator(self.galaxy_interactor)
history_id = dataset_populator.new_history()
payload = dataset_populator.run_tool(
tool_id=tool_id,
inputs={'var': 'server_name'},
history_id=history_id,
)
dataset_id = payload['outputs'][0]['id']
dataset_populator.wait_for_dataset(history_id, dataset_id, assert_ok=True)
output = dataset_populator.get_history_dataset_content(history_id, dataset_id=dataset_id).strip()
assert output.startswith(expect_server_name), (
"Job handler's server name '{output}' does not start with expected string '{expected}'".format(
output=output,
expected=expect_server_name,
)
)
示例12: MaximumWorkflowJobsPerSchedulingIterationTestCase
class MaximumWorkflowJobsPerSchedulingIterationTestCase(integration_util.IntegrationTestCase):
framework_tool_and_types = True
def setUp(self):
super(MaximumWorkflowJobsPerSchedulingIterationTestCase, self).setUp()
self.dataset_populator = DatasetPopulator(self.galaxy_interactor)
self.workflow_populator = WorkflowPopulator(self.galaxy_interactor)
self.dataset_collection_populator = DatasetCollectionPopulator(self.galaxy_interactor)
@classmethod
def handle_galaxy_config_kwds(cls, config):
config["maximum_workflow_jobs_per_scheduling_iteration"] = 1
def do_test(self):
workflow_id = self.workflow_populator.upload_yaml_workflow("""
class: GalaxyWorkflow
steps:
- type: input_collection
- tool_id: collection_creates_pair
state:
input1:
$link: 0
- tool_id: collection_paired_test
state:
f1:
$link: 1#paired_output
- tool_id: cat_list
state:
input1:
$link: 2#out1
""")
with self.dataset_populator.test_history() as history_id:
hdca1 = self.dataset_collection_populator.create_list_in_history(history_id, contents=["a\nb\nc\nd\n", "e\nf\ng\nh\n"]).json()
self.dataset_populator.wait_for_history(history_id, assert_ok=True)
inputs = {
'0': {"src": "hdca", "id": hdca1["id"]},
}
invocation_id = self.workflow_populator.invoke_workflow(history_id, workflow_id, inputs)
self.workflow_populator.wait_for_workflow(history_id, workflow_id, invocation_id)
self.dataset_populator.wait_for_history(history_id, assert_ok=True)
self.assertEqual("a\nc\nb\nd\ne\ng\nf\nh\n", self.dataset_populator.get_history_dataset_content(history_id, hid=0))
示例13: setUp
def setUp(self):
super(RolesApiTestCase, self).setUp()
self.dataset_populator = DatasetPopulator(self.galaxy_interactor)
示例14: setUp
def setUp(self):
super(BaseWorkflowHandlerConfigurationTestCase, self).setUp()
self.dataset_populator = DatasetPopulator(self.galaxy_interactor)
self.workflow_populator = WorkflowPopulator(self.galaxy_interactor)
self.history_id = self.dataset_populator.new_history()
示例15: RolesApiTestCase
class RolesApiTestCase(api.ApiTestCase):
def setUp(self):
super(RolesApiTestCase, self).setUp()
self.dataset_populator = DatasetPopulator(self.galaxy_interactor)
def test_list_and_show(self):
def check_roles_response(response):
assert response.status_code == 200
as_list = response.json()
assert isinstance(as_list, list)
assert len(as_list) > 0
for role in as_list:
RolesApiTestCase.check_role_dict(role)
user_role_id = self.dataset_populator.user_private_role_id()
with self._different_user():
different_user_role_id = self.dataset_populator.user_private_role_id()
admin_roles_response = self._get("roles", admin=True)
user_roles_response = self._get("roles")
check_roles_response(admin_roles_response)
check_roles_response(user_roles_response)
admin_roles_response_ids = [r["id"] for r in admin_roles_response.json()]
user_roles_response_ids = [r["id"] for r in user_roles_response.json()]
# User can see their own private role not the other users, admin can see both.
assert user_role_id in user_roles_response_ids
assert different_user_role_id not in user_roles_response_ids
assert user_role_id in admin_roles_response_ids
assert different_user_role_id in admin_roles_response_ids
# Check showing a valid, role.
role_response = self._get("roles/%s" % user_role_id)
assert role_response.status_code == 200
role = role_response.json()
RolesApiTestCase.check_role_dict(role, assert_id=user_role_id)
def test_create_valid(self):
name = self.dataset_populator.get_random_name()
description = "A test role."
payload = {
"name": name,
"description": description,
"user_ids": json.dumps([self.dataset_populator.user_id()]),
}
response = self._post("roles", payload, admin=True)
assert_status_code_is(response, 200)
# TODO: Why does this return a singleton list - that is bad - should be deprecated
# and return a single role.
role = response.json()[0]
RolesApiTestCase.check_role_dict(role)
assert role["name"] == name
assert role["description"] == description
user_roles_response = self._get("roles")
with self._different_user():
different_user_roles_response = self._get("roles")
user_roles_response_ids = [r["id"] for r in user_roles_response.json()]
different_user_roles_response_ids = [r["id"] for r in different_user_roles_response.json()]
# This new role is public, all users see it.
assert role["id"] in user_roles_response_ids
assert role["id"] in different_user_roles_response_ids
def test_show_error_codes(self):
# Bad role ids are 400.
response = self._get("roles/badroleid")
assert_status_code_is(response, 400)
# Trying to access roles are errors - should probably be 403 not 400 though?
with self._different_user():
different_user_role_id = self.dataset_populator.user_private_role_id()
response = self._get("roles/%s" % different_user_role_id)
assert_status_code_is(response, 400)
def test_create_only_admin(self):
response = self._post("roles")
assert_status_code_is(response, 403)
@staticmethod
def check_role_dict(role_dict, assert_id=None):
assert_has_keys(role_dict, "id", "name", "model_class", "url")
assert role_dict["model_class"] == "Role"
if assert_id is not None:
assert role_dict["id"] == assert_id