aboutsummaryrefslogtreecommitdiff
path: root/bh20sequploader
diff options
context:
space:
mode:
authorPeter Amstutz2020-07-08 20:51:14 +0000
committerPeter Amstutz2020-07-08 20:52:48 +0000
commitbfcebbd349687ebe2d1d47185db9fda38803b674 (patch)
tree1c9780c034f9f9c23df828ca2e155259d8881f92 /bh20sequploader
parentae8991618927f81343038f235c3e3f76932f80ea (diff)
downloadbh20-seq-resource-bfcebbd349687ebe2d1d47185db9fda38803b674.tar.gz
bh20-seq-resource-bfcebbd349687ebe2d1d47185db9fda38803b674.tar.lz
bh20-seq-resource-bfcebbd349687ebe2d1d47185db9fda38803b674.zip
Uploader checks for duplicates
Diffstat (limited to 'bh20sequploader')
-rw-r--r--bh20sequploader/main.py14
1 files changed, 12 insertions, 2 deletions
diff --git a/bh20sequploader/main.py b/bh20sequploader/main.py
index fd0278d..56e0150 100644
--- a/bh20sequploader/main.py
+++ b/bh20sequploader/main.py
@@ -19,8 +19,10 @@ log = logging.getLogger(__name__ )
log.debug("Entering sequence uploader")
ARVADOS_API_HOST='lugli.arvadosapi.com'
-ARVADOS_API_TOKEN='2fbebpmbo3rw3x05ueu2i6nx70zhrsb1p22ycu3ry34m4x4462'
+UPLOADER_API_TOKEN='2fbebpmbo3rw3x05ueu2i6nx70zhrsb1p22ycu3ry34m4x4462'
+ANONYMOUS_API_TOKEN='5o42qdxpxp5cj15jqjf7vnxx5xduhm4ret703suuoa3ivfglfh'
UPLOAD_PROJECT='lugli-j7d0g-n5clictpuvwk8aa'
+VALIDATED_PROJECT='lugli-j7d0g-n5clictpuvwk8aa'
def qc_stuff(metadata, sequence_p1, sequence_p2, do_qc=True):
failed = False
@@ -69,7 +71,7 @@ def main():
parser.add_argument("--skip-qc", action="store_true", help="Skip local qc check")
args = parser.parse_args()
- api = arvados.api(host=ARVADOS_API_HOST, token=ARVADOS_API_TOKEN, insecure=True)
+ api = arvados.api(host=ARVADOS_API_HOST, token=UPLOADER_API_TOKEN, insecure=True)
target = qc_stuff(args.metadata, args.sequence_p1, args.sequence_p2, not args.skip_qc)
seqlabel = target[0][1]
@@ -106,6 +108,14 @@ def main():
"upload_user": "%s@%s" % (username, socket.gethostname())
}
+ api2 = arvados.api(host=ARVADOS_API_HOST, token=ANONYMOUS_API_TOKEN, insecure=True)
+ dup = api2.collections().list(filters=[["owner_uuid", "in", [VALIDATED_PROJECT, UPLOAD_PROJECT]],
+ ["portable_data_hash", "=", col.portable_data_hash()]]).execute()
+ if dup["items"]:
+ # This exact collection has been uploaded before.
+ print("Duplicate of %s" % ([d["uuid"] for d in dup["items"]]))
+ exit(1)
+
col.save_new(owner_uuid=UPLOAD_PROJECT, name="%s uploaded by %s from %s" %
(seqlabel, properties['upload_user'], properties['upload_ip']),
properties=properties, ensure_unique_name=True)