Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
def _create_pair_in_history(self, history_id):
dataset1_id = self._test_dataset(history_id)
dataset2_id = self._test_dataset(history_id)
collection_response = self.gi.histories.create_dataset_collection(
history_id=history_id,
collection_description=dataset_collections.CollectionDescription(
name="MyTestPair",
type="paired",
elements=[
dataset_collections.HistoryDatasetElement(name="forward", id=dataset1_id),
dataset_collections.HistoryDatasetElement(name="reverse", id=dataset2_id),
]
)
)
return collection_response
def _create_pair_in_history(self, history_id):
dataset1_id = self._test_dataset(history_id)
dataset2_id = self._test_dataset(history_id)
collection_response = self.gi.histories.create_dataset_collection(
history_id=history_id,
collection_description=dataset_collections.CollectionDescription(
name="MyTestPair",
type="paired",
elements=[
dataset_collections.HistoryDatasetElement(name="forward", id=dataset1_id),
dataset_collections.HistoryDatasetElement(name="reverse", id=dataset2_id),
]
)
)
return collection_response
def _create_pair_in_history(self, history_id):
dataset1_id = self._test_dataset(history_id)
dataset2_id = self._test_dataset(history_id)
collection_response = self.gi.histories.create_dataset_collection(
history_id=history_id,
collection_description=collections.CollectionDescription(
name="MyTestPair",
type="paired",
elements=[
collections.HistoryDatasetElement(name="forward", id=dataset1_id),
collections.HistoryDatasetElement(name="reverse", id=dataset2_id),
]
)
)
return collection_response
def _create_pair_in_history(self, history_id):
dataset1_id = self._test_dataset(history_id)
dataset2_id = self._test_dataset(history_id)
collection_response = self.gi.histories.create_dataset_collection(
history_id=history_id,
collection_description=collections.CollectionDescription(
name="MyTestPair",
type="paired",
elements=[
collections.HistoryDatasetElement(name="forward", id=dataset1_id),
collections.HistoryDatasetElement(name="reverse", id=dataset2_id),
]
)
)
return collection_response
def test_create_list_of_paired_datasets_in_history(self):
history_id = self.gi.histories.create_history(name="TestDSListCreate")["id"]
dataset1_id = self._test_dataset(history_id)
dataset2_id = self._test_dataset(history_id)
dataset3_id = self._test_dataset(history_id)
dataset4_id = self._test_dataset(history_id)
collection_response = self.gi.histories.create_dataset_collection(
history_id=history_id,
collection_description=dataset_collections.CollectionDescription(
name="MyListOfPairedDatasets",
type="list:paired",
elements=[
dataset_collections.CollectionElement(
name="sample1",
type="paired",
elements=[
dataset_collections.HistoryDatasetElement(name="forward", id=dataset1_id),
dataset_collections.HistoryDatasetElement(name="reverse", id=dataset2_id),
]
),
dataset_collections.CollectionElement(
name="sample2",
type="paired",
elements=[
dataset_collections.HistoryDatasetElement(name="forward", id=dataset3_id),
def test_create_list_in_history(self):
history_id = self.gi.histories.create_history(name="TestDSListCreate")["id"]
dataset1_id = self._test_dataset(history_id)
dataset2_id = self._test_dataset(history_id)
dataset3_id = self._test_dataset(history_id)
collection_response = self.gi.histories.create_dataset_collection(
history_id=history_id,
collection_description=collections.CollectionDescription(
name="MyDatasetList",
elements=[
collections.HistoryDatasetElement(name="sample1", id=dataset1_id),
collections.HistoryDatasetElement(name="sample2", id=dataset2_id),
collections.HistoryDatasetElement(name="sample3", id=dataset3_id),
]
)
)
self.assertEqual(collection_response["name"], "MyDatasetList")
self.assertEqual(collection_response["collection_type"], "list")
elements = collection_response["elements"]
self.assertEqual(len(elements), 3)
self.assertEqual(elements[0]["element_index"], 0)
self.assertEqual(elements[0]["object"]["id"], dataset1_id)
self.assertEqual(elements[1]["object"]["id"], dataset2_id)
self.assertEqual(elements[2]["object"]["id"], dataset3_id)
self.assertEqual(elements[2]["element_identifier"], "sample3")
def test_run_workflow_with_dataset_collection(self):
dataset1 = self.hist.paste_content(FOO_DATA)
dataset2 = self.hist.paste_content(FOO_DATA_2)
collection_description = dataset_collections.CollectionDescription(
name="MyDatasetList",
elements=[
dataset_collections.HistoryDatasetElement(name="sample1", id=dataset1.id),
dataset_collections.HistoryDatasetElement(name="sample2", id=dataset2.id),
]
)
dataset_collection = self.hist.create_dataset_collection(collection_description)
input_map = {"Input Dataset Collection": dataset_collection,
"Input 2": dataset1}
outputs, out_hist = self.wf.run(input_map, self.hist, wait=True)
self.assertEqual(len(outputs), 1)
out_hdca = outputs[0]
self.assertIsInstance(out_hdca, wrappers.HistoryDatasetCollectionAssociation)
self.assertEqual(out_hdca.collection_type, 'list')
self.assertEqual(len(out_hdca.elements), 2)
self.assertEqual(out_hist.id, self.hist.id)
if len(matchingCollections) > 1:
print("Error: more than one collection matching that id found (WTF?)")
exit(1)
collectionId = matchingCollections[0]['id']
failedCollection = gi.histories.show_dataset_collection(historyId, collectionId)
okDatasets = [d for d in failedCollection['elements'] if d['object']['state'] == 'ok' and d['object']['file_size'] > 0]
notOkDatasets = [d for d in failedCollection['elements'] if d['object']['state'] != 'ok' or d['object']['file_size'] == 0]
okCollectionName = failedCollection['name'] + " (ok)"
notOkCollectionName = failedCollection['name'] + " (not ok)"
gi.histories.create_dataset_collection(
history_id=historyId,
collection_description=collections.CollectionDescription(
name=okCollectionName,
elements=[collections.HistoryDatasetElement(d['object']['name'], d['object']['id']) for d in okDatasets]))
gi.histories.create_dataset_collection(
history_id=historyId,
collection_description=collections.CollectionDescription(
name=notOkCollectionName,
elements=[collections.HistoryDatasetElement(d['object']['name'], d['object']['id']) for d in notOkDatasets]))
exit(1)
if len(matchingCollections) > 1:
print("Error: more than one collection matching that id found (WTF?)")
exit(1)
collectionId = matchingCollections[0]['id']
failedCollection = gi.histories.show_dataset_collection(historyId, collectionId)
okDatasets = [d for d in failedCollection['elements'] if d['object']['state'] == 'ok' and d['object']['file_size'] > 0]
notOkDatasets = [d for d in failedCollection['elements'] if d['object']['state'] != 'ok' or d['object']['file_size'] == 0]
okCollectionName = failedCollection['name'] + " (ok)"
notOkCollectionName = failedCollection['name'] + " (not ok)"
gi.histories.create_dataset_collection(
history_id=historyId,
collection_description=collections.CollectionDescription(
name=okCollectionName,
elements=[collections.HistoryDatasetElement(d['object']['name'], d['object']['id']) for d in okDatasets]))
gi.histories.create_dataset_collection(
history_id=historyId,
collection_description=collections.CollectionDescription(
name=notOkCollectionName,
elements=[collections.HistoryDatasetElement(d['object']['name'], d['object']['id']) for d in notOkDatasets]))
collectionId = matchingCollections[0]['id']
failedCollection = gi.histories.show_dataset_collection(historyId, collectionId)
okDatasets = [d for d in failedCollection['elements'] if d['object']['state'] == 'ok' and d['object']['file_size'] > 0]
notOkDatasets = [d for d in failedCollection['elements'] if d['object']['state'] != 'ok' or d['object']['file_size'] == 0]
okCollectionName = failedCollection['name'] + " (ok)"
notOkCollectionName = failedCollection['name'] + " (not ok)"
gi.histories.create_dataset_collection(
history_id=historyId,
collection_description=collections.CollectionDescription(
name=okCollectionName,
elements=[collections.HistoryDatasetElement(d['object']['name'], d['object']['id']) for d in okDatasets]))
gi.histories.create_dataset_collection(
history_id=historyId,
collection_description=collections.CollectionDescription(
name=notOkCollectionName,
elements=[collections.HistoryDatasetElement(d['object']['name'], d['object']['id']) for d in notOkDatasets]))