[ARVADOS] updated: 1.3.0-1091-g067bb74eb

Git user git at public.curoverse.com
Fri Jun 21 22:15:24 UTC 2019


Summary of changes:
 ...min_list_collections_without_property_py.liquid |  15 +++
 ...property_to_collections_under_project_py.liquid |  36 +++++++
 .../_admin_update_collection_property_py.liquid    |  22 ++++
 ...llection-managed-properties.html.textile.liquid | 112 +++------------------
 4 files changed, 86 insertions(+), 99 deletions(-)
 create mode 100644 doc/_includes/_admin_list_collections_without_property_py.liquid
 create mode 100644 doc/_includes/_admin_set_property_to_collections_under_project_py.liquid
 create mode 100644 doc/_includes/_admin_update_collection_property_py.liquid

       via  067bb74eb31914bb9735e0b847bb91ba2f46fca5 (commit)
      from  e6eb33290995c821fe6c9c1f2fcd0d543d9b4580 (commit)

Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.


commit 067bb74eb31914bb9735e0b847bb91ba2f46fca5
Author: Lucas Di Pentima <ldipentima at veritasgenetics.com>
Date:   Fri Jun 21 19:14:51 2019 -0300

    14874: Simplifies example scripts and expands documentation.
    
    Arvados-DCO-1.1-Signed-off-by: Lucas Di Pentima <ldipentima at veritasgenetics.com>

diff --git a/doc/_includes/_admin_list_collections_without_property_py.liquid b/doc/_includes/_admin_list_collections_without_property_py.liquid
new file mode 100644
index 000000000..a65aec9b9
--- /dev/null
+++ b/doc/_includes/_admin_list_collections_without_property_py.liquid
@@ -0,0 +1,15 @@
+#!/usr/bin/env python
+{% comment %}
+Copyright (C) The Arvados Authors. All rights reserved.
+
+SPDX-License-Identifier: CC-BY-SA-3.0
+{% endcomment %}
+import arvados
+import arvados.util as util
+
+filters = [['properties.responsible_person_uuid', 'exists', False]]
+cols = util.list_all(arvados.api().collections().list, filters=filters, select=['uuid', 'name'])
+
+print("Found {} collections:".format(len(cols)))
+for c in cols:
+    print('{}, "{}"'.format(c['uuid'], c['name']))
\ No newline at end of file
diff --git a/doc/_includes/_admin_set_property_to_collections_under_project_py.liquid b/doc/_includes/_admin_set_property_to_collections_under_project_py.liquid
new file mode 100644
index 000000000..06ef6f097
--- /dev/null
+++ b/doc/_includes/_admin_set_property_to_collections_under_project_py.liquid
@@ -0,0 +1,36 @@
+#!/usr/bin/env python
+{% comment %}
+Copyright (C) The Arvados Authors. All rights reserved.
+
+SPDX-License-Identifier: CC-BY-SA-3.0
+{% endcomment %}
+import arvados
+import arvados.util as util
+
+def get_subproject_uuids(api, root_uuid):
+    uuids = []
+    groups = util.list_all(api.groups().list, filters=[['owner_uuid', '=', '{}'.format(root_uuid)]], select=['uuid'])
+    for g in groups:
+        uuids += ([g['uuid']] + get_subproject_uuids(api, g['uuid']))
+    return uuids
+
+def get_cols(api, filters):
+    cols = util.list_all(api.collections().list, filters=filters, select=['uuid', 'properties'])
+    return cols
+
+# Search for collections on project hierarchy rooted at root_uuid
+root_uuid = 'zzzzz-j7d0g-ppppppppppppppp'
+# Set the property to the UUID below
+responsible_uuid = 'zzzzz-tpzed-xxxxxxxxxxxxxxx'
+
+api = arvados.api()
+for p_uuid in [root_uuid] + get_subproject_uuids(api, root_uuid):
+    f = [['properties.responsible_person_uuid', 'exists', False],
+         ['owner_uuid', '=', p_uuid]]
+    cols = get_cols(api, f)
+    print("Found {} collections owned by {}".format(len(cols), p_uuid))
+    for c in cols:
+        print(" - Updating collection {}".format(c["uuid"]))
+        props = c['properties']
+        props['responsible_person_uuid'] = responsible_uuid
+        api.collections().update(uuid=c['uuid'], body={'properties': props}).execute()
\ No newline at end of file
diff --git a/doc/_includes/_admin_update_collection_property_py.liquid b/doc/_includes/_admin_update_collection_property_py.liquid
new file mode 100644
index 000000000..a2a8f9d82
--- /dev/null
+++ b/doc/_includes/_admin_update_collection_property_py.liquid
@@ -0,0 +1,22 @@
+#!/usr/bin/env python
+{% comment %}
+Copyright (C) The Arvados Authors. All rights reserved.
+
+SPDX-License-Identifier: CC-BY-SA-3.0
+{% endcomment %}
+import arvados
+import arvados.util as util
+
+old_uuid = "zzzzz-tpzed-xxxxxxxxxxxxxxx"
+new_uuid = "zzzzz-tpzed-yyyyyyyyyyyyyyy"
+
+api = arvados.api()
+filters = [['properties.responsible_person_uuid', '=', '{}'.format(old_uuid)]]
+cols = util.list_all(api.collections().list, filters=filters, select=['uuid', 'properties'])
+
+print("Found {} collections".format(len(cols)))
+for c in cols:
+    print("Updating collection {}".format(c["uuid"]))
+    props = c['properties']
+    props['responsible_person_uuid'] = new_uuid
+    api.collections().update(uuid=c['uuid'], body={'properties': props}).execute()
\ No newline at end of file
diff --git a/doc/admin/collection-managed-properties.html.textile.liquid b/doc/admin/collection-managed-properties.html.textile.liquid
index 4f7bb3b17..c6943acae 100644
--- a/doc/admin/collection-managed-properties.html.textile.liquid
+++ b/doc/admin/collection-managed-properties.html.textile.liquid
@@ -57,115 +57,29 @@ For the following examples we assume that the @responsible_person_uuid@ property
 
 h4. List uuid/names of collections without @responsible_person_uuid@ property
 
