semantics
This commit is contained in:
@@ -1,9 +1,8 @@
|
||||
# [DEF:MapperPluginModule:Module]
|
||||
# @SEMANTICS: plugin, mapper, datasets, postgresql, excel
|
||||
# @PURPOSE: Implements a plugin for mapping dataset columns using external database connections or Excel files.
|
||||
# @LAYER: Plugins
|
||||
# @RELATION: Inherits from PluginBase. Uses DatasetMapper from superset_tool.
|
||||
# @RELATION: USES -> TaskContext
|
||||
# #region MapperPluginModule [TYPE Module] [SEMANTICS plugin, mapper, datasets, postgresql, excel]
|
||||
# @BRIEF Implements a plugin for mapping dataset columns using external database connections or Excel files.
|
||||
# @LAYER Plugins
|
||||
# @RELATION Inherits from PluginBase. Uses DatasetMapper from superset_tool.
|
||||
# @RELATION USES -> [TaskContext]
|
||||
|
||||
# [SECTION: IMPORTS]
|
||||
from typing import Dict, Any, Optional
|
||||
@@ -16,71 +15,71 @@ from ..core.utils.dataset_mapper import DatasetMapper
|
||||
from ..core.task_manager.context import TaskContext
|
||||
# [/SECTION]
|
||||
|
||||
# [DEF:MapperPlugin:Class]
|
||||
# @PURPOSE: Plugin for mapping dataset columns verbose names.
|
||||
# #region MapperPlugin [TYPE Class]
|
||||
# @BRIEF Plugin for mapping dataset columns verbose names.
|
||||
class MapperPlugin(PluginBase):
|
||||
"""
|
||||
Plugin for mapping dataset columns verbose names.
|
||||
"""
|
||||
|
||||
@property
|
||||
# [DEF:id:Function]
|
||||
# @PURPOSE: Returns the unique identifier for the mapper plugin.
|
||||
# @PRE: Plugin instance exists.
|
||||
# @POST: Returns string ID.
|
||||
# @RETURN: str - "dataset-mapper"
|
||||
# #region id [TYPE Function]
|
||||
# @BRIEF Returns the unique identifier for the mapper plugin.
|
||||
# @PRE Plugin instance exists.
|
||||
# @POST Returns string ID.
|
||||
# @RETURN str - "dataset-mapper"
|
||||
def id(self) -> str:
|
||||
with belief_scope("id"):
|
||||
return "dataset-mapper"
|
||||
# [/DEF:id:Function]
|
||||
# #endregion id
|
||||
|
||||
@property
|
||||
# [DEF:name:Function]
|
||||
# @PURPOSE: Returns the human-readable name of the mapper plugin.
|
||||
# @PRE: Plugin instance exists.
|
||||
# @POST: Returns string name.
|
||||
# @RETURN: str - Plugin name.
|
||||
# #region name [TYPE Function]
|
||||
# @BRIEF Returns the human-readable name of the mapper plugin.
|
||||
# @PRE Plugin instance exists.
|
||||
# @POST Returns string name.
|
||||
# @RETURN str - Plugin name.
|
||||
def name(self) -> str:
|
||||
with belief_scope("name"):
|
||||
return "Dataset Mapper"
|
||||
# [/DEF:name:Function]
|
||||
# #endregion name
|
||||
|
||||
@property
|
||||
# [DEF:description:Function]
|
||||
# @PURPOSE: Returns a description of the mapper plugin.
|
||||
# @PRE: Plugin instance exists.
|
||||
# @POST: Returns string description.
|
||||
# @RETURN: str - Plugin description.
|
||||
# #region description [TYPE Function]
|
||||
# @BRIEF Returns a description of the mapper plugin.
|
||||
# @PRE Plugin instance exists.
|
||||
# @POST Returns string description.
|
||||
# @RETURN str - Plugin description.
|
||||
def description(self) -> str:
|
||||
with belief_scope("description"):
|
||||
return "Map dataset column verbose names using PostgreSQL comments or Excel files."
|
||||
# [/DEF:description:Function]
|
||||
# #endregion description
|
||||
|
||||
@property
|
||||
# [DEF:version:Function]
|
||||
# @PURPOSE: Returns the version of the mapper plugin.
|
||||
# @PRE: Plugin instance exists.
|
||||
# @POST: Returns string version.
|
||||
# @RETURN: str - "1.0.0"
|
||||
# #region version [TYPE Function]
|
||||
# @BRIEF Returns the version of the mapper plugin.
|
||||
# @PRE Plugin instance exists.
|
||||
# @POST Returns string version.
|
||||
# @RETURN str - "1.0.0"
|
||||
def version(self) -> str:
|
||||
with belief_scope("version"):
|
||||
return "1.0.0"
|
||||
# [/DEF:version:Function]
|
||||
# #endregion version
|
||||
|
||||
@property
|
||||
# [DEF:ui_route:Function]
|
||||
# @PURPOSE: Returns the frontend route for the mapper plugin.
|
||||
# @RETURN: str - "/tools/mapper"
|
||||
# #region ui_route [TYPE Function]
|
||||
# @BRIEF Returns the frontend route for the mapper plugin.
|
||||
# @RETURN str - "/tools/mapper"
|
||||
def ui_route(self) -> str:
|
||||
with belief_scope("ui_route"):
|
||||
return "/tools/mapper"
|
||||
# [/DEF:ui_route:Function]
|
||||
# #endregion ui_route
|
||||
|
||||
# [DEF:get_schema:Function]
|
||||
# @PURPOSE: Returns the JSON schema for the mapper plugin parameters.
|
||||
# @PRE: Plugin instance exists.
|
||||
# @POST: Returns dictionary schema.
|
||||
# @RETURN: Dict[str, Any] - JSON schema.
|
||||
# #region get_schema [TYPE Function]
|
||||
# @BRIEF Returns the JSON schema for the mapper plugin parameters.
|
||||
# @PRE Plugin instance exists.
|
||||
# @POST Returns dictionary schema.
|
||||
# @RETURN Dict[str, Any] - JSON schema.
|
||||
def get_schema(self) -> Dict[str, Any]:
|
||||
with belief_scope("get_schema"):
|
||||
return {
|
||||
@@ -126,10 +125,10 @@ class MapperPlugin(PluginBase):
|
||||
},
|
||||
"required": ["env", "dataset_id", "source"]
|
||||
}
|
||||
# [/DEF:get_schema:Function]
|
||||
# #endregion get_schema
|
||||
|
||||
# [DEF:execute:Function]
|
||||
# @PURPOSE: Executes the dataset mapping logic with TaskContext support.
|
||||
# #region execute [TYPE Function]
|
||||
# @BRIEF Executes the dataset mapping logic with TaskContext support.
|
||||
# @PARAM: params (Dict[str, Any]) - Mapping parameters.
|
||||
# @PARAM: context (Optional[TaskContext]) - Task context for logging with source attribution.
|
||||
# @PRE: Params contain valid 'env', 'dataset_id', and 'source'. params must be a dictionary.
|
||||
@@ -208,7 +207,7 @@ class MapperPlugin(PluginBase):
|
||||
except Exception as e:
|
||||
log.error(f"Mapping failed: {e}")
|
||||
raise
|
||||
# [/DEF:execute:Function]
|
||||
# #endregion execute
|
||||
|
||||
# [/DEF:MapperPlugin:Class]
|
||||
# [/DEF:MapperPluginModule:Module]
|
||||
# #endregion MapperPlugin
|
||||
# #endregion MapperPluginModule
|
||||
|
||||
Reference in New Issue
Block a user