There were several issues and bugs I encountered getting this 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" -- remove the indexing

           library_id = library['id']

4. In example_watch_folder.py change the sleep duration on line 59 to 15 seconds. If you're still getting zero byte .dat files, then you'll need to extend the duration even more.

time.sleep(15)

5. 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. IMPORTANT: If you don't do the following step you'll get a 500 Internal Server.
  6. Change the output filename in the workflow and then save the workflow. 
  7. Test that the workflow is accessable by visiting 'http://<galaxy_server/api/workflows' in your browser, and then visit 'http://<galaxy_server/api/workflows/<workflow_id>
  8. Download the exons file to local
6. 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 <api_key>

7. Run the script:

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

8. 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

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

where <history_id> 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"
] 

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


and the output file can be downloaded here:
http:localhost:8080/datasets/81991b32733a4fc4/display?to_ext=data

Cheers!
Rob



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