how to create one polymorphic model
Nessuno ha ancora preso questa issue.
Valutazione
- Difficoltà
- 5/5
- Tempo stimato
- Più di una settimana
- Idoneità per principianti
- 12/100
- Tipo di issue
- Funzionalità
- Chiarezza
- Abbastanza chiara
- Stato di attività
- Ferma
- Stack tecnologico
- python
- Ambito
- stream-processing
Direzione di ricerca
The request centres on the polymorphic_fields=True option of faust.Record and on passing such a model as value_type to app.topic, so start by finding where Record options and topic value deserialization are handled. Before any change, decide what the maintainers want: the issue asks whether this is feasible and never states a design, and it has been open for about 1,290 days with no decision. Done would mean a written design agreed in the thread, then a test that deserializes a type-tagged event into the matching subclass.
Scritto dal modello di indicizzazione a partire dal testo della issue.
Descrizione
I want to be able to process 1 event that can have multiple schemas based on type.
for example
class Event(faust.Record, serializer="json"):
track_id: str
class InsertDataEvent(Event):
file_path: str
type: str = "INSERT"
class CreateTableEvent(Event):
table_name: str
type: str = "CREATE_TABLE"
class PolyEvent(faust.Record, polymorphic_fields=True):
...
And when I process the event, I want it to automatically be parsed by the type, and validated against the leaf class (AKA CreateTableEvent or InsertDataEvent).
ingestion_topic = app.topic("my-topic", key_type=str, value_type=PolyEvent)
@app.agent(channel=ingestion_topic)
async def process(stream) -> None:
async for value in stream.events():
event = value.value
if event.type == "INSERT":
insert_data(event.file_path)
if event.type == "CREATE_TABLE":
create_table(event.table_name)
Is this feasible? how would I write PolyEvent in that case?
Checklist
- I have included information about relevant versions
- I have verified that the issue persists when using the
masterbranch of Faust.
Versions
- Python version -
3.11.0 - Faust version -
0.10.3
- Lingua principale
- Python
- Stelle
- 1.9k
- Fork
- 205
- Merge medio
- 2h 2m
- PR unite (30g)
- 1
Preparare l'ambiente
- Nessun Dockerfile né file Docker Compose
- Ha un modello di pull request
- Leggi la guida per i contributori
Come iniziare
- Leggi tutta la issue e poi la guida ai contributi del progetto.
- Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
- Fai un fork del repository e lavora su un branch.
- Apri una pull request che faccia riferimento al numero della issue.
Altre issue di faust-streaming/faust
-
Difficoltà 1/5 Meno di un'ora Idoneità per principianti 86/100
faust-streaming/faust#804 ·
-
scripts/install script forces use of ./venv virtualenv, impossible to use with virtualenvwrapperAperta
Difficoltà 1/5 Meno di un'ora Idoneità per principianti 62/100
faust-streaming/faust#28 · 1 commento ·
-
[BUG] SASL PLAINTEXT producer initialization fails : missing sasl_plain_username/passwordForse già presa @wbarnha l’ha presa 56 giorni fa. Aperta
faust-streaming/faust#794 · 2 commenti · 1 reazione · 2 assegnatari ·
-
Difficoltà 4/5 3-5 giorni Idoneità per principianti 18/100
faust-streaming/faust#670 ·
-
Difficoltà 4/5 3-5 giorni Idoneità per principianti 18/100
faust-streaming/faust#666 ·
Tutte le issue di faust-streaming/faust
Issue simili
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 72/100
I maintainer di solito rispondono entro 1 giorno
-
[Maintainer] task area:visualizer
Difficoltà 1/5 Meno di un'ora Idoneità per principianti 78/100
RailtownAI/railtracks#1824 ·
I maintainer di solito rispondono entro 3 giorni
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 62/100
apache/datafusion#27688 ·
I maintainer di solito rispondono entro 1 giorno
-
Difficoltà 1/5 Meno di un'ora Idoneità per principianti 88/100
heasarc/heasarc-tutorials#317 ·
-
bug good first issue help wanted
Difficoltà 2/5 1-3 ore Idoneità per principianti 88/100
mloda-ai/mloda-registry#1664 ·
I maintainer di solito rispondono entro 1 giorno