ruff format and pyright lint

This commit is contained in:
Sosokker 2025-05-12 14:26:27 +07:00
parent 67f691a46a
commit 93ccc23e2a

View File

@ -13,6 +13,7 @@ class RunCreate(BaseModel):
""" """
Model for creating a new run. (Empty) Model for creating a new run. (Empty)
""" """
pass pass
@ -20,9 +21,10 @@ class Run(BaseModel):
""" """
Status of a pipeline run. Status of a pipeline run.
""" """
id: UUID id: UUID
pipeline_id: UUID pipeline_id: UUID
status: Literal['PENDING', 'RUNNING', 'COMPLETED', 'FAILED'] status: Literal["PENDING", "RUNNING", "COMPLETED", "FAILED"]
started_at: datetime started_at: datetime
finished_at: Optional[datetime] = None finished_at: Optional[datetime] = None
@ -31,24 +33,20 @@ class RunResult(Run):
""" """
Extended run model including results or error. Extended run model including results or error.
""" """
results: Optional[List[Dict[str, Any]]] = None results: Optional[List[Dict[str, Any]]] = None
error: Optional[str] = None error: Optional[str] = None
class ApiConfig(BaseModel): class ApiConfig(BaseModel):
""" """
Configuration for an API source. Configuration for an API source.
""" """
url: HttpUrl = Field(
..., url: HttpUrl = Field(..., description="API endpoint URL")
description="API endpoint URL",
example="https://api.example.com/data"
)
token: Optional[str] = Field( token: Optional[str] = Field(
None, None,
description="Optional bearer token for API authentication", description="Optional bearer token for API authentication",
example="abcdef123456"
) )
@ -56,20 +54,18 @@ class ScrapeConfig(BaseModel):
""" """
Configuration for a web-scraping source. Configuration for a web-scraping source.
""" """
urls: List[HttpUrl] = Field( urls: List[HttpUrl] = Field(
..., ...,
description="List of URLs to scrape", description="List of URLs to scrape",
example=["https://example.com/page1", "https://example.com/page2"]
) )
schema_file: Optional[str] = Field( schema_file: Optional[str] = Field(
None, None,
description="Path to a JSON file containing CSS extraction schema", description="Path to a JSON file containing CSS extraction schema",
example="schemas/page_schema.json"
) )
prompt: Optional[str] = Field( prompt: Optional[str] = Field(
None, None,
description="Prompt string for LLM-based extraction", description="Prompt string for LLM-based extraction",
example="Extract product titles and prices"
) )
@ -77,25 +73,21 @@ class FileConfig(BaseModel):
""" """
Configuration for a file-based source. Supports either a file path or an uploaded file. Configuration for a file-based source. Supports either a file path or an uploaded file.
""" """
path: Optional[str] = Field( path: Optional[str] = Field(
None, None,
description="Path to the input file (optional if upload is provided)", description="Path to the input file (optional if upload is provided)",
example="/data/myfile.json"
) )
upload: Optional[Any] = Field( upload: Optional[Any] = Field(
None, None,
description="Uploaded file object or metadata (optional if path is provided)", description="Uploaded file object or metadata (optional if path is provided)",
example=None
) )
upload_filename: Optional[str] = Field( upload_filename: Optional[str] = Field(
None, None,
description="Original filename of the uploaded file (for validation)", description="Original filename of the uploaded file (for validation)",
example="myfile.json"
) )
format: Literal["csv", "json", "sqlite"] = Field( format: Literal["csv", "json", "sqlite"] = Field(
"json", "json", description="Format of the file"
description="Format of the file",
example="csv"
) )
@field_validator("path", mode="before") @field_validator("path", mode="before")
@ -123,13 +115,14 @@ class FileConfig(BaseModel):
return v return v
class ApiSource(BaseModel): class ApiSource(BaseModel):
""" """
An API-based data source. An API-based data source.
""" """
type: Literal["api"] = Field( type: Literal["api"] = Field(
"api", description="Discriminator for API source" # Removed const=True "api",
description="Discriminator for API source", # Removed const=True
) )
config: ApiConfig config: ApiConfig
@ -138,8 +131,10 @@ class ScrapeSource(BaseModel):
""" """
A web-scraping data source. A web-scraping data source.
""" """
type: Literal["scrape"] = Field( type: Literal["scrape"] = Field(
"scrape", description="Discriminator for scrape source" # Removed const=True "scrape",
description="Discriminator for scrape source", # Removed const=True
) )
config: ScrapeConfig config: ScrapeConfig
@ -148,28 +143,31 @@ class FileSource(BaseModel):
""" """
A file-based data source. A file-based data source.
""" """
type: Literal["file"] = Field( type: Literal["file"] = Field(
"file", description="Discriminator for file source" # Removed const=True "file",
description="Discriminator for file source", # Removed const=True
) )
config: FileConfig config: FileConfig
Source = Annotated[ Source = Annotated[
Union[ApiSource, ScrapeSource, FileSource], Union[ApiSource, ScrapeSource, FileSource],
Field(discriminator="type", description="Union of all source types") Field(discriminator="type", description="Union of all source types"),
] ]
class PipelineCreate(BaseModel): class PipelineCreate(BaseModel):
""" """
Payload for creating a new pipeline. Payload for creating a new pipeline.
""" """
name: Optional[str] = Field( name: Optional[str] = Field(
None, default=None,
description="Optional human-readable name for the pipeline", description="Optional human-readable name for the pipeline",
example="My Data Pipeline"
) )
sources: List[Source] = Field( sources: List[Source] = Field(
..., ..., description="List of data sources for this pipeline"
description="List of data sources for this pipeline"
) )
@ -177,19 +175,12 @@ class Pipeline(BaseModel):
""" """
Representation of a pipeline. Representation of a pipeline.
""" """
id: UUID = Field(
..., id: UUID = Field(..., description="Unique identifier for the pipeline")
description="Unique identifier for the pipeline"
)
name: Optional[str] = Field( name: Optional[str] = Field(
None, None, description="Optional human-readable name for the pipeline"
description="Optional human-readable name for the pipeline"
)
sources: List[Source] = Field(
...,
description="List of configured data sources"
) )
sources: List[Source] = Field(..., description="List of configured data sources")
created_at: datetime = Field( created_at: datetime = Field(
..., ..., description="UTC timestamp when the pipeline was created"
description="UTC timestamp when the pipeline was created" )
)