+The collection's managed properties feature assigns the configured properties to newly created collections. This means that previously existing collections won't get the default properties and if needed, they should be assigned manually.
+
+The following example script outputs a listing of collection UUIDs and names of those collections that don't include the @responsible_person_uuid@ property.
+
 {% codeblock as python %}
-import arvados
-
-page = 100
-offset = 0
-cols = []
-
-filters = [['properties.responsible_person_uuid', 'exists', False]]
-api = arvados.api()
-req = api.collections().list(filters=filters, select=['uuid', 'name'], limit=page).execute()
-
-while True:
-    cols += [c for c in req['items']]
-    if req['items_available'] < offset+page:
-        break
-    offset += page
-    req = api.collections().list(filters=filters, select=['uuid', 'name'], limit=page, offset=offset).execute()
-
-print("Found {} collections:".format(len(cols)))
-for c in cols:
-    print('{}, "{}"'.format(c['uuid'], c['name']))
+{% include 'admin_list_collections_without_property_py' %}
 {% endcodeblock %}
 
 h4. Update the @responsible_person_uuid@ property from nil to X in the project hierarchy rooted at P
 
+When enabling @responsible_person_uuid@, new collections will get this property's value set to the user who owns the root project where the collection is placed, but older collections won't have the property set. The following example script allows an administrator to set the @responsible_person_uuid@ property to collections below a certaing project hierarchy.
+
 {% codeblock as python %}
-import arvados
-
-def get_subproject_uuids(api, root_uuid):
-    page = 100
-    offset = 0
-    uuids = []
-    r = api.groups().list(
-        filters=[['owner_uuid', '=', '{}'.format(root_uuid)]],
-        select=['uuid'],
-        limit=page
-    ).execute()
-    while True:
-        for g in r['items']:
-            uuids += ([g['uuid']] + get_subproject_uuids(api, g['uuid']))
-        if r['items_available'] < offset+page:
-            break
-        offset += page
-        r = api.groups().list(
-            filters=[['owner_uuid', '=', '{}'.format(root_uuid)]],
-            select=['uuid'],
-            limit=page
-        ).execute()
-    return uuids
-
-def get_cols(api, filters):
-    page = 100
-    offset = 0
-    uuids = []
-    r = api.collections().list(filters=filters, select=['uuid', 'properties'], limit=page).execute()
-    while True:
-        uuids += [c for c in r['items']]
-        if r['items_available'] < offset+page:
-            break
-        offset += page
-        r = api.collections().list(filters=filters, select=['uuid', 'properties'], limit=page).execute()
-    return uuids
-
-root_uuid = 'zzzzz-j7d0g-ppppppppppppppp'
-responsible_uuid = 'zzzzz-tpzed-xxxxxxxxxxxxxxx'
-
-api = arvados.api()
-for p_uuid in [root_uuid] + get_subproject_uuids(api, root_uuid):
-    f = [['properties.responsible_person_uuid', 'exists', False],
-         ['owner_uuid', '=', p_uuid]]
-    cols = get_cols(api, f)
-    print("Found {} collections owned by {}".format(len(cols), p_uuid))
-    for c in cols:
-        print(" - Updating collection {}".format(c["uuid"]))
-        props = c['properties']
-        props['responsible_person_uuid'] = responsible_uuid
-        api.collections().update(uuid=c['uuid'], body={'properties': props}).execute()
+{% include 'admin_set_property_to_collections_under_project_py' %}
 {% endcodeblock %}
 
-h4. Update the @responsible_person_uuid@ property from X to Y
+h4. Update the @responsible_person_uuid@ property from X to Y on all collections
+
+This example can be useful to change responsibility from one user to another.
 
-The following code should run with admin privileges, assuming that the managed property is @protected at .
+Please note that the following code should run with admin privileges, assuming that the managed property is @protected at .
 
 {% codeblock as python %}
-import arvados
-
-old_uuid = "zzzzz-tpzed-xxxxxxxxxxxxxxx"
-new_uuid = "zzzzz-tpzed-yyyyyyyyyyyyyyy"
-
-page = 100
-offset = 0
-cols = []
-
-filters = [['properties.responsible_person_uuid', '=', '{}'.format(old_uuid)]]
-api = arvados.api()
-req = api.collections().list(filters=filters, select=['uuid', 'properties'], limit=page).execute()
-
-while True:
-    cols += [c for c in req['items']]
-    if req['items_available'] < offset+page:
-        break
-    offset += page
-    req = api.collections().list(filters=filters, select=['uuid', 'properties'], limit=page, offset=offset).execute()
-
-print("Found {} collections".format(len(cols)))
-for c in cols:
-    print("Updating collection {}".format(c["uuid"]))
-    props = c['properties']
-    props['responsible_person_uuid'] = new_uuid
-    api.collections().update(uuid=c['uuid'], body={'properties': props}).execute()
+{% include 'admin_update_collection_property_py' %}
 {% endcodeblock %}
 

-----------------------------------------------------------------------


hooks/post-receive
-- 




More information about the arvados-commits mailing list