[galaxy-dev] example_watch_folder.py : URL did not return JSON data

2013-03-12 Thread Rob Leclerc
I'm trying to get the example_watch_folder.py to work with a simple
example, but I am running into an error (Caveat, python is not
my native language)

I call the following script, but get the subsequent error:

$ ./example_watch_folder.py 8c25bc83f6f9e4001dd21eb7b64f063f
http://localhost:8080/ /Users/Rob/Documents/galaxy-db/input/
/Users/Rob/Documents/galaxy-db/output/ "API Imports" 2a56795cad3c7db3


  * URL did not return JSON data*


The preconditions I have in place are:

1. I copied my api_key: 8c25bc83f6f9e4001dd21eb7b64f063f


2. I created a new history on http://localhost:8080

3. I downloaded the the exons from hg19/chr22 from UCSC

3. On the dataset I performed a Text Manipulation > Select first (20 lines)

4. I extracted a workflow from the history and recorded the workflow id
(2a56795cad3c7db3).

5. I created directories:

   - /Users/Rob/Documents/galaxy-db/input/
   - /Users/Rob/Documents/galaxy-db/output/


My args may be malformed. Can someone provide me an example of a theirs?

Cheers,
Rob
___
Please keep all replies on the list by using "reply all"
in your mail client.  To manage your subscriptions to this
and other Galaxy lists, please use the interface at:

  http://lists.bx.psu.edu/

Re: [galaxy-dev] example_watch_folder.py : URL did not return JSON data

2013-03-12 Thread Dannon Baker
The second argument there should point to the url of Galaxy's API --
in this case http://localhost:8080/api, I'm guessing.

-Dannon

On Tue, Mar 12, 2013 at 6:11 PM, Rob Leclerc  wrote:
>
> I'm trying to get the example_watch_folder.py to work with a simple example,
> but I am running into an error (Caveat, python is not my native language)
>
> I call the following script, but get the subsequent error:
>
> $ ./example_watch_folder.py 8c25bc83f6f9e4001dd21eb7b64f063f
> http://localhost:8080/ /Users/Rob/Documents/galaxy-db/input/
> /Users/Rob/Documents/galaxy-db/output/ "API Imports" 2a56795cad3c7db3
>
>
>URL did not return JSON data
>
>
> The preconditions I have in place are:
>
> 1. I copied my api_key: 8c25bc83f6f9e4001dd21eb7b64f063f
>
>
> 2. I created a new history on http://localhost:8080
>
> 3. I downloaded the the exons from hg19/chr22 from UCSC
>
> 3. On the dataset I performed a Text Manipulation > Select first (20 lines)
>
> 4. I extracted a workflow from the history and recorded the workflow id
> (2a56795cad3c7db3).
>
> 5. I created directories:
>
> /Users/Rob/Documents/galaxy-db/input/
> /Users/Rob/Documents/galaxy-db/output/
>
>
> My args may be malformed. Can someone provide me an example of a theirs?
>
> Cheers,
> Rob
>
>
>
> ___
> Please keep all replies on the list by using "reply all"
> in your mail client.  To manage your subscriptions to this
> and other Galaxy lists, please use the interface at:
>
>   http://lists.bx.psu.edu/
___
Please keep all replies on the list by using "reply all"
in your mail client.  To manage your subscriptions to this
and other Galaxy lists, please use the interface at:

  http://lists.bx.psu.edu/


Re: [galaxy-dev] example_watch_folder.py : URL did not return JSON data

2013-03-12 Thread Rob Leclerc
Hi Dannon. Thanks! I had been experimenting with BioBlend and forgot to add
the /api/ on the url.

./example_watch_folder.py 8c25bc83f6f9e4001dd21eb7b64f063f
http://localhost:8080/api/ /Users/Rob/Documents/galaxy-db/input/
/Users/Rob/Documents/galaxy-db/output/ "API Imports" 2a56795cad3c7db3


However, I am now running into a new error when it tries to create the API
Imports folder

Traceback (most recent call last):
  File "./example_watch_folder.py", line 87, in 
main(api_key, api_url, in_folder, out_folder, data_library, workflow )
  File "./example_watch_folder.py", line 30, in main
library_id = library[0]['id']
KeyError: 0

