cnr-ibf-pa / hbp-bsp-issues

Ticketing system for developers/testers and power users of the Brain Simulation Platform of the Human Brain Project
4 stars 0 forks source link

Update script to retrieve models from ModelCatalog #527

Closed appukuttan-shailesh closed 4 years ago

appukuttan-shailesh commented 4 years ago

@antonelepfl : We might need to update the script here: https://github.com/antonelepfl/usecases/blob/dev/src/assets/config_files/create_singlecellmodeling_structure.py for two reasons: 1) retrieving data (via GET) from the KG backend requires authentication solution:

from hbp_validation_framework import ModelCatalog
mc = ModelCatalog(username="shailesh")  # HBP username; password via environment variable
# mc = ModelCatalog(username="shailesh", password="")  # HBP username & Password

The token gets saved in mc.auth

For more authentication related info, see: https://hbp-validation-client.readthedocs.io/en/master/#regarding-hbp-authentication https://hbp-validation-client.readthedocs.io/en/master/#hbp_validation_framework.ModelCatalog

Note: no authentication info required if run inside a Collab Jupyter notebook

2) the query for returning Hippocampus models currently retrieves models not appropriate for the usecases. solution: Change the query from: 'hippocampus_models.json': '?brain_region=hippocampus&organization=HBP-SP6&model_scope=single%20cell&species=Rattus%20norvegicus' to 'hippocampus_models.json': '?brain_region=hippocampus&organization=HBP-SP6&model_scope=single%20cell&species=Rattus%20norvegicus&collab_id=12027' Note: this is also in accordance with out earlier discussion here.

appukuttan-shailesh commented 4 years ago

Also, https://github.com/antonelepfl/usecases/blob/dev/src/assets/config_files/create_singlecellmodeling_structure.py#L63

instance_to_zip = model_info['instances'][0]['source']

needs to be updated to something like:

instance_to_zip = next((inst["source"] for inst in model_info['instances'] if inst["version"] == "2.0"), None)
antonelepfl commented 4 years ago

Hi Shailesh, I was having a look and I don't find the ModelCatalog class where I can pass directly the token. I was planing to use the refresh token to get the access one as discussed on Monday meeting. Do you know if I can do this?

antonelepfl commented 4 years ago

Ah ok I thought I was obliged to use the package but I was able to retrieve using the Rest API.

antonelepfl commented 4 years ago

Hi guys, I've been doing the changes and I would like to have confirmation regarding the new models that will be available on the BSP Use Cases. Please have a look at the results json and check if all the models that you want are there and contain the correct information:

appukuttan-shailesh commented 4 years ago

@antonelepfl : Yes, you can use either the Python client, or the REST APIs directly. If using the former (for package version >= 0.5.23), you can pass the token via:

from hbp_validation_framework import ModelCatalog
mc = ModelCatalog(token="<token>")

Note: the token can be either from Collab v1 or v2. For v2, you should use the access_token, and not the refresh_token.

apdavison commented 4 years ago

For both v1 and v2 you need the access token.

antonelepfl commented 4 years ago

Yeah I'm going to use the Rest API as I mentioned and I was able to get the models that I posted on the JSON files above

antonelepfl commented 4 years ago

We need to wait for @clupascu to push the new use cases to PROD before changing the models. For @lbologna The models works correctly. @SteMasoli Do you need to make some change on your use cases or this new queries will work for the current use cases?

clupascu commented 4 years ago

@antonelepfl it seems that Py3 versions of my usecases were pushed to PROD, so now the change of the models is necessary for me. Can you please change them? The usecases in PROD do not work without this change.

antonelepfl commented 4 years ago

Ok. @clupascu Can you confirm that this is the correct list? https://github.com/antonelepfl/usecases/commit/34074d05ef2deb4e16ce34e07fe96631531a8bb9

clupascu commented 4 years ago

yes. It is the correct list.

antonelepfl commented 4 years ago

So they should be in PROD.

antonelepfl commented 4 years ago

PR to change plan in progress https://github.com/antonelepfl/usecases/pull/326