Fix flaky "errors"

This commit is contained in:
Matt Chambers
2016-05-13 11:38:48 -05:00
parent 3a708a0089
commit 384bdbfe70
@@ -7,7 +7,6 @@ Sample call:
python filter_failed_datasets_from_collection.py <GalaxyUrl> <ApiKey> MySpecialHistory 1234
"""
import sys
import bioblend
from bioblend.galaxy import GalaxyInstance
from bioblend.galaxy import dataset_collections as collections
@@ -26,7 +25,7 @@ historyMatches = gi.histories.get_histories(name=historyName)
if (len(historyMatches) > 1):
print("Error: more than one history matches that name.")
exit(1)
historyId = historyMatches[0]['id']
historyContents = gi.histories.show_history(historyId, contents=True, deleted=False, visible=True, details=False)
matchingCollections = filter(lambda x: x['hid'] == collectionHistoryId, historyContents)
@@ -34,17 +33,17 @@ matchingCollections = filter(lambda x: x['hid'] == collectionHistoryId, historyC
if (len(matchingCollections) == 0):
print("Error: no collections matching that id found.")
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 = filter(lambda d: d['object']['state'] == 'ok' and d['object']['file_size'] > 0, failedCollection['elements'])
notOkDatasets = filter(lambda d: d['object']['state'] != 'ok' or d['object']['file_size'] == 0, failedCollection['elements'])
okCollectionName = failedCollection['name'] + " (ok)";
notOkCollectionName = failedCollection['name'] + " (not ok)";
okCollectionName = failedCollection['name'] + " (ok)"
notOkCollectionName = failedCollection['name'] + " (not ok)"
gi.histories.create_dataset_collection(
history_id=historyId,
@@ -56,4 +55,4 @@ 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]))
elements=[collections.HistoryDatasetElement(d['object']['name'], d['object']['id']) for d in notOkDatasets]))