-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Update poetry env with 1bn personas, test nbs
- Loading branch information
1 parent
1296b24
commit 33ac65e
Showing
8 changed files
with
31,359 additions
and
57 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -178,3 +178,5 @@ models/ | |
|
||
|
||
/data | ||
|
||
/secrets |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
# BugBytes instructor likes to use the schemas.py file and add all the Pydantic schemas to that file | ||
from datetime import date | ||
from enum import Enum | ||
from pydantic import BaseModel, field_validator | ||
from sqlmodel import SQLModel, Field, Relationship | ||
|
||
|
||
class GenreURLChoices(Enum): | ||
ROCK = "rock" | ||
ELECTRONIC = "electronic" | ||
METAL = "metal" | ||
HIP_HOP = "hip-hop" | ||
SHOEGAZE = "shoegaze" | ||
|
||
|
||
class GenreChoices(Enum): | ||
ROCK = "Rock" | ||
ELECTRONIC = "Electronic" | ||
METAL = "Metal" | ||
HIP_HOP = "Hip-Hop" | ||
SHOEGAZE = "Shoegaze" | ||
|
||
|
||
class AlbumBase(SQLModel): | ||
title: str | ||
release_date: date | ||
band_id: int | None = Field(default=None, foreign_key="band.id") | ||
|
||
|
||
class Album(AlbumBase, table=True): | ||
id: int = Field(default=None, primary_key=True) | ||
band: "Band" = Relationship(back_populates="albums") | ||
|
||
|
||
class BandBase(SQLModel): | ||
name: str | ||
genre: GenreChoices | ||
|
||
|
||
class BandCreate(BandBase): | ||
albums: list[AlbumBase] | None = None | ||
|
||
# only pass because it is strictly inheriting and not adding other fields | ||
@field_validator("genre", mode="before") | ||
def title_case_genre(cls, value): | ||
return value.title() | ||
|
||
|
||
class Band(BandBase, table=True): | ||
id: int = Field(default=None, primary_key=True) | ||
albums: list[Album] = Relationship(back_populates="band") |
Oops, something went wrong.