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

CI test fixes #927

Open
wants to merge 1 commit into
base: develop
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion ibllib/pipes/misc.py
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ def create_alyx_probe_insertions(
for plabel in labels:
insdict = {"session": eid, "name": plabel, "model": pmodel, "json": qc_dict}
# search for the corresponding insertion in Alyx
alyx_insertion = one.alyx.get(f'/insertions?&session={eid}&name={plabel}', clobber=True)
alyx_insertion = one.alyx.get(f'/insertions?&session={str(eid)}&name={plabel}', clobber=True)
# if it doesn't exist, create it
if len(alyx_insertion) == 0:
alyx_insertion = one.alyx.rest("insertions", "create", data=insdict)
Expand Down
12 changes: 8 additions & 4 deletions ibllib/plots/snapshot.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
import numpy as np

from one.api import ONE
from one.alf.spec import is_uuid
from ibllib.pipes import tasks
from one.alf.exceptions import ALFObjectNotFound
from neuropixel import trace_header, TIP_SIZE_UM
Expand Down Expand Up @@ -177,6 +178,8 @@ class Snapshot:

def __init__(self, object_id, content_type='session', one=None):
self.one = one or ONE()
if not is_uuid(object_id, versions=(4,)):
raise ValueError('Expected `object_id` to be a UUIDv4 object')
self.object_id = object_id
self.content_type = content_type
self.images = []
Expand Down Expand Up @@ -217,13 +220,14 @@ def register_image(self, image_file, text='', json_field=None, width=None):
# the protocol is not compatible with byte streaming and json, so serialize the json object here
# Make sure that user is logged in, if not, try to log in
assert self.one.alyx.is_logged_in, 'No Alyx user is logged in, try running one.alyx.authenticate() first'
object_id = str(self.object_id) # ensure not UUID object
note = {
'user': self.one.alyx.user, 'content_type': self.content_type, 'object_id': self.object_id,
'user': self.one.alyx.user, 'content_type': self.content_type, 'object_id': object_id,
'text': text, 'width': width, 'json': json.dumps(json_field)}
_logger.info(f'Registering image to {self.content_type} with id {self.object_id}')
_logger.info(f'Registering image to {self.content_type} with id {object_id}')
# to make sure an eventual note gets deleted with the image call the delete REST endpoint first
current_note = self.one.alyx.rest('notes', 'list',
django=f"object_id,{self.object_id},text,{text},json__name,{text}",
django=f"object_id,{object_id},text,{text},json__name,{text}",
no_cache=True)
if len(current_note) == 1:
self.one.alyx.rest('notes', 'delete', id=current_note[0]['id'])
Expand All @@ -235,7 +239,7 @@ def register_image(self, image_file, text='', json_field=None, width=None):
return note_db
except requests.HTTPError as e:
if 'matching query does not exist' in str(e):
_logger.error(f'The object_id {self.object_id} does not match an object of type {self.content_type}')
_logger.error(f'The object_id {object_id} does not match an object of type {self.content_type}')
_logger.debug(traceback.format_exc())
else:
raise e
Expand Down
10 changes: 7 additions & 3 deletions ibllib/qc/critical_reasons.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
import json
from datetime import datetime
from one.webclient import AlyxClient
from one.alf.spec import is_uuid

_logger = logging.getLogger('ibllib')

Expand Down Expand Up @@ -83,8 +84,8 @@ def main(uuid, alyx=None):
# ask reasons for selection of critical status

# hit the database to know if uuid is insertion or session uuid
sess_list = alyx.get('/sessions?&django=pk,' + uuid, clobber=True)
ins_list = alyx.get('/insertions?&django=pk,' + uuid, clobber=True)
sess_list = alyx.get('/sessions?&django=pk,' + str(uuid), clobber=True)
ins_list = alyx.get('/insertions?&django=pk,' + str(uuid), clobber=True)

if len(sess_list) > 0 and len(ins_list) == 0: # session
note = CriticalSessionNote(uuid, alyx)
Expand Down Expand Up @@ -131,6 +132,8 @@ def __init__(self, uuid, alyx, content_type=None):
content_type : str
The Alyx model name of the UUID.
"""
if not is_uuid(uuid, versions=(4,)):
raise ValueError('Expected `uuid` to be a UUIDv4 object')
self.uuid = uuid
self.alyx = alyx
self.selected_reasons = []
Expand Down Expand Up @@ -237,7 +240,8 @@ def _delete_notes(self, notes):
self._delete_note(note['id'])

def _check_existing_note(self):
notes = self.alyx.rest('notes', 'list', django=f'text__icontains,{self.note_title},object_id,{self.uuid}', no_cache=True)
query = f'text__icontains,{self.note_title},object_id,{str(self.uuid)}'
notes = self.alyx.rest('notes', 'list', django=query, no_cache=True)
if len(notes) == 0:
return False, None
else:
Expand Down
2 changes: 1 addition & 1 deletion requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ ibl-neuropixel>=1.6.2
iblutil>=1.13.0
iblqt>=0.4.2
mtscomp>=1.0.1
ONE-api==3.0b3
ONE-api==3.0b4
phylib>=2.6.0
psychofit
slidingRP>=1.1.1 # steinmetz lab refractory period metrics
Expand Down
Loading