(This is coming from the section that creates 'API Imports' library if it
doesn't already exist)

24:  for library in libs:

25:  if library['name'] == data_library:

26: library_id = library['id']

27:  if not library_id:

28:lib_create_data = {'name':data_library}

29:library = submit(api_key, api_url + 'libraries',
lib_create_data, return_formatted=False)

30:library_id = library[0]['id']


As I mentioned, I'm not familiar with python, but I can't see where
'library[0]['id']' is set or is in scope, since this seems to be the
item in the iterator above this section.


Cheers,

Rob



Rob Leclerc, PhD
 
P: (US) +1-(917)-873-3037
P: (Shanghai) +86-1-(861)-612-5469
Personal Email: rob.lecl...@aya.yale.edu


On Tue, Mar 12, 2013 at 6:14 PM, Dannon Baker wrote:

> The second argument there should point to the url of Galaxy's API --
> in this case http://localhost:8080/api, I'm guessing.
>
> -Dannon
>
> On Tue, Mar 12, 2013 at 6:11 PM, Rob Leclerc 
> wrote:
> >
> > I'm trying to get the example_watch_folder.py to work with a simple
> example,
> > but I am running into an error (Caveat, python is not my native language)
> >
> > I call the following script, but get the subsequent error:
> >
> > $ ./example_watch_folder.py 8c25bc83f6f9e4001dd21eb7b64f063f
> > http://localhost:8080/ /Users/Rob/Documents/galaxy-db/input/
> > /Users/Rob/Documents/galaxy-db/output/ "API Imports" 2a56795cad3c7db3
> >
> >
> >URL did not return JSON data
> >
> >
> > The preconditions I have in place are:
> >
> > 1. I copied my api_key: 8c25bc83f6f9e4001dd21eb7b64f063f
> >
> >
> > 2. I created a new history on http://localhost:8080
> >
> > 3. I downloaded the the exons from hg19/chr22 from UCSC
> >
> > 3. On the dataset I performed a Text Manipulation > Select first (20
> lines)
> >
> > 4. I extracted a workflow from the history and recorded the workflow id
> > (2a56795cad3c7db3).
> >
> > 5. I created directories:
> >
> > /Users/Rob/Documents/galaxy-db/input/
> > /Users/Rob/Documents/galaxy-db/output/
> >
> >
> > My args may be malformed. Can someone provide me an example of a theirs?
> >
> > Cheers,
> > Rob
> >
> >
> >
> > ___
> > Please keep all replies on the list by using "reply all"
> > in your mail client.  To manage your subscriptions to this
> > and other Galaxy lists, please use the interface at:
> >
> >   http://lists.bx.psu.edu/
>
___
Please keep all replies on the list by using "reply all"
in your mail client.  To manage your subscriptions to this
and other Galaxy lists, please use the interface at:

  http://lists.bx.psu.edu/

Re: [galaxy-dev] example_watch_folder.py : URL did not return JSON data

2013-03-13 Thread Dannon Baker
It should be set on line 29 as the result of that submit function.  Can you
add (between 29 and 30) a 'print library' to see what that call actually
results in?

Off the top of my head, this might be happening if your user account (that
the API key is associated with) isn't an admin account -- only admins can
create Data Libraries.

On Tue, Mar 12, 2013 at 6:35 PM, Rob Leclerc wrote:

> Hi Dannon. Thanks! I had been experimenting with BioBlend and forgot to
> add the /api/ on the url.
>
> ./example_watch_folder.py 8c25bc83f6f9e4001dd21eb7b64f063f
> http://localhost:8080/api/ /Users/Rob/Documents/galaxy-db/input/
> /Users/Rob/Documents/galaxy-db/output/ "API Imports" 2a56795cad3c7db3
>
>
> However, I am now running into a new error when it tries to create the API
> Imports folder
>
> Traceback (most recent call last):
>   File "./example_watch_folder.py", line 87, in 
> main(api_key, api_url, in_folder, out_folder, data_library, workflow )
>   File "./example_watch_folder.py", line 30, in main
> library_id = library[0]['id']
> KeyError: 0
>
> (This is coming from the section that creates 'API Imports' library if it
> doesn't already exist)
>
> 24:  for library in libs:
>
> 25:  if library['name'] == data_library:
>
> 26: library_id = library['id']
>
> 27:  if not library_id:
>
> 28:lib_create_data = {'name':data_library}
>
> 29:library = submit(api_key, api_url + 'libraries', lib_create_data, 
> return_formatted=False)
>
> 30:library_id = library[0]['id']
>
>
> As I mentioned, I'm not familiar with python, but I can't see where 
> 'library[0]['id']' is set or is in scope, since this seems to be the item in 
> the iterator above this section.
>
>
> Cheers,
>
> Rob
>
>
>
> Rob Leclerc, PhD
> 
> P: (US) +1-(917)-873-3037
> P: (Shanghai) +86-1-(861)-612-5469
> Personal Email: rob.lecl...@aya.yale.edu
>
>
> On Tue, Mar 12, 2013 at 6:14 PM, Dannon Baker wrote:
>
>> The second argument there should point to the url of Galaxy's API --
>> in this case http://localhost:8080/api, I'm guessing.
>>
>> -Dannon
>>
>> On Tue, Mar 12, 2013 at 6:11 PM, Rob Leclerc 
>> wrote:
>> >
>> > I'm trying to get the example_watch_folder.py to work with a simple
>> example,
>> > but I am running into an error (Caveat, python is not my native
>> language)
>> >
>> > I call the following script, but get the subsequent error:
>> >
>> > $ ./example_watch_folder.py 8c25bc83f6f9e4001dd21eb7b64f063f
>> > http://localhost:8080/ /Users/Rob/Documents/galaxy-db/input/
>> > /Users/Rob/Documents/galaxy-db/output/ "API Imports" 2a56795cad3c7db3
>> >
>> >
>> >URL did not return JSON data
>> >
>> >
>> > The preconditions I have in place are:
>> >
>> > 1. I copied my api_key: 8c25bc83f6f9e4001dd21eb7b64f063f
>> >
>> >
>> > 2. I created a new history on http://localhost:8080
>> >
>> > 3. I downloaded the the exons from hg19/chr22 from UCSC
>> >
>> > 3. On the dataset I performed a Text Manipulation > Select first (20
>> lines)
>> >
>> > 4. I extracted a workflow from the history and recorded the workflow id
>> > (2a56795cad3c7db3).
>> >
>> > 5. I created directories:
>> >
>> > /Users/Rob/Documents/galaxy-db/input/
>> > /Users/Rob/Documents/galaxy-db/output/
>> >
>> >
>> > My args may be malformed. Can someone provide me an example of a theirs?
>> >
>> > Cheers,
>> > Rob
>> >
>> >
>> >
>> > ___
>> > Please keep all replies on the list by using "reply all"
>> > in your mail client.  To manage your subscriptions to this
>> > and other Galaxy lists, please use the interface at:
>> >
>> >   http://lists.bx.psu.edu/
>>
>
>
___
Please keep all replies on the list by using "reply all"
in your mail client.  To manage your subscriptions to this
and other Galaxy lists, please use the interface at:

  http://lists.bx.psu.edu/

Re: [galaxy-dev] example_watch_folder.py : URL did not return JSON data

2013-03-13 Thread Rob Leclerc
Hi Dannon,

Thanks. I've moved to a full size monitor, apparently my eyes are going!

They *key error: 0* seems to be the result of a bug in the code.

print(library)


results in:

{'url': '/api/libraries/4b187121143038ff', 'id': '4b187121143038ff',
'name': 'API Import11'}


So library[0]['id'] doesn't point to anything, resulting in the key error.
I changed the code on line 30

library_id = library['id']


This seems to fix the issue. I've now got to the section of code where I am
watching the in_folder, but there doesn't seem to be any subsequent
activity. I'll post my findings or questions as I make progress or lack
thereof.

Cheers,
Rob



On Wed, Mar 13, 2013 at 7:35 AM, Dannon Baker wrote:

> It should be set on line 29 as the result of that submit function.  Can
> you add (between 29 and 30) a 'print library' to see what that call
> actually results in?
>
> Off the top of my head, this might be happening if your user account (that
> the API key is associated with) isn't an admin account -- only admins can
> create Data Libraries.
>
>
> On Tue, Mar 12, 2013 at 6:35 PM, Rob Leclerc wrote:
>
>> Hi Dannon. Thanks! I had been experimenting with BioBlend and forgot to
>> add the /api/ on the url.
>>
>> ./example_watch_folder.py 8c25bc83f6f9e4001dd21eb7b64f063f
>> http://localhost:8080/api/ /Users/Rob/Documents/galaxy-db/input/
>> /Users/Rob/Documents/galaxy-db/output/ "API Imports" 2a56795cad3c7db3
>>
>>
>> However, I am now running into a new error when it tries to create the
>> API Imports folder
>>
>> Traceback (most recent call last):
>>   File "./example_watch_folder.py", line 87, in 
>> main(api_key, api_url, in_folder, out_folder, data_library, workflow )
>>   File "./example_watch_folder.py", line 30, in main
>> library_id = library[0]['id']
>> KeyError: 0
>>
>> (This is coming from the section that creates 'API Imports' library if it
>> doesn't already exist)
>>
>> 24:  for library in libs:
>>
>> 25:  if library['name'] == data_library:
>>
>> 26: library_id = library['id']
>>
>> 27:  if not library_id:
>>
>> 28:lib_create_data = {'name':data_library}
>>
>> 29:library = submit(api_key, api_url + 'libraries', lib_create_data, 
>> return_formatted=False)
>>
>> 30:library_id = library[0]['id']
>>
>>
>> As I mentioned, I'm not familiar with python, but I can't see where 
>> 'library[0]['id']' is set or is in scope, since this seems to be the item in 
>> the iterator above this section.
>>
>>
>>
>>
>> Cheers,
>>
>> Rob
>>
>>
>>
>>
>> On Tue, Mar 12, 2013 at 6:14 PM, Dannon Baker wrote:
>>
>>> The second argument there should point to the url of Galaxy's API --
>>> in this case http://localhost:8080/api, I'm guessing.
>>>
>>> -Dannon
>>>
>>> On Tue, Mar 12, 2013 at 6:11 PM, Rob Leclerc 
>>> wrote:
>>> >
>>> > I'm trying to get the example_watch_folder.py to work with a simple
>>> example,
>>> > but I am running into an error (Caveat, python is not my native
>>> language)
>>> >
>>> > I call the following script, but get the subsequent error:
>>> >
>>> > $ ./example_watch_folder.py 8c25bc83f6f9e4001dd21eb7b64f063f
>>> > http://localhost:8080/ /Users/Rob/Documents/galaxy-db/input/
>>> > /Users/Rob/Documents/galaxy-db/output/ "API Imports" 2a56795cad3c7db3
>>> >
>>> >
>>> >URL did not return JSON data
>>> >
>>> >
>>> > The preconditions I have in place are:
>>> >
>>> > 1. I copied my api_key: 8c25bc83f6f9e4001dd21eb7b64f063f
>>> >
>>> >
>>> > 2. I created a new history on http://localhost:8080
>>> >
>>> > 3. I downloaded the the exons from hg19/chr22 from UCSC
>>> >
>>> > 3. On the dataset I performed a Text Manipulation > Select first (20
>>> lines)
>>> >
>>> > 4. I extracted a workflow from the history and recorded the workflow id
>>> > (2a56795cad3c7db3).
>>> >
>>> > 5. I created directories:
>>> >
>>> > /Users/Rob/Documents/galaxy-db/input/
>>> > /Users/Rob/Documents/galaxy-db/output/
>>> >
>>> >
>>> > My args may be malformed. Can someone provide me an example of a
>>> theirs?
>>> >
>>> > Cheers,
>>> > Rob
>>> >
>>> >
>>> >
>>> > ___
>>> > Please keep all replies on the list by using "reply all"
>>> > in your mail client.  To manage your subscriptions to this
>>> > and other Galaxy lists, please use the interface at:
>>> >
>>> >   http://lists.bx.psu.edu/
>>>
>>
>>
>
___
Please keep all replies on the list by using "reply all"
in your mail client.  To manage your subscriptions to this
and other Galaxy lists, please use the interface at:

  http://lists.bx.psu.edu/

Re: [galaxy-dev] example_watch_folder.py : URL did not return JSON data

2013-03-13 Thread Rob Leclerc
I was able to get the script to work. I've written down some notes for a
quickstart for anyone else who might be following in my footsteps.

1. Create input and output directores where you will drop and emit files.
In my example I used:

/Users/Rob/Documents/galaxy-drop/input

/Users/Rob/Documents/galaxy-drop/output

2. Edit the galaxy-dist configuration script (universe_wsgi.ini) and set:

allow_library_path_paste = true


3. In example_watch_folder.py, comment out line 30 and replace it with:

#library_id = library[0]['id]  This causes a "key error : 0"

   library_id = library['id']

4. CREATE A SAMPLE Workflow & Dataset:


   1. Start Galaxy
   2. Go to USCS and upload the Exons from chr22 to your clean history file
   3. Use the Text Manipulation tool to select the first 5 lines of the
   gene exon file
   4. Extract the workflow
   5. *RESTART Galaxy* (You'll get a 500 Internal Server Error if you try
   to run this without restarting)
   6. Download the exons file to local

5. In your browser go to: http://localhost:8080/api/workflows and identify
the id of the workflow you've just created. Let's assume it is
(4b187121143038ff) and that your api_key for admin is
(8c25bc83f6f9e4001dd21eb7b64f063f)

6. Run the script:

./example_watch_folder.py 8c25bc83f6f9e4001dd21eb7b64f063f
http://localhost:8080/api/ /Users/Rob/Documents/galaxy-drop/input
/Users/Rob/Documents/galaxy-drop/output "My API Import" 4b187121143038ff


7. Copy the exons file to /Users/Rob/Documents/galaxy-drop/input when the
process is complete the file will be placed in
/Users/Rob/Documents/galaxy-drop/output

8. In your browser go to: http://localhost:8080/api/histories locate the
recently created history and then navigate to:

http://localhost:8080/api/histories//contents

where  is the id of the history that was created when you ran
the dataset on the last workflow.

This is my result. The second file is the output file.

[
{
"id": "0d16186aaff7cbfd",
"name": "Galaxy1-[Exons_chr22].bed",
"type": "file",
"url": "/api/histories/2d9035b3fc152403/contents/0d16186aaff7cbfd"
},
{
"id": "81991b32733a4fc4",
"name": "top200",
"type": "file",
"url": "/api/histories/2d9035b3fc152403/contents/81991b32733a4fc4"
]


9. You can navigate to the JSON description of the file in your browser:

http://localhost:8080/api/histories/2d9035b3fc152403/contents/81991b32733a4fc4


and the output file can be downloaded here:

http:localhost:8080/datasets/81991b32733a4fc4/display?to_ext=data


Cheers!
Rob


On Wed, Mar 13, 2013 at 12:15 PM, Rob Leclerc wrote:

> Hi Dannon,
>
> Thanks. I've moved to a full size monitor, apparently my eyes are going!
>
> They *key error: 0* seems to be the result of a bug in the code.
>
> print(library)
>
>
> results in:
>
> {'url': '/api/libraries/4b187121143038ff', 'id': '4b187121143038ff',
> 'name': 'API Import11'}
>
>
> So library[0]['id'] doesn't point to anything, resulting in the key error.
> I changed the code on line 30
>
> library_id = library['id']
>
>
> This seems to fix the issue. I've now got to the section of code where I
> am watching the in_folder, but there doesn't seem to be any subsequent
> activity. I'll post my findings or questions as I make progress or lack
> thereof.
>
> Cheers,
> Rob
>
>
>
> On Wed, Mar 13, 2013 at 7:35 AM, Dannon Baker wrote:
>
>> It should be set on line 29 as the result of that submit function.  Can
>> you add (between 29 and 30) a 'print library' to see what that call
>> actually results in?
>>
>> Off the top of my head, this might be happening if your user account
>> (that the API key is associated with) isn't an admin account -- only admins
>> can create Data Libraries.
>>
>>
>> On Tue, Mar 12, 2013 at 6:35 PM, Rob Leclerc wrote:
>>
>>> Hi Dannon. Thanks! I had been experimenting with BioBlend and forgot to
>>> add the /api/ on the url.
>>>
>>> ./example_watch_folder.py 8c25bc83f6f9e4001dd21eb7b64f063f
>>> http://localhost:8080/api/ /Users/Rob/Documents/galaxy-db/input/
>>> /Users/Rob/Documents/galaxy-db/output/ "API Imports" 2a56795cad3c7db3
>>>
>>>
>>> However, I am now running into a new error when it tries to create the
>>> API Imports folder
>>>
>>> Traceback (most recent call last):
>>>   File "./example_watch_folder.py", line 87, in 
>>> main(api_key, api_url, in_folder, out_folder, data_library, workflow
>>> )
>>>   File "./example_watch_folder.py", line 30, in main
>>> library_id = library[0]['id']
>>> KeyError: 0
>>>
>>> (This is coming from the section that creates 'API Imports' library if
>>> it doesn't already exist)
>>>
>>> 24:  for library in libs:
>>>
>>> 25:  if library['name'] == data_library:
>>>
>>> 26: library_id = library['id']
>>>
>>> 27:  if not library_id:
>>>
>>> 28:lib_create_data = {'name':data_library}
>>>
>>> 29:library = submit(api_key, api_url + 'libraries', 
>>> lib_create_data, return_formatted=False)
>>>
>>> 30:library_