hexylena/galaxy-data_source-examples

Fail to set up Asynchronous Communication

Closed this issue · 6 comments

first of all thank you very much for these examples.
I'm trying to set up the Cherry examples.

It works with Synchronous Communication.

But I fail with Asynchronous mode.

I don't understand here:
https://github.com/erasche/galaxy-data_source-examples/blob/4331ce408f14e2c7649dd9786e29c0d8cba4ecdc/cherrypy/server.py#L57

data_id is equal to -1 (when I first launch the tool Cherry Py Async teston the galaxy interface), so I never go into this. Then the form is displayed. I can submit it. But Galaxy shows me an error in the log:

Traceback (most recent call last):
File "lib/galaxy/web/framework/middleware/batch.py", line 80, in call
return self.application(environ, start_response)
File "lib/galaxy/web/framework/middleware/request_id.py", line 15, in call
return self.app(environ, start_response)
File "lib/galaxy/web/framework/middleware/xforwardedhost.py", line 23, in call
return self.app(environ, start_response)
File "lib/galaxy/web/framework/middleware/translogger.py", line 71, in call
return self.application(environ, replacement_start_response)
File "lib/galaxy/web/framework/middleware/error.py", line 166, in call
response = self.exception_handler(exc_info, environ)
File "lib/galaxy/web/framework/middleware/error.py", line 181, in exception_handler
get_vars = wsgilib.parse_querystring(environ)
File "/softs/bioinfo/galaxy-dev/.venv/lib/python2.7/site-packages/paste/request.py", line 107, in parse_querystring
strict_parsing=False)
File "/softs/add-ons/Python-2.7.12/lib/python2.7/urlparse.py", line 409, in parse_qsl
pairs = [s2 for s1 in qs.split('&') for s2 in s1.split(';')]
File "lib/galaxy/web/framework/middleware/error.py", line 154, in call
app_iter = self.application(environ, sr_checker)
File "/softs/bioinfo/galaxy-dev/.venv/lib/python2.7/site-packages/paste/recursive.py", line 85, in call
return self.application(environ, start_response)
File "/softs/bioinfo/galaxy-dev/.venv/lib/python2.7/site-packages/paste/httpexceptions.py", line 640, in call
return self.application(environ, start_response)
File "lib/galaxy/web/framework/base.py", line 143, in call
return self.handle_request(environ, start_response)
File "lib/galaxy/web/framework/base.py", line 222, in handle_request
body = method(trans, **kwargs)
File "lib/galaxy/webapps/galaxy/controllers/async.py", line 150, in index
open(data.file_name, 'wb').close() # create the file
IOError: [Errno 2] No such file or directory: ''

so I tried to change if int(data_id) != -1: to if int(data_id) == -1:
In this case, the file is created. The interface prints OK but for the next step, it looks like I can't pass the authentication:
https://github.com/erasche/galaxy-data_source-examples/blob/4331ce408f14e2c7649dd9786e29c0d8cba4ecdc/cherrypy/generate_data_async#L23

I misunderstand something, but I can't see it right now. Could you help me?
Thank you.

Hi @FredericBGA I'm afraid I've never used the Cherry versions, and the person who contributed them has since moved on.

If you have questions on the flask version I can definitely help with that?

Hi, i will try the Flask example!

Ok, I managed to run the example with flask as well.
I have had to install older version of Flask (1.0) and future (0.12.0) otherwise I had errors like this:

AttributeError: encode method has been disabled in newbytes

And I'm still successful with Synchronous mode.

Using Asynchronous mode, when I run python async_finish.py I think that I'm facing the same error as when using Cherry.
If I understand async_finish.py pings Galaxy, with STATUS=OK and an URL where Galaxy will be able to get the file.
But I'm afraid that I need to be authenticated because I see a redirect to root/login in the log:

