Model
Logic Backend for View, connection to sources.
ModelLogic
Originally in Control
Logic backend for view. Initialized as object by View.
Source code in src/ibl_explorer/model.py
423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 |
|
display_list(sel_list, eid='', collection='')
Connector to getDataDisplay() of sources.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
source |
str
|
Source. |
required |
sel_list |
str | None
|
Selected list. |
required |
eid |
str | None
|
EID. |
''
|
collection |
str | None
|
Collection. |
''
|
Returns:
Name | Type | Description |
---|---|---|
dict |
dict
|
Data for DataTree |
Source code in src/ibl_explorer/model.py
450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 |
|
draw_diagram(data, settings)
Draw diagram, doesn't work.
Source code in src/ibl_explorer/model.py
509 510 511 512 513 514 515 |
|
get_description(desc)
Retrieve description of dataset. Hardcoded to OneConnector.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
desc |
str
|
Path of file to describe. |
required |
Returns:
Name | Type | Description |
---|---|---|
str |
str
|
Description in dict format |
Source code in src/ibl_explorer/model.py
497 498 499 500 501 502 503 504 505 506 507 |
|
get_dialog(menu)
Information on how to build dialog. Information is hardcoded right now, was planned to retrieve data from selected source.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
menu |
str
|
Selected dialog |
required |
Example
[[Name of Field, Field, Data for the Field, Description]]
Returns:
Name | Type | Description |
---|---|---|
list |
list
|
Information on how to build dialog |
Source code in src/ibl_explorer/model.py
472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 |
|
init_model()
async
Init sources as objects in _data_sources and create default list for display. Throws Error when trying to initialize child class of ABC (metaclass error).
Returns:
Name | Type | Description |
---|---|---|
bool |
bool
|
If initialized successful, return true. Switches from LoadScreen to MainScreen. |
Source code in src/ibl_explorer/model.py
435 436 437 438 439 440 441 442 443 444 445 446 447 448 |
|
DataSource
Copied from Notebook
Interface for data sources. Was planned to be a metaclass, which inherits from ABC and uses @abstractmethod decorator.
Why an "Interface" in Python?
Since the project was planned to be as modular as possible, the Control should've been able to fetch all data sources via the interface.
Source code in src/ibl_explorer/model.py
21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 |
|
getAvailableLists(default=False)
Returns available lists which can be displayed and searched First entry is default
Parameters:
Name | Type | Description | Default |
---|---|---|---|
default |
bool
|
Returns default list as str. |
False
|
Returns:
Type | Description |
---|---|
[dict | str]
|
dict | str: [listName, entryType, nameOfEntry, description] | listName |
Source code in src/ibl_explorer/model.py
71 72 73 74 75 76 77 78 79 80 81 |
|
getDataDisplay(selectedList, searchTerm='', param=[])
Creates displayable data from list or search request. Either selectedList can be used for a list request or param for a search request. Use getAvailableLists() for available lists or getSearchParams() for search parameters.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
selected |
List (str
|
Indicates list or search operation, can use searchTerm. |
required |
searchTerm |
str | list
|
Used to list and search by Term. |
''
|
param |
list
|
Uses searchTerm. |
[]
|
Returns:
Name | Type | Description |
---|---|---|
dict |
dict
|
Data that can be parsed as a tree by View. |
Source code in src/ibl_explorer/model.py
90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 |
|
getDataset(uuid, term)
Get Dataset from API with UUID Args: uuid (str): UUID term (str): Further specify which Dataset should be returned.
Returns:
Name | Type | Description |
---|---|---|
list |
list
|
Dataset from API |
Source code in src/ibl_explorer/model.py
106 107 108 109 110 111 112 113 114 115 |
|
getSearchParams()
Returns a list of parameters which can be used to search the source.
Returns:
Name | Type | Description |
---|---|---|
dict |
dict
|
{Name: [parameter name, [useable types], [description]]} |
Source code in src/ibl_explorer/model.py
83 84 85 86 87 88 |
|
getStatus()
Shows status of module, executed after initSource and on info page
Example
status = { "Code": self._status[0], "Messages": self._status[1], "Description": self._status[2], }
Returns:
Name | Type | Description |
---|---|---|
dict |
dict
|
Dictionary with Errorcode, Message list and Source description. |
Source code in src/ibl_explorer/model.py
55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 |
|
initSource()
Initially meant to be called, when the LoadScreen was already visible. Writes to _status and returns a bool when finished so the load screen could show the status of initialization.
Example
0: Not initialized, 1: initialized, no Errors, 2: initialized, messages available, 3: Error while initializing Description.
self._status = [0, ["Not initialized, initialize with "initSource()" "], "Connector for the ONE API, using the Alyx fileformat"]
self._status = [1, [], "Connector for the ONE API, using the Alyx fileformat"]
self._status = [2, ["Deprecation warning: ibllib is soon to be deprecated."], "Connector for the ONE API, using the Alyx fileformat"]
self._status = [3, ["Exception: Library XY missing", "Source could not be initialized"], "Connector for the ONE API, using the Alyx fileformat"]
Returns:
Name | Type | Description |
---|---|---|
bool |
bool
|
True if initialization was successful, False otherwise. |
Source code in src/ibl_explorer/model.py
35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 |
|
OneConnector(DataSource)
Copied from Notebook
Bases: DataSource
Connector for the IBL ONE API.
note
See DataSource for further method description.
Source code in src/ibl_explorer/model.py
118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 |
|
__init__()
Initializes the class. Copied from init_source(), since python threw a lot of errors regarding one and ba. Would probably (?) work in init_source(). Doesn't use error handling.
Source code in src/ibl_explorer/model.py
128 129 130 131 132 133 134 135 136 137 138 139 140 141 |
|
getDataDisplay(selectedList, searchTerm='', param=[])
Retrieves list or search result from API and parses the data as dict/json.
example
API Data: ["a/b/c", "a", "b", "c", "a/ab/bc"]
Returns: {selectedList: {a: {b: {c: ""}, ab: {bc: ""}}}}
Source code in src/ibl_explorer/model.py
175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 |
|
getDataset(uuid, term)
Get Dataset from API with UUID Args: uuid (str): UUID
Returns:
Name | Type | Description |
---|---|---|
list |
list
|
Dataset from API |
Source code in src/ibl_explorer/model.py
300 301 302 303 304 305 306 307 308 309 310 |
|
initSource()
Initially meant to be called, when the LoadScreen was already visible. Writes to _status and returns a bool when finished so the load screen could show the status of initialization.
Example
0: Not initialized, 1: initialized, no Errors, 2: initialized, messages available, 3: Error while initializing Description.
self._status = [0, ["Not initialized, initialize with "initSource()" "], "Connector for the ONE API, using the Alyx fileformat"]
self._status = [1, [], "Connector for the ONE API, using the Alyx fileformat"]
self._status = [2, ["Deprecation warning: ibllib is soon to be deprecated."], "Connector for the ONE API, using the Alyx fileformat"]
self._status = [3, ["Exception: Library XY missing", "Source could not be initialized"], "Connector for the ONE API, using the Alyx fileformat"]
Returns:
Name | Type | Description |
---|---|---|
bool |
bool
|
True if initialization was successful, False otherwise. |
Source code in src/ibl_explorer/model.py
35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 |
|
DiagramSource
Copied from Notebook
Source code in src/ibl_explorer/model.py
349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 |
|
getDescription()
Get description of diagram
Returns:
Name | Type | Description |
---|---|---|
str |
str
|
Description |
Source code in src/ibl_explorer/model.py
359 360 361 362 363 364 365 366 |
|
getDiagram(data, settings)
Create diagram with data and settings Should open a window with the diagram.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
data |
list
|
Data |
required |
settings |
list
|
Settings |
required |
Source code in src/ibl_explorer/model.py
382 383 384 385 386 387 388 389 390 391 |
|
getSettings()
Available settings for diagram
Returns:
Name | Type | Description |
---|---|---|
list |
list
|
Available settings for diagram |
Source code in src/ibl_explorer/model.py
373 374 375 376 377 378 379 380 |
|
testDataset()
Dataset for test
Source code in src/ibl_explorer/model.py
393 394 395 396 |
|
LineDiagram(DiagramSource)
Copied from Notebook
Bases: DiagramSource
Source code in src/ibl_explorer/model.py
400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 |
|
getDescription()
Get description of diagram
Returns:
Name | Type | Description |
---|---|---|
str |
str
|
Description |
Source code in src/ibl_explorer/model.py
359 360 361 362 363 364 365 366 |
|
getSettings()
Available settings for diagram
Returns:
Name | Type | Description |
---|---|---|
list |
list
|
Available settings for diagram |
Source code in src/ibl_explorer/model.py
373 374 375 376 377 378 379 380 |
|