Skip to content

Commit

Permalink
lint
Browse files Browse the repository at this point in the history
  • Loading branch information
lingyielia committed Jul 11, 2024
2 parents dbd5713 + 69df6e0 commit b265a19
Show file tree
Hide file tree
Showing 6 changed files with 16 additions and 22 deletions.
4 changes: 1 addition & 3 deletions vizro-ai/src/vizro_ai/dashboard/graph/code_generation.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,7 @@

import logging
import operator
import re
from typing import Annotated, Any, Dict, List, Union
from typing import Annotated, Dict, List

import pandas as pd
import vizro.models as vm
Expand All @@ -30,7 +29,6 @@
logger.setLevel(logging.INFO)



Messages = List[BaseMessage]
"""List of messages."""

Expand Down
1 change: 0 additions & 1 deletion vizro-ai/src/vizro_ai/dashboard/nodes/_model.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@
from pydantic.v1 import BaseModel, ValidationError
except ImportError: # pragma: no cov
from pydantic import BaseModel, ValidationError
from typing import Dict

from langchain_core.language_models.chat_models import BaseChatModel
from langchain_core.messages import HumanMessage
Expand Down
2 changes: 1 addition & 1 deletion vizro-ai/src/vizro_ai/dashboard/nodes/build.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,11 @@
import logging

import vizro.models as vm
from tqdm.auto import tqdm, trange
from vizro_ai.dashboard.utils import _execute_step
from vizro_ai.utils.helper import DebugFailure

logger = logging.getLogger(__name__)
from tqdm.auto import tqdm, trange


class PageBuilder:
Expand Down
4 changes: 1 addition & 3 deletions vizro-ai/src/vizro_ai/dashboard/nodes/data_summary.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,4 @@ def _get_df_info(df: pd.DataFrame) -> Tuple[Dict[str, str], str]:
class DfInfo(BaseModel):
"""Data Info output."""

dataset_name: str = Field(
pattern=r"^[a-z]+(_[a-z]+)?$", description="Small snake case name of the dataset."
)
dataset_name: str = Field(pattern=r"^[a-z]+(_[a-z]+)?$", description="Small snake case name of the dataset.")
17 changes: 7 additions & 10 deletions vizro-ai/src/vizro_ai/dashboard/nodes/plan.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
"""Module containing the planner functionality."""

import logging
from typing import Dict, List, Literal, Union
from typing import List, Literal, Union

import vizro.models as vm
from langchain_openai import ChatOpenAI
Expand Down Expand Up @@ -45,10 +45,7 @@ class Component(BaseModel):
component_id: str = Field(
pattern=r"^[a-z]+(_[a-z]+)?$", description="Small snake case description of this component."
)
page_id: str = Field(
...,
description="The page id where this component will be placed."
)
page_id: str = Field(..., description="The page id where this component will be placed.")
data_frame: str = Field(
...,
description="The name of the dataframe that this component will use. If the dataframe is "
Expand All @@ -63,13 +60,13 @@ def create(self, model, df_metadata) -> Union[ComponentType, None]:

if self.component_type == "Graph":
return vm.Graph(
id=self.component_id+"_"+self.page_id,
figure=vizro_ai.plot(df=df_metadata.metadata[self.data_frame].df, user_input=self.component_description)
id=self.component_id + "_" + self.page_id,
figure=vizro_ai.plot(
df=df_metadata.metadata[self.data_frame].df, user_input=self.component_description
),
)
elif self.component_type == "AgGrid":
return vm.AgGrid(
id=self.component_id+"_"+self.page_id,
figure=dash_ag_grid(data_frame=self.data_frame))
return vm.AgGrid(id=self.component_id + "_" + self.page_id, figure=dash_ag_grid(data_frame=self.data_frame))
elif self.component_type == "Card":
return _get_proxy_model(
query=self.component_description, llm_model=model, result_model=vm.Card, df_metadata=df_metadata
Expand Down
10 changes: 6 additions & 4 deletions vizro-ai/src/vizro_ai/dashboard/utils.py
Original file line number Diff line number Diff line change
@@ -1,12 +1,11 @@
"""Helper Functions For Vizro AI dashboard."""

from typing import Any, Dict
from dataclasses import dataclass, field

import pandas as pd

# import black
from typing import Any
from typing import Any, Dict

import pandas as pd
import tqdm.std
import vizro.models as vm

Expand All @@ -18,19 +17,22 @@
"import vizro.models as vm\n"
)


@dataclass
class DataFrameMetadata:
"""Dataclass containing metadata for a dataframe."""

df_schema: Dict[str, str]
df: pd.DataFrame


@dataclass
class DfMetadata:
"""Dataclass containing metadata for all dataframes."""

metadata: Dict[str, DataFrameMetadata] = field(default_factory=dict)


@dataclass
class DashboardOutputs:
"""Dataclass containing all possible `VizroAI.dashboard()` output."""
Expand Down

0 comments on commit b265a19

Please sign in to comment.