aboutsummaryrefslogtreecommitdiff
path: root/scripts/cleanup.py
blob: 78f34c8c1ab0484712d7c8563822edf1b52adda0 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
import arvados
import arvados.util

api = arvados.api()

delete_patterns = [
    "%missing%`collection_location`%",
    "%missing%`technology`%",
    "%missing%`host_species`%",
    "%QC fail: alignment%",
    "%does not look like a valid URI%",
    "%Duplicate of%",
    "%No matching triples found for predicate obo:NCIT_C42781%",
    "%does not look like a valid URI%"
    ]

revalidate_patterns = [
    "%missing%`license`%",
    "%QC fail%"
]

for p in delete_patterns:
    c = arvados.util.list_all(api.collections().list, filters=[
        ["owner_uuid", "=", "lugli-j7d0g-n5clictpuvwk8aa"],
        ["properties.errors", "like", p]])
    for i in c:
        print("trashing %s %s" % (i["uuid"], i["properties"].get("sequence_label")))
        api.collections().delete(uuid=i["uuid"]).execute()

for p in revalidate_patterns:
    c = arvados.util.list_all(api.collections().list, filters=[
        ["owner_uuid", "=", "lugli-j7d0g-n5clictpuvwk8aa"],
        ["properties.errors", "like", p]])
    for i in c:
        print("clearing status %s %s" % (i["uuid"], i["properties"].get("sequence_label")))
        pr = i["properties"]
        if "status" in pr:
            del pr["status"]
        if "errors" in pr:
            del pr["errors"]
        api.collections().update(uuid=i["uuid"], body={"properties": pr}).execute()