Closed appukuttan-shailesh closed 5 years ago
Interestingly, this works via the web apps. When I try to replicate the exact same API calls via Postman, I get the same error as above.
Web-app replication info: URL: https://validation-v1.brainsimulation.eu/models/?app_id=68489&format=json&web_app=True Payload:
{
"models":[
{
"id":"fa173234-a2b7-485d-9938-d98747bc89c3",
"name":"IGNORE - Test Model - 2019-05-15_13:54:16_duplicate",
"alias":"2019-05-15_13:54:16_duplicate",
"author":"Shailesh Appukuttan",
"owner":"Shailesh Appukuttan",
"app":{
"id":"359330",
"data_modalities":"",
"test_type":"",
"species":"",
"brain_region":"",
"cell_type":"",
"model_scope":"",
"abstraction_level":"",
"organization":"",
"app_type":"validation_app",
"collab_id":52468
},
"organization":"HBP-SP6",
"project":"SP 6.4",
"private":false,
"license":"BSD 3-Clause",
"cell_type":"granule cell",
"model_scope":"single cell",
"abstraction_level":"spiking neurons",
"brain_region":"hippocampus",
"species":"Mus musculus",
"description":"This is a test entry! Please ignore.",
"instances":[
],
"images":[
]
}
]
}
Any thoughts on this @apdavison ?
This is important since as a workaround users are asking us for entries to be deleted and new entries created (when several models need to be edited at once).
Do you have the same problem with the staging server?
Editing a model is still failing. E.g.
mc.get_model(model_id="21d03065-38e6-4720-bec6-dec4bdaff812")
works.
But,
mc.edit_model(model_id="21d03065-38e6-4720-bec6-dec4bdaff812", name="Kali_Freund_temp")
fails with
Exception: Error in updating model. Response = <Response [404]>
I get
KeyError Traceback (most recent call last)
<ipython-input-5-5f8bb6c6cdc5> in <module>
----> 1 mc.edit_model(model_id="21d03065-38e6-4720-bec6-dec4bdaff812", name="Kali_Freund_temp")
~/dev/validation/hbp-validation-client/hbp_validation_framework/__init__.py in edit_model(self, model_id, app_id, name, alias, author, organization, private, cell_type, model_scope, abstraction_level, brain_region, species, owner, project, license, description)
1865 model_data[key] = model_json[key]
1866 if app_id is None:
-> 1867 app_id = model_json["app"]["id"]
1868 if model_data["alias"] == "":
1869 model_data["alias"] = None
KeyError: 'id'
Have you updated the client locally?
I had the "url" partly incorrect. Correcting that gets rid off the 404 error, but brings me back to the original 500 error.
Yes, I had edited the client locally, by commenting out some lines (currently just for testing this):
for key in model_data:
if model_data[key] is None:
model_data[key] = model_json[key]
# if app_id is None:
# app_id = model_json["app"]["id"]
if model_data["alias"] == "":
model_data["alias"] = None
values = self.get_attribute_options()
# if model_data["cell_type"] not in values["cell_type"]:
# raise Exception("cell_type = '" +model_data["cell_type"]+"' is invalid.\nValue has to be one of these: " + str(values["cell_type"]))
# if model_data["model_scope"] not in values["model_scope"]:
# raise Exception("model_scope = '" +model_data["model_scope"]+"' is invalid.\nValue has to be one of these: " + str(values["model_scope"]))
# if model_data["abstraction_level"] not in values["abstraction_level"]:
# raise Exception("abstraction_level = '" +model_data["abstraction_level"]+"' is invalid.\nValue has to be one of these: " + str(values["abstraction_level"]))
# if model_data["brain_region"] not in values["brain_region"]:
# raise Exception("brain_region = '" +model_data["brain_region"]+"' is invalid.\nValue has to be one of these: " + str(values["brain_region"]))
# if model_data["species"] not in values["species"]:
# raise Exception("species = '" +model_data["species"]+"' is invalid.\nValue has to be one of these: " + str(values["species"]))
# values["organization"].append("") # allow blank organization field
# if model_data["organization"] not in values["organization"]:
# raise Exception("organization = '" +model_data["organization"]+"' is invalid.\nValue has to be one of these: " + str(values["organization"]))
# if model_data["private"] not in [True, False]:
# raise Exception("Model's 'private' attribute should be specified as True / False. Default value is False.")
url = self.url + "/models/"
Unable to get it working even via Postman.... The body of my request was:
{"models": [{"cell_type": "pyramidal cell", "description": "A model of CA1 pyramidal neurons, as described in:\n\nS. Kali, T.F. Freund (2004) Dendritic processing in hippocampal pyramidal cells and its modulation by inhibitory interneurons. *Proceedings of the 2004 IEEE International Joint Conference on Neural Networks* [doi:10.1109/IJCNN.2004.1379985](http://doi.org/10.1109/IJCNN.2004.1379985)", "license": "", "author": [{"family_name": "Kali", "given_name": "Szabolcs"}, {"family_name": "Freund", "given_name": "Tamas F."}], "model_scope": "single cell", "abstraction_level": "None", "id": "21d03065-38e6-4720-bec6-dec4bdaff812", "project": "", "alias": "kali-freund-2004", "private": "False", "brain_region": "hippocampus", "owner": "", "organization": "None", "species": "Rattus norvegicus", "name": "Kali_Freund"}]}
PUT https://validation-staging.brainsimulation.eu/models/
Error: 500 Internal Server Error
TypeError at /models/ string indices must be integers
The problem is in the request body. Some of the datatypes expected by the API have changed:
null
, []
or absent, not ""
false
, not "False"
Yes, it works with the above changes :+1: . Thanks! Will update the client accordingly.
Sorry.... following up on above:
if I try to just provide the following in query body:
{"models": [{"id": "21d03065-38e6-4720-bec6-dec4bdaff812", "name": "Kali_Freund_1"}]}
It returns a message saying:
[ "This field may not be blank." ]
It does not indicate what field cannot be blank. Also, is it right to demand even the fields that I do not wish to edit? Here, I just wished to edit the name of the model.
As you stated that I can let "owners" be absent, I would expect (and prefer) to have other un-edited fields absent.
I might be wrong about allowing some fields to be absent. In general with PUT you are supposed to provide all fields, PATCH may be used to update only some fields, however the server doesn't currently support PATCH. Could you make a ticket for that?
Closing this issue in view of #248.
Editing an existing model results in error.
URL: https://validation-v1.brainsimulation.eu/models/?app_id=359330 Sample payload:
Error: 500 Internal Server Error