[pid: 31500|app: 0|req: 3021/6037] 192.168.109.144 () {54 vars in 1086 bytes} [Tue Jul 16 17:20:56 2019] GET /async/ds_test_async?STATUS=OK&URL=https%3A%2F%2Fgalaxydev.biogemma.fr%3A4430%2Fdata%2Ftemp.dat => generated 154 bytes in 15 msecs (HTTP/1.1 302) 5 headers in 400 bytes (1 switches on core 2)
192.168.109.144 - - [16/Jul/2019:17:20:56 +0200] "GET /root/login?redirect=%2Fasync%2Fds_test_async HTTP/1.1" 200 - "-" "Python-urllib/2.7"
[pid: 31500|app: 0|req: 3022/6038] 192.168.109.144 () {54 vars in 959 bytes} [Tue Jul 16 17:20:56 2019] GET /root/login?redirect=%2Fasync%2Fds_test_async => generated 4325 bytes in 17 msecs (HTTP/1.1 200) 3 headers in 289 bytes (1 switches on core 7)

I'm afraid that I really miss something obvious here.

I also tried to call the URL in my browser (I'm authenticated in this session) with a file that I'm sure it exists (ie: https://www.uniprot.org/uniprot/Q84Y01.txt), but I see an error:

"GET /async/ds_test_async?STATUS=OK&URL=https://www.uniprot.org/uniprot/Q84Y01.txt HTTP/1.1" 500 - "-" "Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:68.0) Gecko/20100101 Firefox/68.0"
Traceback (most recent call last):
File "lib/galaxy/web/framework/middleware/batch.py", line 80, in call
return self.application(environ, start_response)
File "lib/galaxy/web/framework/middleware/request_id.py", line 15, in call
return self.app(environ, start_response)
File "lib/galaxy/web/framework/middleware/xforwardedhost.py", line 23, in call
return self.app(environ, start_response)
File "lib/galaxy/web/framework/middleware/translogger.py", line 71, in call
return self.application(environ, replacement_start_response)
File "lib/galaxy/web/framework/middleware/error.py", line 166, in call
response = self.exception_handler(exc_info, environ)
File "lib/galaxy/web/framework/middleware/error.py", line 181, in exception_handler
get_vars = wsgilib.parse_querystring(environ)
File "/softs/bioinfo/galaxy-dev/.venv/lib/python2.7/site-packages/paste/request.py", line 107, in parse_querystring
strict_parsing=False)
File "/softs/add-ons/Python-2.7.12/lib/python2.7/urlparse.py", line 409, in parse_qsl
pairs = [s2 for s1 in qs.split('&') for s2 in s1.split(';')]
File "lib/galaxy/web/framework/middleware/error.py", line 154, in call
app_iter = self.application(environ, sr_checker)
File "/softs/bioinfo/galaxy-dev/.venv/lib/python2.7/site-packages/paste/recursive.py", line 85, in call
return self.application(environ, start_response)
File "/softs/bioinfo/galaxy-dev/.venv/lib/python2.7/site-packages/paste/httpexceptions.py", line 640, in call
return self.application(environ, start_response)
File "lib/galaxy/web/framework/base.py", line 143, in call
return self.handle_request(environ, start_response)
File "lib/galaxy/web/framework/base.py", line 222, in handle_request
body = method(trans, **kwargs)
File "lib/galaxy/webapps/galaxy/controllers/async.py", line 150, in index
open(data.file_name, 'wb').close() # create the file
IOError: [Errno 2] No such file or directory: ''

What I have test so far...

On my dev server, I overcame manually the empty data.file_name

        if data.file_name == '':
            data.file_name = '/softs/bioinfo/galaxy-dev/database/files/080/dataset_80224.dat'
        open(data.file_name, 'wb').close()  # create the file

so now the dataset is well created in my history, and Galaxy then wait for python async_finish.py

so python async_finish.py pings https://galaxydev.biogemma.fr/async/ds_test_async/84015/a2463a1e5dce6fdba68ac4867277f6b8a599cccc?STATUS=OK&URL=https%3A%2F%2Fgalaxydev.biogemma.fr%3A4430%2Fdata%2Ftemp.dat

But again I'm facing the authentication issue...
If I copy and paste the link in my browser (as I'm authenticated here), it works! The dataset is created in history and it holds the right content!

Do you think that the first error (missing file_name for the dataset) is a Galaxy issue that i can report?
I don't understand the authentication issue. a2463a1e5dce6fdba68ac4867277f6b8a599cccc it is a kind of key or session token that would allow the connection?

it was a bug!
galaxy git