pixano.app.routers.utils
assert_table_in_group(dataset, table, group)
Assert that a table belongs to a group.
If the table does not belong to the group, raise a 404 error.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
dataset
|
Dataset
|
Dataset. |
required |
table
|
str
|
Table name. |
required |
group
|
SchemaGroup
|
Group. |
required |
Source code in pixano/app/routers/utils.py
create_row_handler(dataset_id, group, table, id, row, settings)
async
Add a row to a table.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
dataset_id
|
str
|
Dataset ID containing the table. |
required |
group
|
SchemaGroup
|
Schema group of the schema of the table. |
required |
table
|
str
|
Table name. |
required |
id
|
str
|
ID of the row. |
required |
row
|
BaseSchemaModel
|
Row to add. |
required |
settings
|
Settings
|
App settings. |
required |
Returns:
Type | Description |
---|---|
BaseSchemaModel
|
The added row. |
Source code in pixano/app/routers/utils.py
create_rows(dataset, table, models)
Add rows to a table.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
dataset
|
Dataset
|
Dataset containing the table. |
required |
table
|
str
|
Table name. |
required |
models
|
list[BaseSchemaModel]
|
Models of the rows to add. |
required |
Returns:
Type | Description |
---|---|
list[BaseSchema]
|
The added rows. |
Source code in pixano/app/routers/utils.py
create_rows_handler(dataset_id, group, table, rows, settings)
async
Add rows to a table.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
dataset_id
|
str
|
Dataset ID containing the table. |
required |
group
|
SchemaGroup
|
Schema group of the schema of the table. |
required |
table
|
str
|
Table name containing the rows. |
required |
rows
|
list[BaseSchemaModel]
|
Rows to add. |
required |
settings
|
Settings
|
App settings. |
required |
Returns:
Type | Description |
---|---|
list[BaseSchemaModel]
|
List of updated rows. |
Source code in pixano/app/routers/utils.py
delete_row_handler(dataset_id, group, table, id, settings)
async
Delete a row from a table.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
dataset_id
|
str
|
Dataset ID containing the table. |
required |
group
|
SchemaGroup
|
Schema group of the schema of the table. |
required |
table
|
str
|
Table name containing the row. |
required |
id
|
str
|
ID of the row to delete. |
required |
settings
|
Settings
|
App settings. |
required |
Source code in pixano/app/routers/utils.py
delete_rows(dataset, table, ids)
Delete rows from a table.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
dataset
|
Dataset
|
Dataset containing the table. |
required |
table
|
str
|
Table name. |
required |
ids
|
list[str]
|
IDs of the rows to delete. |
required |
Returns:
Type | Description |
---|---|
list[str]
|
IDs not found. |
Source code in pixano/app/routers/utils.py
delete_rows_handler(dataset_id, group, table, ids, settings)
async
Delete rows from a table.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
dataset_id
|
str
|
Dataset ID containing the table. |
required |
group
|
SchemaGroup
|
Schema group of the schema of the table. |
required |
table
|
str
|
Table name containing the rows. |
required |
ids
|
list[str]
|
IDs of the rows to delete. |
required |
settings
|
Settings
|
App settings. |
required |
Source code in pixano/app/routers/utils.py
get_dataset(dataset_id, dir, media_dir=None)
Get a dataset.
If the dataset is not found, raise a 404 error.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
dataset_id
|
str
|
Dataset ID. |
required |
dir
|
Path
|
Directory containing the dataset. |
required |
media_dir
|
Path | None
|
Directory containing the media files. |
None
|
Returns:
Type | Description |
---|---|
Dataset
|
The dataset. |
Source code in pixano/app/routers/utils.py
get_model_from_row(table, model_type, row)
Get a model from a row.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
table
|
str
|
Table name containing the row. |
required |
model_type
|
type[T]
|
Model type to create. |
required |
row
|
BaseSchema
|
Row. |
required |
Returns:
Type | Description |
---|---|
T
|
The model. |
Source code in pixano/app/routers/utils.py
get_models_from_rows(table, model_type, rows)
Get models from rows.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
table
|
str
|
Table name containing the rows. |
required |
model_type
|
type[T]
|
Model type to create. |
required |
rows
|
list[BaseSchema]
|
Rows. |
required |
Returns:
Type | Description |
---|---|
list[T]
|
List of models. |
Source code in pixano/app/routers/utils.py
get_row_handler(dataset_id, group, table, id, settings)
async
Get a row model.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
dataset_id
|
str
|
Dataset ID containing the table. |
required |
group
|
SchemaGroup
|
Schema group of the schema of the table. |
required |
table
|
str
|
Table name. |
required |
id
|
str
|
ID of the row. |
required |
settings
|
Settings
|
App settings. |
required |
Returns:
Type | Description |
---|---|
BaseSchemaModel
|
The model. |
Source code in pixano/app/routers/utils.py
get_rows(dataset, table, where=None, ids=None, item_ids=None, limit=None, skip=0)
Get rows from a table.
The rows can be filtered by a where clause, IDs, item IDs or a limit and a skip.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
dataset
|
Dataset
|
Dataset containing the table. |
required |
table
|
str
|
Table name. |
required |
where
|
str | None
|
Where clause. |
None
|
ids
|
list[str] | None
|
IDs of the rows. |
None
|
item_ids
|
list[str] | None
|
Item IDs of the rows. |
None
|
limit
|
int | None
|
Limit number of rows. |
None
|
skip
|
int
|
Skip number of rows. |
0
|
Returns:
Type | Description |
---|---|
list[BaseSchema]
|
List of rows. |
Source code in pixano/app/routers/utils.py
get_rows_handler(dataset_id, group, table, settings, where=None, ids=None, item_ids=None, limit=None, skip=0)
async
Get row models.
Rows can be filtered by a where clause, IDs, item IDs or a limit and a skip.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
dataset_id
|
str
|
Dataset ID containing the table. |
required |
group
|
SchemaGroup
|
Schema group of the schema of the table. |
required |
table
|
str
|
Table name. |
required |
settings
|
Settings
|
App settings. |
required |
where
|
str | None
|
Where clause. |
None
|
ids
|
list[str] | None
|
IDs of the rows. |
None
|
item_ids
|
list[str] | None
|
Item IDs of the rows. |
None
|
limit
|
int | None
|
Limit number of rows. |
None
|
skip
|
int
|
Skip number of rows. |
0
|
Returns:
Type | Description |
---|---|
list[BaseSchemaModel]
|
List of models. |
Source code in pixano/app/routers/utils.py
update_row_handler(dataset_id, group, table, id, row, settings)
async
Update a row in a table.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
dataset_id
|
str
|
Dataset ID containing the table. |
required |
group
|
SchemaGroup
|
Schema group of the schema of the table. |
required |
table
|
str
|
Table name containing the row. |
required |
id
|
str
|
ID of the row. |
required |
row
|
BaseSchemaModel
|
Row to update. |
required |
settings
|
Settings
|
App settings. |
required |
Returns:
Type | Description |
---|---|
BaseSchemaModel
|
The updated row. |
Source code in pixano/app/routers/utils.py
update_rows(dataset, table, models)
Update rows in a table.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
dataset
|
Dataset
|
Dataset containing the table. |
required |
table
|
str
|
Table name. |
required |
models
|
list[BaseSchemaModel]
|
Models of the rows to update. |
required |
Returns:
Type | Description |
---|---|
list[BaseSchema]
|
The updated rows. |
Source code in pixano/app/routers/utils.py
update_rows_handler(dataset_id, group, table, rows, settings)
async
Update rows in a table.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
dataset_id
|
str
|
Dataset ID containing the table. |
required |
group
|
SchemaGroup
|
Schema group of the schema of the table. |
required |
table
|
str
|
Table name containing the rows. |
required |
rows
|
list[BaseSchemaModel]
|
Rows to update. |
required |
settings
|
Settings
|
App settings. |
required |
Returns:
Type | Description |
---|---|
list[BaseSchemaModel]
|
List of updated rows. |
Source code in pixano/app/routers/utils.py
validate_group(group, valid_groups=set(SchemaGroup))
Assert that a group is valid.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
group
|
str | SchemaGroup
|
Group. |
required |
valid_groups
|
set[SchemaGroup]
|
The valid groups. |
set(SchemaGroup)
|