Package: shihua-sunbasket
SunBasket-算法信息存储管理工具介绍SunBasket是一款嵌入式算法辅助管理工具，主要提供五类信息管理，包括算法、模型、参数、应用程序和数据、模型存储管理和算法日志。主要技术使用SQLite、ORM和logging，设计模式为工厂模式。安装SunBasket采用Python开发，得益于Python良好的社区环境，安装支持Pythonic风格的各种管理器。$pipinstallsunbasket-0.1-xxxxxxxxxxxx.whl快速指南SunBasket提供python-sdk的日志转发至SQLite的日志记录功能，算法、模型、参数、应用、数据的信息管理功能以及模型的存储功能,以下是SunBasket主程脚本示例：importloggingfromsunbasket.handlerimportSQLiteHandlerfromsunbasket.dataimportAlgorithmInfoManager,ModelInfoManager,ParameterInfoManager,ApplicationInfoManager,DataInfoManager,ModelStoreManager,serialize_data,deserialize_data####### 手动日志测试### 创建日志操作对象logger=logging.getLogger()### 设置日志操作对象的日志等级logger.setLevel(logging.INFO)### 创建一个SQLite处理器# SQLiteHandler = SQLiteHandler(log_database='sqlite:///E:\\workspace\\SunBasket\\Demo\\test.db')SQLiteHandler=SQLiteHandler()### 设置SQLite处理器的日志等级SQLiteHandler.setLevel(logging.INFO)### 向日志操作对象添加SQLite处理器logger.addHandler(SQLiteHandler)logger.info('start test log handler')logger.warning('this is a warning log')####### 信息管理测试### 连接数据库connect_info='sqlite:///E:\\workspace\\SunBasket\\Demo\\test.db'### 算法信息管理algorithm_info_data_dict={'name':'test','version':'v001','summary':'test summary','config':'test config','remark':'test remark','homepage':'test homepage','author':'shihua','authoremail':'xxxxx@xxx.com','license':'MIT','requires':'numpy,pandas','requiredby':'xxxx'}algorithm_info=AlgorithmInfoManager(connect_info=connect_info,data_dict=algorithm_info_data_dict)algorithm_info.add_data()### 模型信息管理model_info_data_dict={'name':'test','version':'v001','summary':'test summary','config':'test config','remark':'test remark','requires':'numpy,pandas','data':'test data','algorithm':'test algorithm'}model_info=ModelInfoManager(connect_info=connect_info,data_dict=model_info_data_dict)model_info.add_data()### 参数信息管理parameter_info_data_dict={'name':'test','version':'v001','summary':'test summary','config':'test config','remark':'test remark','datatype':'test datatype','requiredby':'xxxx'}parameter_info=ParameterInfoManager(connect_info=connect_info,data_dict=parameter_info_data_dict)parameter_info.add_data()### 应用信息管理application_info_data_dict={'name':'test','version':'v001','summary':'test summary','config':'test config','remark':'test remark','requires':'test requires','project':'xxxx'}application_info=ApplicationInfoManager(connect_info=connect_info,data_dict=application_info_data_dict)application_info.add_data()### 数据信息管理data_info_data_dict={'name':'test','version':'v001','summary':'test summary','config':'test config','remark':'test remark','requireby':'test requiredby','datatype':'test datatype','project':'xxxx'}data_info=DataInfoManager(connect_info=connect_info,data_dict=data_info_data_dict)data_info.add_data()####### 存储管理测试### 模型存储管理classTestModel(object):def__init__(self,name):self.name=nameself.arg=150defadd(self,a,b):returna+btest_model=TestModel(name='testmodel')### 序列化数据对象serialized_data=serialize_data(data=test_model)model_store_data_dict={'name':'test','version':'v001','summary':'test summary','config':'test config','remark':'test remark','data':serialized_data}model_store=ModelStoreManager(connect_info=connect_info,data_dict=model_store_data_dict)model_store.add_data()### 读取目标模型tmp_model=model_store.get_model_data(connect_info=connect_info,name='test',version='v001')### 反序列化数据对象tmp_model_data=deserialize_data(serialized_data=tmp_model.data)print(tmp_model_data.name,tmp_model_data.arg,tmp_model_data.add(1,2))设计基于python基础包logging开发日志转发处理器使用SQLite作为日志存储后端支持日志过滤和日志信息选择管理算法、模型、参数、应用和数据五大类信息模型的存储管理技术列表数据库-SQLiteORMlogging配置文件-yaml继承重写静态方法对象化设计UML图以下是设计的UML图：