没有项目描述
aiot-studio的Python项目详细描述
AIOT工作室
aiot studio是为mnubo's AIoT Studio.
开发数据源和依赖集的官方库。安装
要求
- Python2.7或Python3.4及以上版本
requests
pandas
≥0.20numpy
$ pip install aiot-studio
简单的数据源用法
fromaiotstudio.datasourceimportsearch_df,logdefexecute(parameters):log.info("Hello aiot-studio")result=search_df({"from":"event","select":[{"count":"*"}]})returnresult
配置
库需要用mnubo API credentials配置。 凭据可以按如下方式共享(按优先级降序):
- 环境变量:
MNUBO_CLIENT_ID
,MNUBO_CLIENT_SECRET
,MNUBO_API_URL
- 本地配置文件:
application.conf
在项目根目录或由MNUBO_CONFIG_FILE
环境变量指示的任何位置 - 全局配置文件:
~/.settings/mnubo/application.conf
(或在Windows上C:\Users\<username>\.settings\mnubo\application.conf
)
对于最后两个选项,配置文件应如下所示:
[DEFAULT]
mnubo_client_id = {API_CLIENT_ID}
mnubo_client_secret = {API_CLIENT_SECRET}
mnubo_api_url = https://prod.api.mnubo.com
可用方法
search(query)
:将搜索结果作为JSON返回search_df(query)
:将搜索结果返回为Pandas DataFramelog
:Python logger:将出现在“日志”应用程序中,使用log.info
、log.warning
或log.error
而不是print
blob_store_bucket_names()
:返回可用的存储桶名称blob_store_fetch(bucket_name, object_name)
:从bucket中获取对象
注释:
- 所有“search”方法都需要一个mql查询,如search API文档中所述
- blob存储方法只有在代码运行在mnubo的体系结构中时才可用,在本地使用它会抛出
FeatureUnavailableError