Skip to main content

SunBasket-算法信息存储管理工具

shields_version shields_license shields_author shiedls_python

sunbasketsymbol

介绍

  • SunBasket是一款嵌入式算法辅助管理工具,主要提供五类信息管理,包括算法、模型、参数、应用程序和数据、模型存储管理和算法日志。主要技术使用SQLite、ORM和logging,设计模式为工厂模式。

安装

SunBasket采用Python开发,得益于Python良好的社区环境,安装支持Pythonic风格的各种管理器。

	$ pip install sunbasket-0.1-xxxxxxxxxxxx.whl

快速指南

  • SunBasket提供python-sdk的日志转发至SQLite的日志记录功能,算法、模型、参数、应用、数据的信息管理功能以及模型的存储功能,以下是SunBasket主程脚本示例:
import logging
from sunbasket.handler import SQLiteHandler
from sunbasket.data import AlgorithmInfoManager,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()



####### 存储管理测试
### 模型存储管理
class TestModel(object):

	def __init__(self,name):
		self.name = name
		self.arg = 150

	def add(self,a,b):
		return a+b
test_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作为日志存储后端
  • 支持日志过滤和日志信息选择
  • 管理算法、模型、参数、应用和数据五大类信息
  • 模型的存储管理

技术列表

  • 数据库-SQLite
  • ORM
  • logging
  • 配置文件-yaml
  • 继承重写
  • 静态方法
  • 对象化

设计UML图

以下是设计的UML图: sunbasketuml

Metadata

Release files for shihua-sunbasket 0.1.1

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for shihua-sunbasket 0.1.1
File Size Uploaded
shihua-sunbasket-0.1.1.tar.gz 12.2 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for shihua-sunbasket 0.1.1
File Interpreter ABI Platform
shihua_sunbasket-0.1.1-py3-none-any.whl Python 3 none any Details

Total release size: 29.6 kB

Release files / shihua-sunbasket-0.1.1.tar.gz

Download URL shihua-sunbasket-0.1.1.tar.gz
Size 12.2 kB
Tags Source
SHA-256 checksum
How to use checksums
d9ac026332344d50d007deaffc2c735bf061b353902ad650ef3397d861f350a2
BLAKE2b-256 checksum
How to use checksums
e94b81aea59518aaf548c4c59d0cd24a50f9587457f443a6131338b65f18daba
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/4.0.2 CPython/3.9.12

Release files / shihua_sunbasket-0.1.1-py3-none-any.whl

Download URL shihua_sunbasket-0.1.1-py3-none-any.whl
Size 17.5 kB
Tags Python 3
SHA-256 checksum
How to use checksums
734de43884c2d9931c54b113d957af4631d03134a5675b4b9ac401b55caef14f
BLAKE2b-256 checksum
How to use checksums
9cb0ce003d28c91b33eb6f0cc8dd7b9dbb735dae577134aed5ef4e9ca5d86833
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/4.0.2 CPython/3.9.12

Release history Release notifications | RSS feed

This release

0.1.1 This release

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page