aminghadersohi commented on code in PR #35259:
URL: https://github.com/apache/superset/pull/35259#discussion_r2403013476


##########
superset-core/src/superset_core/dao/types.py:
##########
@@ -0,0 +1,127 @@
+# Licensed to the Apache Software Foundation (ASF) under one
+# or more contributor license agreements.  See the NOTICE file
+# distributed with this work for additional information
+# regarding copyright ownership.  The ASF licenses this file
+# to you under the Apache License, Version 2.0 (the
+# "License"); you may not use this file except in compliance
+# with the License.  You may obtain a copy of the License at
+#
+#   http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing,
+# software distributed under the License is distributed on an
+# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+# KIND, either express or implied.  See the License for the
+# specific language governing permissions and limitations
+# under the License.
+
+"""Protocol interfaces for Data Access Objects."""
+
+from abc import ABC, abstractmethod
+from typing import Any, Generic, Optional, TypeVar, Union
+
+from flask_appbuilder.models.filters import BaseFilter
+from flask_sqlalchemy import BaseQuery
+
+from superset_core.models.base import CoreModel
+
+# Type variable bound to our CoreModel
+T_Model = TypeVar("T_Model", bound=CoreModel)
+
+
+class BaseDAO(Generic[T_Model], ABC):

Review Comment:
   I think this fits in perfectly with the architecture of mcp service. 
Currently the POC adds a set of MCP Core classes that need a BaseDAO like this 
passed so they can stay generic, but because there isn't one yet, i had to add 
this: 
   ```
   class DAO(Protocol):
       """Protocol for Data Access Objects used in model tools.
       To be replaced with one from superset core
       """
   
       model_cls: Type[Any]
   
       @classmethod
       def list(
           cls,
           column_operators: Optional[List[Any]] = None,
           order_column: str = "changed_on",
           order_direction: str = "desc",
           page: int = 0,
           page_size: int = 10,
           search: Optional[str] = None,
           search_columns: Optional[List[str]] = None,
           custom_filters: Optional[Dict[str, Any]] = None,
           columns: Optional[List[str]] = None,
       ) -> tuple[List[Any], int]:
           """List method that all DAOs should implement."""
           ...
   
       @classmethod
       def find_by_id(cls, id: int) -> T | None:
           """Find by ID method that all DAOs should implement."""
           ...
   
       @classmethod
       def get_filterable_columns_and_operators(cls) -> Dict[str, Any]:
           """Get filterable columns and operators."""
           ...
   
       @classmethod
       def count(cls) -> int:
           """Count total number of records. Required for instance info."""
           ...
   
   ```
   
   We can replace it later when this PR is decided upon super easily



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to