def pipeline_instance(uuid, patterns, local): pi_uuid = uuid job_patterns = patterns cluster_uuid = pi_uuid.split('-')[0] resp = arvados.api().pipeline_instances().list(filters=[["uuid","=", pi_uuid]]).execute() if not local: for job in resp.items()[1][1][0]['components']['cwl-runner']['job']['components']: for pattern in job_patterns: if re.match(pattern, job): job_uuid = resp.items()[1][1][0]['components']['cwl-runner']['job']['components'][job] jobresp = arvados.api().jobs().list(filters=[["uuid", "=", job_uuid]]).execute() output_pdh = jobresp.items()[1][1][0]['output'] for file in Collection(output_pdh): print os.path.join(output_pdh,file) else: for job in resp.items()[1][1][0]['components']: for pattern in job_patterns: if re.match(pattern, job): job_uuid = resp.items()[1][1][0]['components'][job]['job']['uuid'] jobresp = arvados.api().jobs().list(filters=[["uuid", "=", job_uuid]]).execute() output_pdh = jobresp.items()[1][1][0]['output'] print job for file in Collection(output_pdh): print os.path.join(output_pdh,file)
def test__eq__from_manifest(self): with Collection( '. 781e5e245d69b566979b86e28d23f2c7+10 0:10:count1.txt') as c1: with Collection( '. 781e5e245d69b566979b86e28d23f2c7+10 0:10:count1.txt' ) as c2: self.assertTrue(c1["count1.txt"] == c2["count1.txt"]) self.assertFalse(c1["count1.txt"] != c2["count1.txt"])
def test__ne__(self): with Collection('. 781e5e245d69b566979b86e28d23f2c7+10 0:10:count1.txt') as c1: with Collection() as c2: with c2.open("count1.txt", "w") as f: f.write("1234567890") self.assertTrue(c1["count1.txt"] != c2["count1.txt"]) self.assertFalse(c1["count1.txt"] == c2["count1.txt"])
def test__eq__from_writes(self): with Collection('. 781e5e245d69b566979b86e28d23f2c7+10 0:10:count1.txt') as c1: with Collection() as c2: f = c2.open("count1.txt", "w") f.write("0123456789") self.assertTrue(c1["count1.txt"] == c2["count1.txt"]) self.assertFalse(c1["count1.txt"] != c2["count1.txt"])
def test_permission_expired(self): base_manifest = ". 781e5e245d69b566979b86e28d23f2c7+10+A715fd31f8111894f717eb1003c1b0216799dd9ec@{} 0:10:count.txt\n" now = datetime.datetime.now() a_week_ago = now - datetime.timedelta(days=7) a_month_ago = now - datetime.timedelta(days=30) a_week_from_now = now + datetime.timedelta(days=7) with Collection(base_manifest.format(self.datetime_to_hex(a_week_from_now))) as c: self.assertFalse(c.find('count.txt').permission_expired()) with Collection(base_manifest.format(self.datetime_to_hex(a_week_ago))) as c: f = c.find('count.txt') self.assertTrue(f.permission_expired()) self.assertTrue(f.permission_expired(a_week_from_now)) self.assertFalse(f.permission_expired(a_month_ago))
def test_prefetch(self): keep = ArvadosFileWriterTestCase.MockKeep({"2e9ec317e197819358fbc43afca7d837+8": "01234567", "e8dc4081b13434b45189a720b77b6818+8": "abcdefgh"}) with Collection(". 2e9ec317e197819358fbc43afca7d837+8 e8dc4081b13434b45189a720b77b6818+8 0:16:count.txt\n", keep_client=keep) as c: r = c.open("count.txt", "r") self.assertEqual("0123", r.read(4)) self.assertIn("2e9ec317e197819358fbc43afca7d837+8", keep.requests) self.assertIn("e8dc4081b13434b45189a720b77b6818+8", keep.requests)
def test_truncate2(self): keep = ArvadosFileWriterTestCase.MockKeep({ "781e5e245d69b566979b86e28d23f2c7+10": b"0123456789", }) api = ArvadosFileWriterTestCase.MockApi({ "name": "test_truncate2", "manifest_text": ". 781e5e245d69b566979b86e28d23f2c7+10 7f614da9329cd3aebf59b91aadc30bf0+67108864 0:12:count.txt\n", "replication_desired": None, }, { "uuid": "zzzzz-4zz18-mockcollection0", "manifest_text": ". 781e5e245d69b566979b86e28d23f2c7+10 7f614da9329cd3aebf59b91aadc30bf0+67108864 0:12:count.txt\n", "portable_data_hash": "272da898abdf86ddc71994835e3155f8+95", }) with Collection('. 781e5e245d69b566979b86e28d23f2c7+10 0:10:count.txt\n', api_client=api, keep_client=keep) as c: writer = c.open("count.txt", "rb+") self.assertEqual(writer.size(), 10) self.assertEqual(b"0123456789", writer.read(12)) # extend file size writer.truncate(12) self.assertEqual(writer.size(), 12) writer.seek(0, os.SEEK_SET) self.assertEqual(b"0123456789\x00\x00", writer.read(12)) self.assertIsNone(c.manifest_locator()) self.assertTrue(c.modified()) c.save_new("test_truncate2") self.assertEqual("zzzzz-4zz18-mockcollection0", c.manifest_locator()) self.assertFalse(c.modified())
def test_overwrite(self): keep = ArvadosFileWriterTestCase.MockKeep( {"781e5e245d69b566979b86e28d23f2c7+10": "0123456789"}) api = ArvadosFileWriterTestCase.MockApi( { "name": "test_overwrite", "manifest_text": ". 2e9ec317e197819358fbc43afca7d837+8 0:8:count.txt\n", "replication_desired": None }, { "uuid": "zzzzz-4zz18-mockcollection0", "manifest_text": ". 2e9ec317e197819358fbc43afca7d837+8 0:8:count.txt\n", "portable_data_hash": "7a461a8c58601798f690f8b368ac4423+51" }) with Collection( '. 781e5e245d69b566979b86e28d23f2c7+10 0:10:count.txt\n', api_client=api, keep_client=keep) as c: writer = c.open("count.txt", "wb+") self.assertEqual(writer.size(), 0) writer.write("01234567") self.assertEqual(writer.size(), 8) self.assertIsNone(c.manifest_locator()) self.assertTrue(c.modified()) c.save_new("test_overwrite") self.assertEqual("zzzzz-4zz18-mockcollection0", c.manifest_locator()) self.assertFalse(c.modified())
def test_create_multiple(self): keep = ArvadosFileWriterTestCase.MockKeep({}) api = ArvadosFileWriterTestCase.MockApi( { "name": "test_create_multiple", "manifest_text": ". 2e9ec317e197819358fbc43afca7d837+8 e8dc4081b13434b45189a720b77b6818+8 0:8:count1.txt 8:8:count2.txt\n", "replication_desired": None }, { "uuid": "zzzzz-4zz18-mockcollection0", "manifest_text": ". 2e9ec317e197819358fbc43afca7d837+8 e8dc4081b13434b45189a720b77b6818+8 0:8:count1.txt 8:8:count2.txt\n", "portable_data_hash": "71e7bb6c00d31fc2b4364199fd97be08+102" }) with Collection(api_client=api, keep_client=keep) as c: w1 = c.open("count1.txt", "wb") w2 = c.open("count2.txt", "wb") w1.write("01234567") w2.write("abcdefgh") self.assertEqual(w1.size(), 8) self.assertEqual(w2.size(), 8) self.assertIsNone(c.manifest_locator()) self.assertTrue(c.modified()) self.assertIsNone(keep.get("2e9ec317e197819358fbc43afca7d837+8")) c.save_new("test_create_multiple") self.assertEqual("zzzzz-4zz18-mockcollection0", c.manifest_locator()) self.assertFalse(c.modified()) self.assertEqual(b"01234567", keep.get("2e9ec317e197819358fbc43afca7d837+8"))
def test_write_large_rewrite(self): keep = ArvadosFileWriterTestCase.MockKeep({}) api = ArvadosFileWriterTestCase.MockApi( { "name": "test_write_large", "manifest_text": ". 3dc0d4bc21f48060bedcb2c91af4f906+32892003 a5de24f4417cfba9d5825eadc2f4ca49+67108000 0:3:count.txt 32892006:67107997:count.txt 3:32892000:count.txt\n", "replication_desired": None }, { "uuid": "zzzzz-4zz18-mockcollection0", "manifest_text": ". 3dc0d4bc21f48060bedcb2c91af4f906+32892003 a5de24f4417cfba9d5825eadc2f4ca49+67108000 0:3:count.txt 32892006:67107997:count.txt 3:32892000:count.txt\n", "portable_data_hash": "217665c6b713e1b78dfba7ebd42344db+156" }) with Collection('. ' + arvados.config.EMPTY_BLOCK_LOCATOR + ' 0:0:count.txt', api_client=api, keep_client=keep) as c: writer = c.open("count.txt", "rb+") text = b''.join([b"0123456789" for a in range(0, 100)]) for b in range(0, 100000): writer.write(text) writer.seek(0, os.SEEK_SET) writer.write("foo") self.assertEqual(writer.size(), 100000000) self.assertIsNone(c.manifest_locator()) self.assertTrue(c.modified()) c.save_new("test_write_large") self.assertEqual("zzzzz-4zz18-mockcollection0", c.manifest_locator()) self.assertFalse(c.modified())
def test_truncate(self): keep = ArvadosFileWriterTestCase.MockKeep({ "781e5e245d69b566979b86e28d23f2c7+10": b"0123456789", }) api = ArvadosFileWriterTestCase.MockApi({ "name": "test_truncate", "manifest_text": ". 781e5e245d69b566979b86e28d23f2c7+10 0:8:count.txt\n", "replication_desired": None, }, { "uuid": "zzzzz-4zz18-mockcollection0", "manifest_text": ". 781e5e245d69b566979b86e28d23f2c7+10 0:8:count.txt\n", "portable_data_hash":"7fcd0eaac3aad4c31a6a0e756475da92+52", }) with Collection('. 781e5e245d69b566979b86e28d23f2c7+10 0:10:count.txt\n', api_client=api, keep_client=keep) as c: writer = c.open("count.txt", "rb+") self.assertEqual(writer.size(), 10) self.assertEqual(b"0123456789", writer.read(12)) writer.truncate(8) # Make sure reading off the end doesn't break self.assertEqual(b"", writer.read(12)) self.assertEqual(writer.size(), 8) writer.seek(0, os.SEEK_SET) self.assertEqual(b"01234567", writer.read(12)) self.assertIsNone(c.manifest_locator()) self.assertTrue(c.modified()) c.save_new("test_truncate") self.assertEqual("zzzzz-4zz18-mockcollection0", c.manifest_locator()) self.assertFalse(c.modified())
def test_append(self): keep = ArvadosFileWriterTestCase.MockKeep({ "781e5e245d69b566979b86e28d23f2c7+10": b"0123456789", }) c = Collection( '. 781e5e245d69b566979b86e28d23f2c7+10 0:10:count.txt\n', keep_client=keep) writer = c.open("count.txt", "ab+") self.assertEqual(writer.read(20), b"0123456789") writer.seek(0, os.SEEK_SET) writer.write("hello") self.assertEqual(writer.read(), b"") writer.seek(-5, os.SEEK_CUR) self.assertEqual(writer.read(3), b"hel") self.assertEqual(writer.read(), b"lo") writer.seek(0, os.SEEK_SET) self.assertEqual(writer.read(), b"0123456789hello") writer.seek(0) writer.write("world") self.assertEqual(writer.read(), b"") writer.seek(0) self.assertEqual(writer.read(), b"0123456789helloworld") self.assertEqual( ". 781e5e245d69b566979b86e28d23f2c7+10 fc5e038d38a57032085441e7fe7010b0+10 0:20:count.txt\n", c.portable_manifest_text())
def test_create_multiple(self): keep = ArvadosFileWriterTestCase.MockKeep({}) api = ArvadosFileWriterTestCase.MockApi( { "name": "test_create_multiple", "manifest_text": ". 2e9ec317e197819358fbc43afca7d837+8 e8dc4081b13434b45189a720b77b6818+8 0:8:count1.txt 8:8:count2.txt\n" }, { "uuid": "zzzzz-4zz18-mockcollection0", "manifest_text": ". 2e9ec317e197819358fbc43afca7d837+8 e8dc4081b13434b45189a720b77b6818+8 0:8:count1.txt 8:8:count2.txt\n" }) with Collection(api_client=api, keep_client=keep) as c: w1 = c.open("count1.txt", "w") w2 = c.open("count2.txt", "w") w1.write("01234567") w2.write("abcdefgh") self.assertEqual(w1.size(), 8) self.assertEqual(w2.size(), 8) self.assertEqual(None, c.manifest_locator()) self.assertEqual(True, c.modified()) self.assertEqual(None, keep.get("2e9ec317e197819358fbc43afca7d837+8")) c.save_new("test_create_multiple") self.assertEqual("zzzzz-4zz18-mockcollection0", c.manifest_locator()) self.assertEqual(False, c.modified()) self.assertEqual("01234567", keep.get("2e9ec317e197819358fbc43afca7d837+8"))
def test_overwrite(self): keep = ArvadosFileWriterTestCase.MockKeep( {"781e5e245d69b566979b86e28d23f2c7+10": "0123456789"}) api = ArvadosFileWriterTestCase.MockApi( { "name": "test_overwrite", "manifest_text": ". 2e9ec317e197819358fbc43afca7d837+8 0:8:count.txt\n" }, { "uuid": "zzzzz-4zz18-mockcollection0", "manifest_text": ". 2e9ec317e197819358fbc43afca7d837+8 0:8:count.txt\n" }) with Collection( '. 781e5e245d69b566979b86e28d23f2c7+10 0:10:count.txt\n', api_client=api, keep_client=keep) as c: writer = c.open("count.txt", "w+") self.assertEqual(writer.size(), 0) writer.write("01234567") self.assertEqual(writer.size(), 8) self.assertEqual(None, c.manifest_locator()) self.assertEqual(True, c.modified()) c.save_new("test_overwrite") self.assertEqual("zzzzz-4zz18-mockcollection0", c.manifest_locator()) self.assertEqual(False, c.modified())
def test_create(self): keep = ArvadosFileWriterTestCase.MockKeep({}) api = ArvadosFileWriterTestCase.MockApi( { "name": "test_create", "manifest_text": ". 2e9ec317e197819358fbc43afca7d837+8 0:8:count.txt\n" }, { "uuid": "zzzzz-4zz18-mockcollection0", "manifest_text": ". 2e9ec317e197819358fbc43afca7d837+8 0:8:count.txt\n" }) with Collection(api_client=api, keep_client=keep) as c: writer = c.open("count.txt", "w+") self.assertEqual(writer.size(), 0) writer.write("01234567") self.assertEqual(writer.size(), 8) self.assertEqual(None, c.manifest_locator()) self.assertEqual(True, c.modified()) self.assertEqual(None, keep.get("2e9ec317e197819358fbc43afca7d837+8")) c.save_new("test_create") self.assertEqual("zzzzz-4zz18-mockcollection0", c.manifest_locator()) self.assertEqual(False, c.modified()) self.assertEqual("01234567", keep.get("2e9ec317e197819358fbc43afca7d837+8"))
def test_write_large_rewrite(self): keep = ArvadosFileWriterTestCase.MockKeep({}) api = ArvadosFileWriterTestCase.MockApi( { "name": "test_write_large", "manifest_text": ". 37400a68af9abdd76ca5bf13e819e42a+32892003 a5de24f4417cfba9d5825eadc2f4ca49+67108000 32892000:3:count.txt 32892006:67107997:count.txt 0:32892000:count.txt\n" }, { "uuid": "zzzzz-4zz18-mockcollection0", "manifest_text": ". 37400a68af9abdd76ca5bf13e819e42a+32892003 a5de24f4417cfba9d5825eadc2f4ca49+67108000 32892000:3:count.txt 32892006:67107997:count.txt 0:32892000:count.txt\n" }) with Collection('. ' + arvados.config.EMPTY_BLOCK_LOCATOR + ' 0:0:count.txt', api_client=api, keep_client=keep) as c: writer = c.open("count.txt", "r+") text = ''.join(["0123456789" for a in xrange(0, 100)]) for b in xrange(0, 100000): writer.write(text) writer.seek(0, os.SEEK_SET) writer.write("foo") self.assertEqual(writer.size(), 100000000) self.assertEqual(None, c.manifest_locator()) self.assertEqual(True, c.modified()) c.save_new("test_write_large") self.assertEqual("zzzzz-4zz18-mockcollection0", c.manifest_locator()) self.assertEqual(False, c.modified())
def test_write_large(self): keep = ArvadosFileWriterTestCase.MockKeep({}) api = ArvadosFileWriterTestCase.MockApi( { "name": "test_write_large", "manifest_text": ". a5de24f4417cfba9d5825eadc2f4ca49+67108000 598cc1a4ccaef8ab6e4724d87e675d78+32892000 0:100000000:count.txt\n" }, { "uuid": "zzzzz-4zz18-mockcollection0", "manifest_text": ". a5de24f4417cfba9d5825eadc2f4ca49+67108000 598cc1a4ccaef8ab6e4724d87e675d78+32892000 0:100000000:count.txt\n" }) with Collection('. ' + arvados.config.EMPTY_BLOCK_LOCATOR + ' 0:0:count.txt', api_client=api, keep_client=keep) as c: writer = c.open("count.txt", "r+") text = ''.join(["0123456789" for a in xrange(0, 100)]) for b in xrange(0, 100000): writer.write(text) self.assertEqual(writer.size(), 100000000) self.assertEqual(None, c.manifest_locator()) self.assertEqual(True, c.modified()) c.save_new("test_write_large") self.assertEqual("zzzzz-4zz18-mockcollection0", c.manifest_locator()) self.assertEqual(False, c.modified())
def test_truncate(self): keep = ArvadosFileWriterTestCase.MockKeep({"781e5e245d69b566979b86e28d23f2c7+10": "0123456789"}) api = ArvadosFileWriterTestCase.MockApi({"name":"test_truncate", "manifest_text":". 781e5e245d69b566979b86e28d23f2c7+10 0:8:count.txt\n"}, {"uuid":"zzzzz-4zz18-mockcollection0", "manifest_text":". 781e5e245d69b566979b86e28d23f2c7+10 0:8:count.txt\n"}) with Collection('. 781e5e245d69b566979b86e28d23f2c7+10 0:10:count.txt\n', api_client=api, keep_client=keep) as c: writer = c.open("count.txt", "r+") self.assertEqual(writer.size(), 10) self.assertEqual("0123456789", writer.read(12)) writer.truncate(8) # Make sure reading off the end doesn't break self.assertEqual("", writer.read(12)) self.assertEqual(writer.size(), 8) writer.seek(0, os.SEEK_SET) self.assertEqual("01234567", writer.read(12)) self.assertEqual(None, c.manifest_locator()) self.assertEqual(True, c.modified()) c.save_new("test_truncate") self.assertEqual("zzzzz-4zz18-mockcollection0", c.manifest_locator()) self.assertEqual(False, c.modified())
def test_write_to_end(self): keep = ArvadosFileWriterTestCase.MockKeep({"781e5e245d69b566979b86e28d23f2c7+10": "0123456789"}) api = ArvadosFileWriterTestCase.MockApi({"name":"test_append", "manifest_text": ". 781e5e245d69b566979b86e28d23f2c7+10 acbd18db4cc2f85cedef654fccc4a4d8+3 0:13:count.txt\n"}, {"uuid":"zzzzz-4zz18-mockcollection0", "manifest_text": ". 781e5e245d69b566979b86e28d23f2c7+10 acbd18db4cc2f85cedef654fccc4a4d8+3 0:13:count.txt\n"}) with Collection('. 781e5e245d69b566979b86e28d23f2c7+10 0:10:count.txt\n', api_client=api, keep_client=keep) as c: writer = c.open("count.txt", "r+") self.assertEqual(writer.size(), 10) writer.seek(5, os.SEEK_SET) self.assertEqual("56789", writer.read(8)) writer.seek(10, os.SEEK_SET) writer.write("foo") self.assertEqual(writer.size(), 13) writer.seek(5, os.SEEK_SET) self.assertEqual("56789foo", writer.read(8)) self.assertEqual(None, c.manifest_locator()) self.assertEqual(True, c.modified()) self.assertEqual(None, keep.get("acbd18db4cc2f85cedef654fccc4a4d8+3")) c.save_new("test_append") self.assertEqual("zzzzz-4zz18-mockcollection0", c.manifest_locator()) self.assertEqual(False, c.modified()) self.assertEqual("foo", keep.get("acbd18db4cc2f85cedef654fccc4a4d8+3"))
def spawn_new_task_per_file(script_parameter, regex, if_sequence=0, and_end_task=True): """ Generalized form of one_task_per_pair_input_file from https://github.com/curoverse/arvados/blob/master/crunch_scripts/arvados_bwa.py Creates a new task if the file in the collection matches the regex """ if if_sequence != arvados.current_task()['sequence']: return job_input = arvados.current_job()['script_parameters'][script_parameter] input_collection = Collection(job_input) for name in input_collection: if not re.search(regex,name): continue new_task_attrs = { 'job_uuid': arvados.current_job()['uuid'], 'created_by_job_task_uuid': arvados.current_task()['uuid'], 'sequence': if_sequence + 1, 'parameters': { 'input_1': name, } } arvados.api().job_tasks().create(body=new_task_attrs).execute() if and_end_task: arvados.api().job_tasks().update(uuid=arvados.current_task()['uuid'], body={'success':True} ).execute()
def test_rewrite_over_existing_file(self): keep = ArvadosFileWriterTestCase.MockKeep({ "781e5e245d69b566979b86e28d23f2c7+10": b"0123456789", }) with Collection('. 781e5e245d69b566979b86e28d23f2c7+10 0:10:count.txt', keep_client=keep) as c: writer = c.open("count.txt", "rb+") for b in range(0, 10): writer.seek(5, os.SEEK_SET) writer.write("abcdefghij") self.assertEqual(writer.size(), 15) self.assertEqual(b"01234abcdefghij", writer.readfrom(0, 20)) self.assertEqual( ". 781e5e245d69b566979b86e28d23f2c7+10 ae5f43bab79cf0be33f025fa97ae7398+100 0:5:count.txt 100:10:count.txt\n", c.portable_manifest_text()) writer.arvadosfile.flush() self.assertEqual(writer.size(), 15) self.assertEqual(b"01234abcdefghij", writer.readfrom(0, 20)) self.assertEqual( ". 781e5e245d69b566979b86e28d23f2c7+10 a925576942e94b2ef57a066101b48876+10 0:5:count.txt 10:10:count.txt\n", c.portable_manifest_text())
def test_write_large(self): keep = ArvadosFileWriterTestCase.MockKeep({}) api = ArvadosFileWriterTestCase.MockApi( { "name": "test_write_large", "manifest_text": ". a5de24f4417cfba9d5825eadc2f4ca49+67108000 598cc1a4ccaef8ab6e4724d87e675d78+32892000 0:100000000:count.txt\n", "replication_desired": None }, { "uuid": "zzzzz-4zz18-mockcollection0", "manifest_text": ". a5de24f4417cfba9d5825eadc2f4ca49+67108000 598cc1a4ccaef8ab6e4724d87e675d78+32892000 0:100000000:count.txt\n", "portable_data_hash": "9132ca8e3f671c76103a38f5bc24328c+108" }) with Collection('. ' + arvados.config.EMPTY_BLOCK_LOCATOR + ' 0:0:count.txt', api_client=api, keep_client=keep) as c: writer = c.open("count.txt", "rb+") text = "0123456789" * 100 for b in range(0, 100000): writer.write(text) self.assertEqual(writer.size(), 100000000) self.assertIsNone(c.manifest_locator()) self.assertTrue(c.modified()) c.save_new("test_write_large") self.assertEqual("zzzzz-4zz18-mockcollection0", c.manifest_locator()) self.assertFalse(c.modified())
def test_write_empty(self): keep = ArvadosFileWriterTestCase.MockKeep({}) with Collection(keep_client=keep) as c: writer = c.open("count.txt", "wb") self.assertEqual(writer.size(), 0) self.assertEqual( ". d41d8cd98f00b204e9800998ecf8427e+0 0:0:count.txt\n", c.portable_manifest_text())
def test_get_manifest_text_commits(self): keep = ArvadosFileWriterTestCase.MockKeep({}) with Collection(keep_client=keep) as c: writer = c.open("count.txt", "w") writer.write("0123456789") self.assertEqual('. 781e5e245d69b566979b86e28d23f2c7+10 0:10:count.txt\n', c.portable_manifest_text()) self.assertNotIn('781e5e245d69b566979b86e28d23f2c7+10', keep.blocks) self.assertEqual('. 781e5e245d69b566979b86e28d23f2c7+10 0:10:count.txt\n', c.manifest_text()) self.assertIn('781e5e245d69b566979b86e28d23f2c7+10', keep.blocks)
def main(): parser = argparse.ArgumentParser() parser.add_argument('--project-uuid', metavar='UUID', help='Project to output to') parser.add_argument('collection_uuid', metavar='UUID', help='Collection UUID') args = parser.parse_args() collection_uuid = args.collection_uuid project_uuid = args.project_uuid c = Collection(collection_uuid) dest = Collection() for i in c: if isinstance(c[i], Subcollection): dest.copy('./' + i, target_path='./' + i, source_collection=c) dest.save_new(owner_uuid=project_uuid) print(dest.manifest_locator())
def test_save_manifest_text(self): keep = ArvadosFileWriterTestCase.MockKeep({}) with Collection(keep_client=keep) as c: writer = c.open("count.txt", "wb") writer.write(b"0123456789") self.assertEqual('. 781e5e245d69b566979b86e28d23f2c7+10 0:10:count.txt\n', c.portable_manifest_text()) self.assertNotIn('781e5e245d69b566979b86e28d23f2c7+10', keep.blocks) self.assertEqual('. 781e5e245d69b566979b86e28d23f2c7+10 0:10:count.txt\n', c.save_new(create_collection_record=False)) self.assertIn('781e5e245d69b566979b86e28d23f2c7+10', keep.blocks)
def get_sample_variantcaller(job): from arvados.collection import Collection for k, v in job["mounts"].items(): if k.endswith("cwl.inputs.json"): c = Collection(v["portable_data_hash"]) with c.open("cwl.inputs.json", "r") as in_handle: inputs = json.load(in_handle) return [get_in_inputs("description", inputs), get_in_inputs("config__algorithm__variantcaller", inputs)] return None, None
def test_write_across_several_segments(self): keep = ArvadosFileWriterTestCase.MockKeep({"781e5e245d69b566979b86e28d23f2c7+10": "0123456789"}) with Collection('. 781e5e245d69b566979b86e28d23f2c7+10 0:4:count.txt 0:4:count.txt 0:4:count.txt', keep_client=keep) as c: writer = c.open("count.txt", "r+") self.assertEqual("012301230123", writer.readfrom(0, 15)) writer.seek(2, os.SEEK_SET) writer.write("abcdefg") self.assertEqual(writer.size(), 12) self.assertEqual("01abcdefg123", writer.readfrom(0, 15)) self.assertEqual(". 781e5e245d69b566979b86e28d23f2c7+10 7ac66c0f148de9519b8bd264312c4d64+7 0:2:count.txt 10:7:count.txt 1:3:count.txt\n", c.portable_manifest_text())
def test_write_at_end(self): keep = ArvadosFileWriterTestCase.MockKeep({"781e5e245d69b566979b86e28d23f2c7+10": "0123456789"}) with Collection('. 781e5e245d69b566979b86e28d23f2c7+10 0:10:count.txt\n', keep_client=keep) as c: writer = c.open("count.txt", "r+") self.assertEqual("0123456789", writer.readfrom(0, 13)) writer.seek(7, os.SEEK_SET) writer.write("foo") self.assertEqual(writer.size(), 10) self.assertEqual("0123456foo", writer.readfrom(0, 13)) self.assertEqual(". 781e5e245d69b566979b86e28d23f2c7+10 acbd18db4cc2f85cedef654fccc4a4d8+3 0:7:count.txt 10:3:count.txt\n", c.portable_manifest_text())
def test_write_across_segment_boundary(self): keep = ArvadosFileWriterTestCase.MockKeep({"781e5e245d69b566979b86e28d23f2c7+10": "0123456789"}) with Collection('. 781e5e245d69b566979b86e28d23f2c7+10 0:10:count.txt 0:10:count.txt\n', keep_client=keep) as c: writer = c.open("count.txt", "r+") self.assertEqual("012345678901234", writer.readfrom(0, 15)) writer.seek(7, os.SEEK_SET) writer.write("foobar") self.assertEqual(writer.size(), 20) self.assertEqual("0123456foobar34", writer.readfrom(0, 15)) self.assertEqual(". 781e5e245d69b566979b86e28d23f2c7+10 3858f62230ac3c915f300c664312c63f+6 0:7:count.txt 10:6:count.txt 3:7:count.txt\n", c.portable_manifest_text())