opencb / opencga

An Open Computational Genomics Analysis platform for big data genomics analysis. OpenCGA is maintained and develop by its parent company Zetta Genomics. Please contact support@zettagenomics.com for bug report and feature requests.
Apache License 2.0
166 stars 97 forks source link

pyopencga isn't compatible with v2.0.0 #1576

Open Joe-Heffer-Shef opened 4 years ago

Joe-Heffer-Shef commented 4 years ago

Hi,

I'm running the demo Docker image:

docker run -d --name cga -e load=true --publish 9090:9090 --publish 27017:27017 --publish 8983:8983 --publish 28017:28017 opencb/opencga-demo:2.0.0-dev

This is the client test code:

"""
http://docs.opencb.org/display/opencga/Using+the+Python+client
"""

import logging

import pyopencga.opencga_config
import pyopencga.opencga_client

LOGGER = logging.getLogger(__name__)

CONFIG_INPUT = 'client_configuration.yaml'

USER = 'demo'
PASSWORD = 'demo'

def get_client(config_input=None) -> pyopencga.opencga_client.OpenCGAClient:
    config = pyopencga.opencga_config.ClientConfiguration(config_input=config_input or CONFIG_INPUT)

    client = pyopencga.opencga_client.OpenCGAClient(configuration=config)

    return client

def main():
    logging.basicConfig(level=logging.DEBUG)
    client = get_client()
    client.login(USER, PASSWORD)
    user_info = client.users.info()
    print(user_info)
    client.logout()

if __name__ == '__main__':
    main()

This is the error log:

DEBUG:urllib3.connectionpool:Starting new HTTP connection (1): localhost:9090
DEBUG:urllib3.connectionpool:http://localhost:9090 "HEAD /opencga-2.0.0-dev HTTP/1.1" 302 0
DEBUG:urllib3.connectionpool:Starting new HTTP connection (1): localhost:9090
DEBUG:urllib3.connectionpool:http://localhost:9090 "POST /opencga-2.0.0-dev/webservices/rest/v1/users/demo/login?skip=0&limit=1000 HTTP/1.1" 200 484
Traceback (most recent call last):
  File "cga_test.py", line 31, in <module>
    client.login(USER, PASSWORD)
  File "C:\Users\joesh\Miniconda3\envs\cga\lib\site-packages\pyopencga\opencga_client.py", line 130, in login
    self._login_handler()
  File "C:\Users\joesh\Miniconda3\envs\cga\lib\site-packages\pyopencga\opencga_client.py", line 112, in login_handler
    self.session_id = Users(self.configuration).login(user=user, pwd=pwd).responses[0]['results'][0]['token']
  File "C:\Users\joesh\Miniconda3\envs\cga\lib\site-packages\pyopencga\rest_clients\user_client.py", line 30, in login
    return self._post('login', data=data, query_id=user, **options)
  File "C:\Users\joesh\Miniconda3\envs\cga\lib\site-packages\pyopencga\rest_clients\_parent_rest_clients.py", line 80, in _post
    return self._rest_retry('post', resource, query_id, subcategory, second_query_id, data=data, **options)
  File "C:\Users\joesh\Miniconda3\envs\cga\lib\site-packages\pyopencga\rest_clients\_parent_rest_clients.py", line 68, in _rest_retry
    on_retry=notify_retry, dont_retry=dont_retry)
  File "C:\Users\joesh\Miniconda3\envs\cga\lib\site-packages\pyopencga\retry.py", line 36, in retry
    return func()
  File "C:\Users\joesh\Miniconda3\envs\cga\lib\site-packages\pyopencga\rest_clients\_parent_rest_clients.py", line 54, in exec_retry
    options=options)
  File "C:\Users\joesh\Miniconda3\envs\cga\lib\site-packages\pyopencga\commons.py", line 280, in execute
    query_id=query_id, second_query_id=second_query_id, **options)
  File "C:\Users\joesh\Miniconda3\envs\cga\lib\site-packages\pyopencga\commons.py", line 224, in _fetch
    for index, res in enumerate(response['response']):
KeyError: 'response'
Joe-Heffer-Shef commented 4 years ago

It looks like the response structure has changed with version 2.0.0

RESTful Web Services

imedina commented 4 years ago

Hi @Joe-Heffer-Shef Many thanks for taking the time to report and sorry for the issues. Just a few comments.

  1. Which version of pyopencga are you using? We are about to release 2.0.0-rc1 in the next couple of days, then we will deploy pyopencga-2.0.0-rc1 to PyPI
  2. Yes there are few changes in 2.0.0 compared to 1.4.x, but pyopencga makes many of them transparent. You can check OpenCGA 2.0.0 REST API here http://bioinfo.hpc.cam.ac.uk/opencga-prod/webservices/#/ (Swagger takes about 20 sec to display)
  3. The user and password are not demo/demo, take a look here: http://docs.opencb.org/display/opencga/Using+OpenCGA#UsingOpenCGA-Connectingtodemoinstallation
  4. Just in case you have missed it there is a Python documentation here: http://docs.opencb.org/display/opencga/Python
  5. In OpenCGA 2.0.0 most of the client code is auto-generated using these scripts https://github.com/opencb/opencga/tree/develop/opencga-app/app/misc/clients. This ensures 100% coverage of REST and reduces bugs, notice this https://github.com/opencb/opencga/blob/develop/opencga-client/src/main/python/pyopencga/rest_clients/sample_client.py#L2

I hope this is helpful, let us know if you have any other issue. Early next week we will upgrade demo server and pyopencga to 2.0.0-rc1. Thanks.