Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Clients: use script to autogenerate #527

Open
julie-sullivan opened this issue Feb 6, 2020 · 5 comments
Open

Clients: use script to autogenerate #527

julie-sullivan opened this issue Feb 6, 2020 · 5 comments
Assignees
Labels
Milestone

Comments

@julie-sullivan
Copy link
Contributor

I'd like to use the opencga script to autogenerate the clients for CellBase.

Can we use the same script, or do we need to modify the current one?

@julie-sullivan
Copy link
Contributor Author

Here are the changes I made so far:

# java_client_generator.py
+            'Admin': 'Admin',
+            'Clinical': 'Clinical',
+            'Gene': 'Gene',
+            'Chromosome': 'Genome Sequence',
+            'Protein': 'Protein',
+            'Region': 'Region',
+            'Regulation': 'Regulation',
+            'Species': 'Species',
+            'TFBS': 'TF',
+            'Transcript': 'Transcript',
+            'Variant': 'Variant',
+            'Xref': 'Id'

The version number is hardcoded:

# rest_client_generator.py

-            server_url + '/webservices/rest/v2/meta/about'
+            server_url + '/webservices/rest/v5/meta/about'

-        for category in requests.get(self.server_url + '/webservices/rest/v2/meta/api').json()['responses'][0]['results'][0]:
+        for category in requests.get(self.server_url + '/webservices/rest/v5/meta/api').json()['responses'][0]['results'][0]:

Also CellBase uses version instead of apiVersion

-        return category['path'].replace('/{apiVersion}/', '')
+        return category['path'].replace('/{apiVersion}/', '').replace('/{version}/', '')

-        return endpoint['path'].replace('/{apiVersion}/', '')
+        return endpoint['path'].replace('/{apiVersion}/', '').replace('/{version}/', '')


@julie-sullivan
Copy link
Contributor Author

The error I am working on now is that CellBase has /{species} prepended to most end points, OpenCGA does not have this.

~/git/opencga/opencga-app/app/misc/clients (develop) $ python3 java_client_generator.py http://127.0.1.1:9090/cellbase /tmp
Processing {species}/clinical/variant/search
Traceback (most recent call last):
  File "java_client_generator.py", line 307, in <module>
    sys.exit(main())
  File "java_client_generator.py", line 304, in main
    client_generator.create_rest_clients()
  File "/home/julie/git/opencga/opencga-app/app/misc/clients/rest_client_generator.py", line 199, in create_rest_clients
    text.append(self.get_method_definition(category, endpoint))
  File "java_client_generator.py", line 126, in get_method_definition
    typed_parameters.append(self.get_parameter_type(parameter) + ' ' + parameter)
  File "java_client_generator.py", line 206, in get_parameter_type
    param_type = super().get_parameter_type(parameter)
  File "/home/julie/git/opencga/opencga-app/app/misc/clients/rest_client_generator.py", line 83, in get_parameter_type
    return self.parameters[parameter]['type']
KeyError: 'species'

@julie-sullivan julie-sullivan self-assigned this Feb 6, 2020
@julie-sullivan julie-sullivan added in progress work in progress, under active development and removed in progress work in progress, under active development labels Feb 6, 2020
@julie-sullivan
Copy link
Contributor Author

I've added the scripts to CellBase (with the changes I listed above):

https://github.com/opencb/cellbase/tree/develop/cellbase-app/app/clients

  • species is in each path, and is needed by each method. How should this be handled?

@imedina imedina added this to the v5.0.0 milestone Jun 1, 2020
@imedina imedina added the client label Jun 1, 2020
@imedina
Copy link
Member

imedina commented Jun 1, 2020

Just worth mentioning the clients to be generated include Java, Python, R and Javascript, is this right?

@julie-sullivan
Copy link
Contributor Author

Yes! That is correct.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants