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


##########
superset-core/src/superset_core/api/models.py:
##########
@@ -0,0 +1,295 @@
+# 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.
+
+"""
+Model API for superset-core.
+
+Provides model classes that will be replaced by host implementations
+during initialization for extension developers to use.
+
+Usage:
+    from superset_core.api.models import Dataset, Database, get_session
+
+    # Use as regular model classes
+    dataset = Dataset(name="My Dataset")
+    db = Database(database_name="My DB")
+    session = get_session()
+"""
+
+from datetime import datetime
+from typing import Any
+from uuid import UUID
+
+from flask_appbuilder import Model
+from sqlalchemy.orm import scoped_session
+
+
+class CoreModel(Model):
+    """
+    Abstract base class that extends Flask-AppBuilder's Model.
+
+    This base class provides the interface contract for all Superset models.
+    The host package provides concrete implementations.
+    """
+
+    __abstract__ = True
+
+
+class Database(CoreModel):
+    """
+    Abstract class for Database models.
+
+    This abstract class defines the contract that database models should 
implement,
+    providing consistent database connectivity and metadata operations.
+    """
+
+    __abstract__ = True
+
+    id: int
+    verbose_name: str
+    database_name: str | None
+
+    @property
+    def name(self) -> str:
+        raise NotImplementedError
+
+    @property
+    def backend(self) -> str:
+        raise NotImplementedError
+
+    @property
+    def data(self) -> dict[str, Any]:
+        raise NotImplementedError
+
+
+class Dataset(CoreModel):
+    """
+    Abstract class for Dataset models.
+
+    This abstract class defines the contract that dataset models should 
implement,
+    providing consistent data source operations and metadata.
+
+    It provides the public API for Datasets implemented by the host 
application.
+    """
+
+    __abstract__ = True
+
+    # Type hints for expected attributes (no actual field definitions)
+    id: int

Review Comment:
   Yes - I initially considered reducing it, but it hit me that the C and U in 
CRUD will require having full property coverage, otherwise the objects may be 
incompatible with the metastore data model.



-- 
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