- # Register the resulting collection in Arvados.
- collection = arvados.api().collections().create(
- body={
- 'uuid': writer.finish(),
- 'manifest_text': writer.manifest_text(),
- },
- ).execute()
-
- # Print the locator (uuid) of the new collection.
- output = collection['uuid']
- if project_link is not None:
- try:
- create_project_link(output, project_link)
- except apiclient.errors.Error as error:
- print >>stderr, (
- "arv-put: Error adding Collection to project: {}.".format(
- error))
- status = 1
-
+ try:
+ manifest_text = writer.manifest_text()
+ if args.normalize:
+ manifest_text = CollectionReader(manifest_text).manifest_text(normalize=True)
+ replication_attr = 'replication_desired'
+ if api_client._schema.schemas['Collection']['properties'].get(replication_attr, None) is None:
+ # API called it 'redundancy' before #3410.
+ replication_attr = 'redundancy'
+ # Register the resulting collection in Arvados.
+ collection = api_client.collections().create(
+ body={
+ 'owner_uuid': project_uuid,
+ 'name': collection_name,
+ 'manifest_text': manifest_text,
+ replication_attr: args.replication,
+ },
+ ensure_unique_name=True
+ ).execute(num_retries=args.retries)
+
+ print >>stderr, "Collection saved as '%s'" % collection['name']
+
+ if args.portable_data_hash and 'portable_data_hash' in collection and collection['portable_data_hash']:
+ output = collection['portable_data_hash']
+ else:
+ output = collection['uuid']
+
+ except apiclient_errors.Error as error:
+ print >>stderr, (
+ "arv-put: Error creating Collection on project: {}.".format(
+ error))
+ status = 1
+
+ # Print the locator (uuid) of the new collection.