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

Test new passive API endpoint with mtrain dev env #156

Open
jeromelecoq opened this issue Oct 11, 2022 · 3 comments
Open

Test new passive API endpoint with mtrain dev env #156

jeromelecoq opened this issue Oct 11, 2022 · 3 comments
Assignees
Labels
bug Something isn't working enhancement New feature or request

Comments

@jeromelecoq
Copy link
Collaborator

jeromelecoq commented Oct 11, 2022

We are currently in the process of testing a new API endpoint to automatically route passively train mice with mtrain.
Currently development is tracked on those repo:
https://github.com/jeromelecoq/mtrain_api
https://github.com/jeromelecoq/mtrain_lims

(Because of lack of write access to main repos).

@jeromelecoq jeromelecoq self-assigned this Oct 11, 2022
@jeromelecoq
Copy link
Collaborator Author

Latest issue was that mice in passive script would not allow test mice through submission of pkl files.

ie with this input json:
{
"inc": {
"API_BASE": "http://devmtrain1.corp.alleninstitute.org:5000",
"foraging_id": "82ddf9b9-34cc-4b3f-87dd-f10f4d79be62",
"foraging_file_name": "/allen/programs/mindscope/production/openscope/prod0/specimen_1194090570/behavior_session_1207398649/220906125538_637484_82ddf9b9-34cc-4b3f-87dd-f10f4d79be62.pkl"
}
}

with the following line cmd:
mtrain_lims --input_json input_passive.json --output_json output_passive.json

would return:
{"status_code": 409, "reason": "CONFLICT", "input_parameters": {"API_BASE": "http://devmtrain1.corp.alleninstitute.org:5000", "foraging_file_name": "/allen/programs/mindscope/production/openscope/prod0/specimen_1194090570/behavior_session_1207398649/220906125538_637484_82ddf9b9-34cc-4b3f-87dd-f10f4d79be62.pkl", "foraging_id": "82ddf9b9-34cc-4b3f-87dd-f10f4d79be62"}, "text": "{\n "reason": "(psycopg2.errors.UniqueViolation) duplicate key value violates unique constraint \"behavior_sessions_pkey\"\nDETAIL: Key (id)=(82ddf9b9-34cc-4b3f-87dd-f10f4d79be62) already exists.\n [SQL: 'INSERT INTO behavior_sessions (id, date, state_id, \"LabTracks_ID\") VALUES (%(id)s, %(date)s, %(state_id)s, %(LabTracks_ID)s)'] [parameters: {'id': '82ddf9b9-34cc-4b3f-87dd-f10f4d79be62', 'date': '2022-09-06T12:56:04.496000-07:00', 'state_id': 291, 'LabTracks_ID': 637484}] (Background on this error at: http://sqlalche.me/e/gkpj)\", \n "success": false\n}\n"}

I think the error is because the session already exists. but When I call
(/allen/programs/mindscope/workgroups/openscope/environment/mtrain) [jeromel@hpc-login demo_json]$ mtrain_lims --input_json input_passive.json --output_json output_passive.json --force_testupload
Traceback (most recent call last):
File "/allen/programs/mindscope/workgroups/openscope/environment/mtrain/bin/mtrain_lims", line 11, in
load_entry_point('mtrain-lims==0.3.0', 'console_scripts', 'mtrain_lims')()
File "/allen/programs/mindscope/workgroups/openscope/environment/mtrain/lib/python2.7/site-packages/mtrain_lims-0.3.0-py2.7.egg/mtrain_lims/main.py", line 150, in main
result = sess.post(os.path.join(API_BASE, api_call_endpoint), data=data_package_cs)
File "/allen/programs/mindscope/workgroups/openscope/environment/mtrain/lib/python2.7/site-packages/requests/sessions.py", line 581, in post
return self.request('POST', url, data=data, json=json, **kwargs)
File "/allen/programs/mindscope/workgroups/openscope/environment/mtrain/lib/python2.7/site-packages/requests/sessions.py", line 533, in request
resp = self.send(prep, **send_kwargs)
File "/allen/programs/mindscope/workgroups/openscope/environment/mtrain/lib/python2.7/site-packages/requests/sessions.py", line 646, in send
r = adapter.send(request, **kwargs)
File "/allen/programs/mindscope/workgroups/openscope/environment/mtrain/lib/python2.7/site-packages/requests/adapters.py", line 498, in send
raise ConnectionError(err, request=request)
requests.exceptions.ConnectionError: ('Connection aborted.', BadStatusLine("''",))

I think the error is because mouse id are not properly converted.

Asking to merge this commit onto the dev environment:
https://github.com/jeromelecoq/mtrain_api/commit/10b2405ca8ac913de27a102911290ce305840f1c

@jeromelecoq
Copy link
Collaborator Author

Passive pkl file got in !

{"status_code": 200, "reason": "OK", "input_parameters": {"API_BASE": "http://devmtrain1.corp.alleninstitute.org:5000", "foraging_file_name": "/allen/programs/mindscope/production/openscope/prod0/specimen_1194090570/behavior_session_1207398649/220906125538_637484_82ddf9b9-34cc-4b3f-87dd-f10f4d79be62.pkl", "foraging_id": "82ddf9b9-34cc-4b3f-87dd-f10f4d79be62"}, "text": "{\n  "success": true\n}\n"}

@jeromelecoq
Copy link
Collaborator Author

Will ask Sean McCullock to review this

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants