# -*- coding: utf-8 -*-
"""
@author: yq
@time: 2024/11/1
@desc: 
"""
import pandas as pd

from data import DataLoaderBase, DataLoaderHive
from entitys import DbConfigEntity, MetricFucResultEntity
from metrics import MetricBase


class A(MetricBase):

    def __init__(self, file_path: str, sheet_name: str = 0, *args, **kwargs):
        super().__init__(*args, **kwargs)
        self._file_path = file_path
        self._sheet_name = sheet_name

    def _load_data(self, data_loader: DataLoaderBase, *args, **kwargs) -> pd.DataFrame:
        data = data_loader.get_data(self._file_path, self._sheet_name)
        return data

    def calculate(self, *args, **kwargs) -> MetricFucResultEntity:
        data = self._load_data()
        return MetricFucResultEntity(table=data, value='1', image_path='cache/image/t1.png')


if __name__ == "__main__":
    # f_register_metric_func(A)

    data_loader = DataLoaderHive(DbConfigEntity.from_config("config/demo/hive_config.json"))
    df = data_loader.get_data("select * from pokes")
    print(df.head())

    # data_loader = DataLoaderMysql(DbConfigEntity.from_config("./config/mysql_config.json"))
    # monitor_metric = MonitorMetric("./config/model_feature_strategy_template.json")
    # monitor_metric.calculate_metric(data_loader=data_loader)
    # monitor_metric.report()
