-
Notifications
You must be signed in to change notification settings - Fork 16
fix: use pydantic models for create index payloads #658
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Conversation
107b8f8
to
72d2555
Compare
72d2555
to
a62d157
Compare
class Config: | ||
"""Pydantic configuration.""" | ||
|
||
populate_by_name = True |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
let s follow the same pattern we use in other aread of the code
class Config: | |
"""Pydantic configuration.""" | |
populate_by_name = True | |
model_config = ConfigDict(populate_by_name=True) |
|
||
if cron_expression: | ||
data_source["indexer"] = { | ||
data_source_dict["indexer"] = { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
why don t we create a model for this and add it as an optional member of DataSourceBase
?
class Indexer(BaseModel):
model_config = ConfigDict(alias_generator=to_camel, populate_by_name=True)
cron_expression: str
time_zone_id: str
@model_validator(mode = 'before')
def validate():
... #we can even add a cron expression validator here
class BaseSourceConfig(BaseModel):
indexer: Optional[Indexer] = None
...
|
||
name: str = Field(description="Index name") | ||
description: str = Field(default="", description="Index description") | ||
data_source: Dict[str, Any] = Field( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
let s use the DataSourceBase
here
No description provided.