ai-cfia / ai-cfia/ailab-datastore

Adapt DB schema to include types of container used

Offen
#266 1 Kommentar 0 Reaktionen 0 zugewiesene Personen Auf GitHub ansehen
dependencies documentation enhancement user-impacting features
Vorherrschende Sprache
Python
Sterne
3
Forks
0
PR-Merge-Kennzahlen
Keine gemergten PRs in 30 T.

Beschreibung

## Context

With the release of https://github.com/ai-cfia/ailab-datastore/pull/263, we are introducing new BLOB Strorage technology in the equation. Therefor, we need to keep track of which kind of storage the container is.

## Proposed changes

### Database
- 💾 Adding a Container type table
```mermaid
---
title: CONTAINER_TYPE table
---
erDiagram

CONTAINER {
UUID type_id FK "new column"
}

CONTAINER_TYPE {
UUID id PK
TEXT name "unique"
}

CONTAINER }o--||CONTAINER_TYPE: is
```

### Python modules
- 📦 `datastore.__init__.py`
- Add the type id in various function to keep track through our workflows
- Update the Container model
- Update the Container creation logic
```python

class Container(BaseModel): # needs to be update with container type

...

class ContainerController
async def create_storage(self, connection_str: str, credentials: str,container_type):
# This need to be updated since this is where we create the Blob storage container.

...

async def new_user(
cursor: Cursor,
email: str,
connection_string,
container_type: uuid | str, # Specify the container type for user creation
tier="user",
role: Role = Role.INSPECTOR,
) -> User:

...

async def create_container(
cursor: Cursor,
connection_str: str,
container_type: uuid | str, # Specify the container type when creating the container
container_name: str = None,
user_id: UUID = None,
is_public=False,
storage_prefix="user",
add_user_to_storage: bool = False,
) -> ContainerController:
```
- 📦 `datastore.db.container.__init__.py`
- We need to Implement various CRUD f() for the container_type
- We need to adapt our container queries to include container_type_id
```python
get_container_type_by_name(name:str)->UUID: # Exemple of CRUD

...

def create_container(
cursor: Cursor,
name: str,
type_id:UUID, # To add
user_id: UUID,
is_public: bool = False,
storage_prefix: str = "user",
) -> UUID:
# Need to changes the query
```

## Acceptance Criteria

- Offering an easy way to save BLOB storage types through time
- Datastore workflow allow to specify the storage types
- Container model reflects new logic for types
- New tests to showcases the changes
- Update previous tests to handle edge cases of multiple container types being used

Beitragsleitfaden

Für dieses Repository ist kein Beitragsleitfaden indexiert

Bewertung

Dieses Issue wurde noch nicht bewertet.

Neue Issues direkt in Ihr Postfach

Eine kurze Übersicht über anfängerfreundliche GitHub-Issues.