[ARVADOS] updated: 30c250473cd62b845acbec8a9af182410d572873
git at public.curoverse.com
git at public.curoverse.com
Thu Jan 2 19:32:56 EST 2014
Summary of changes:
crunch_scripts/pgp-survey-import | 12 ++++++------
doc/user/reference/sdk-python.textile | 8 --------
doc/user/tutorials/tutorial-trait-search.textile | 19 +++++++++----------
3 files changed, 15 insertions(+), 24 deletions(-)
via 30c250473cd62b845acbec8a9af182410d572873 (commit)
from 4c69fbec263b5eeea23d11ee93fb002d028e2b6f (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 30c250473cd62b845acbec8a9af182410d572873
Author: Tom Clegg <tom at curoverse.com>
Date: Thu Jan 2 16:29:28 2014 -0800
Remove json.dumps() from example and tutorial code.
(Not necessary since 4c69fbec263b5eeea23d11ee93fb002d028e2b6f)
closes #1819
diff --git a/crunch_scripts/pgp-survey-import b/crunch_scripts/pgp-survey-import
index df5758b..4e11812 100755
--- a/crunch_scripts/pgp-survey-import
+++ b/crunch_scripts/pgp-survey-import
@@ -31,7 +31,7 @@ for input_file in arvados.CollectionReader(this_job_input).all_files():
if line_number == 0:
headings = words
for t in arvados.api('v1').traits().list(
- where=json.dumps({'name':words}),
+ where={'name':words},
limit=1000
).execute()['items']:
traits[t['name']] = t
@@ -39,19 +39,19 @@ for input_file in arvados.CollectionReader(this_job_input).all_files():
# find or create trait
if trait_name not in traits:
traits_match = arvados.api('v1').traits().list(
- where=json.dumps({'name':trait_name})
+ where={'name':trait_name}
).execute()['items']
if len(traits_match) > 0:
traits[trait_name] = traits_match[0]
else:
traits[trait_name] = arvados.api('v1').traits().create(
- trait=json.dumps({'name':trait_name})).execute()
+ trait={'name':trait_name}).execute()
out.write(separator)
out.write(json.dumps(traits[trait_name]))
separator = ",\n"
else:
huID_links_match = arvados.api('v1').links().list(
- where=json.dumps({'link_class':'identifier','name':words[0]})
+ where={'link_class':'identifier','name':words[0]}
).execute()['items']
if len(huID_links_match) > 0:
human_uuid = huID_links_match[0]['head_uuid']
@@ -71,13 +71,13 @@ for input_file in arvados.CollectionReader(this_job_input).all_files():
human_trait = {}
for t in arvados.api('v1').links().list(
limit=10000,
- where=json.dumps({
+ where={
'tail_uuid':human_uuid,
'tail_kind':'arvados#human',
'head_kind':'arvados#trait',
'link_class':'human_trait',
'name':'pgp-survey-response'
- })
+ }
).execute()['items']:
human_trait[t['head_uuid']] = t
for i, trait_value in enumerate(words[3:], start=3):
diff --git a/doc/user/reference/sdk-python.textile b/doc/user/reference/sdk-python.textile
index 29212c1..288a9d5 100644
--- a/doc/user/reference/sdk-python.textile
+++ b/doc/user/reference/sdk-python.textile
@@ -108,14 +108,6 @@ Many API methods accept a parameter whose name is the same as the resource type.
</code></pre>
</notextile>
-Currently, non-atom parameter values (hashes and lists) other than @body@ must be explicitly encoded using @json.dumps()@. (This will be fixed in a future release.)
-
-<notextile>
-<pre><code class="userinput">arvados.api('v1').links().list(
- where=json.dumps({'link_class':'permission'})).execute()
-</code></pre>
-</notextile>
-
One way to make API calls slightly less verbose is:
<notextile>
diff --git a/doc/user/tutorials/tutorial-trait-search.textile b/doc/user/tutorials/tutorial-trait-search.textile
index 4f4ec9c..0381d28 100644
--- a/doc/user/tutorials/tutorial-trait-search.textile
+++ b/doc/user/tutorials/tutorial-trait-search.textile
@@ -29,11 +29,10 @@ If everything is set up correctly, you will be able to import the arvados SDK.
notextile. <pre><code>>>> <span class="userinput">import arvados</span></pre></code>
-This tutorial will also use the regular expression (re) and json python modules:
+This tutorial will also use the regular expression (re) python module:
<notextile>
<pre><code>>>> <span class="userinput">import re</span>
->>> <span class="userinput">import json</span>
</code></pre>
</notextile>
@@ -72,11 +71,11 @@ h2. Finding humans with the selected trait
We query the "links" resource to find humans that report the selected trait. Links are directional connections between Arvados data items, for example, from a human to their reported traits.
<notextile>
-<pre><code>>>> <span class="userinput">trait_query = json.dumps({
+<pre><code>>>> <span class="userinput">trait_query = {
'link_class': 'human_trait',
'tail_kind': 'arvados#human',
'head_uuid': non_melanoma_cancer
- })
+ }
</code></pre>
</notextile>
@@ -125,10 +124,10 @@ u'1h9kt-7a9it-t1v8sjz6dm9jmjf', u'1h9kt-7a9it-qe8wrbyvuqs5jew']
h2. Find Personal Genome Project identifiers from Arvados UUIDs
<notextile>
-<pre><code>>>> <span class="userinput">human_query = json.dumps({
+<pre><code>>>> <span class="userinput">human_query = {
"link_class": "identifier",
"head_uuid": human_uuids
- })</span>
+ }</span>
>>> <span class="userinput">pgpid_links = arvados.api('v1').links().list(limit=1000, where=human_query).execute()</span>
>>> <span class="userinput">map(lambda l: l['name'], pgpid_links['items'])</span>
[u'hu01024B', u'hu11603C', u'hu15402B', u'hu174334', u'hu1BD549', u'hu237A50',
@@ -151,11 +150,11 @@ h2. Find genomic data from specific humans
Now we want to find collections in Keep that were provided by these humans. We search the "links" resource for "provenance" links that point to subjects in list of humans with the non-melanoma skin cancer trait:
<notextile>
-<pre><code>>>> <span class="userinput">provenance_links = arvados.api().links().list(limit=1000, where=json.dumps({
+<pre><code>>>> <span class="userinput">provenance_links = arvados.api().links().list(limit=1000, where={
"link_class": "provenance",
"name": "provided",
"tail_uuid": human_uuids
- })).execute()
+ }).execute()
collection_uuids = map(lambda l: l['head_uuid'], provenance_links['items'])
# build map of human uuid -> PGP ID
@@ -168,9 +167,9 @@ for p_link in provenance_links['items']:
pgpid[p_link['head_uuid']] = pgpid[p_link['tail_uuid']]
# get details (e.g., list of files) of each collection
-collections = arvados.api('v1').collections().list(where=json.dumps({
+collections = arvados.api('v1').collections().list(where={
"uuid": collection_uuids
- })).execute()
+ }).execute()
# print PGP public profile links with file locators
for c in collections['items']:
-----------------------------------------------------------------------
hooks/post-receive
--
More information about the arvados-commits
mailing list