From d919e5735380343be1b21699f7ba18976a8b18ae Mon Sep 17 00:00:00 2001 From: JasonAlbertEinstien Date: Sat, 16 Aug 2025 22:56:11 +0800 Subject: [PATCH 1/5] minor type issue --- plexe/models.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/plexe/models.py b/plexe/models.py index dfab6512..76237e97 100644 --- a/plexe/models.py +++ b/plexe/models.py @@ -142,10 +142,10 @@ def build( self, datasets: List[pd.DataFrame | DatasetGenerator], provider: str | ProviderConfig = "openai/gpt-4o-mini", - timeout: int = None, - max_iterations: int = None, + timeout: int | None = None, + max_iterations: int | None = None, run_timeout: int = 1800, - callbacks: List[Callback] = None, + callbacks: List[Callback] | None = None, verbose: bool = False, # resume: bool = False, enable_checkpointing: bool = False, From 1329fe49181a2a455f8e2f21062765e74c91ebab Mon Sep 17 00:00:00 2001 From: JasonAlbertEinstien Date: Sat, 16 Aug 2025 23:10:35 +0800 Subject: [PATCH 2/5] minor fix --- plexe/models.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/plexe/models.py b/plexe/models.py index 76237e97..d0290fd5 100644 --- a/plexe/models.py +++ b/plexe/models.py @@ -93,8 +93,8 @@ class Model: def __init__( self, intent: str, - input_schema: Type[BaseModel] | Dict[str, type] = None, - output_schema: Type[BaseModel] | Dict[str, type] = None, + input_schema: Type[BaseModel] | Dict[str, type] = {}, + output_schema: Type[BaseModel] | Dict[str, type] = {}, distributed: bool = False, ): """ From 37f1ef9a8c4e3778d97009ff8e0b59159715ff24 Mon Sep 17 00:00:00 2001 From: JasonAlbertEinstien Date: Sat, 16 Aug 2025 23:22:28 +0800 Subject: [PATCH 3/5] avoid duplicate init type mapping --- plexe/internal/common/utils/pydantic_utils.py | 21 ++++++++++--------- 1 file changed, 11 insertions(+), 10 deletions(-) diff --git a/plexe/internal/common/utils/pydantic_utils.py b/plexe/internal/common/utils/pydantic_utils.py index f542cdf3..074d0d66 100644 --- a/plexe/internal/common/utils/pydantic_utils.py +++ b/plexe/internal/common/utils/pydantic_utils.py @@ -66,20 +66,21 @@ def map_to_basemodel(name: str, schema: dict | Type[BaseModel]) -> Type[BaseMode try: # Handle both Dict[str, type] and Dict[str, str] formats annotated_schema = {} + + type_mapping = { + "int": int, + "float": float, + "str": str, + "bool": bool, + "List[int]": List[int], + "List[float]": List[float], + "List[str]": List[str], + "List[bool]": List[bool], + } for k, v in schema.items(): # If v is a string like "int", convert it to the actual type if isinstance(v, str): - type_mapping = { - "int": int, - "float": float, - "str": str, - "bool": bool, - "List[int]": List[int], - "List[float]": List[float], - "List[str]": List[str], - "List[bool]": List[bool], - } if v in type_mapping: annotated_schema[k] = (type_mapping[v], ...) else: From 67ecb88b60546260a212d82f0ad2c095b5184c10 Mon Sep 17 00:00:00 2001 From: JasonAlbertEinstien Date: Sat, 16 Aug 2025 23:30:53 +0800 Subject: [PATCH 4/5] type fix --- plexe/models.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/plexe/models.py b/plexe/models.py index d0290fd5..2484fdd5 100644 --- a/plexe/models.py +++ b/plexe/models.py @@ -38,7 +38,7 @@ import uuid import warnings from datetime import datetime -from typing import Dict, List, Type, Any +from typing import Dict, List, Type, Any, Optional from deprecated import deprecated import pandas as pd @@ -110,8 +110,8 @@ def __init__( # The model's identity is defined by these fields self.intent: str = intent - self.input_schema: Type[BaseModel] = map_to_basemodel("in", input_schema) if input_schema else None - self.output_schema: Type[BaseModel] = map_to_basemodel("out", output_schema) if output_schema else None + self.input_schema: Optional[Type[BaseModel]] = map_to_basemodel("in", input_schema) if input_schema else None + self.output_schema: Optional[Type[BaseModel]] = map_to_basemodel("out", output_schema) if output_schema else None self.training_data: Dict[str, Dataset] = dict() self.distributed: bool = distributed From 7feecb91daefac972cfca1616e988d66fe14f797 Mon Sep 17 00:00:00 2001 From: JasonAlbertEinstien Date: Sun, 17 Aug 2025 00:44:36 +0800 Subject: [PATCH 5/5] formatting problem --- plexe/internal/common/utils/pydantic_utils.py | 2 +- plexe/models.py | 4 +++- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/plexe/internal/common/utils/pydantic_utils.py b/plexe/internal/common/utils/pydantic_utils.py index 074d0d66..b8fd1c1b 100644 --- a/plexe/internal/common/utils/pydantic_utils.py +++ b/plexe/internal/common/utils/pydantic_utils.py @@ -66,7 +66,7 @@ def map_to_basemodel(name: str, schema: dict | Type[BaseModel]) -> Type[BaseMode try: # Handle both Dict[str, type] and Dict[str, str] formats annotated_schema = {} - + type_mapping = { "int": int, "float": float, diff --git a/plexe/models.py b/plexe/models.py index 2484fdd5..eb9faaa4 100644 --- a/plexe/models.py +++ b/plexe/models.py @@ -111,7 +111,9 @@ def __init__( # The model's identity is defined by these fields self.intent: str = intent self.input_schema: Optional[Type[BaseModel]] = map_to_basemodel("in", input_schema) if input_schema else None - self.output_schema: Optional[Type[BaseModel]] = map_to_basemodel("out", output_schema) if output_schema else None + self.output_schema: Optional[Type[BaseModel]] = ( + map_to_basemodel("out", output_schema) if output_schema else None + ) self.training_data: Dict[str, Dataset] = dict() self.distributed: bool = distributed