Skip to main content

Python wrapper around the KE API

Project description

KE-py

PyPI version Documentation Status

KE-py 是一个对Kyligence Enterprise Rest API 包装的Python SDK。 可以方便地通过使用Python对KE进行调用。为了更方便帮助KE开发者或维护者提供Python的对接和支持, 同时也可以通过IPython对KE进行实时交互。

安装

pip install KE-py

或者:

pip install git+https://github.com/Kyligence/KE-py.git

Python环境

Python >= 3.6 or Python>=2.7

卸载

pip uninstall ke-py

快速入门 Getting Started

快速入门使用 Quick Start,

关于安装和测试: KE-py 安装与测试文档,

使用案例以及最佳实践 Examples.

使用简介

连接KE服务

from KE impot KE

client = KE('device2', username='ADMIN', password='KYLIN', version=3)

For Developer, 对开发者如果需要debug,可以通过加debug参数打印debug信息

client = KE('device2', username='ADMIN', password='KYLIN', version=3, debug=True)

操作项目

projects = client.projects()
print(projects)

project = client.project('learn_kylin')
print(project)

# 获取当前project的所有 jobs
project.jobs()

# 获取当前project的所有cubes
project.cubes()

操作任务

# 返回最近一周的jobs
jobs = client.jobs(time_filter=1)

job = jobs[0]
# 暂停job
job.pause()

# 获取更新的job progress
print(job.refresh(inplace=True).progress)

操作Cube

cube = client.cubes(name='kylin_sales_cube')[0]
# 构建cube;会返回一个job对象。start_time  type 为datetime或timestamp
job = cube.build(start_time=datetime(2013, 2, 6, 8, 0, 0), end_time=datetime(2013, 2, 7, 8, 0, 0))

# 获取当前cube的所有segments
segments = cube.segments()

操作多个segment

# 刷新segments
segments.refresh()

# 合并segments
segments.merge()

操作单个segment

segment0 = cube.segments()[0]
# 查看单个segment创建时间
segment0.create_time_dt

查询

qyery = client.query('select PART_DT, count(1) from kylin_sales group by PART_DT', project='learn_kylin')
# 返回pandas.DataFrame
query.df

       PART_DT COUNT(1)
0   2012-12-14       14
1   2012-08-28        7
2   2012-02-16       22
3   2013-10-19        8
4   2012-10-22       19
..         ...      ...
95  2012-02-20        9
96  2013-08-06       12
97  2013-06-27       18
98  2012-07-17        9
99  2013-10-12       11

[100 rows x 2 columns]

使用案例、实践

对于更多的实践和使用可以参考 Examples文档, 或者Examples代码

文档 Document

更多文档请查阅 (latest development branch): ReadTheDocs Documentation

Reference

API Document

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

KE-py-0.4.tar.gz (24.1 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

KE_py-0.4-py2.py3-none-any.whl (44.5 kB view details)

Uploaded Python 2Python 3

File details

Details for the file KE-py-0.4.tar.gz.

File metadata

  • Download URL: KE-py-0.4.tar.gz
  • Upload date:
  • Size: 24.1 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.1.1 pkginfo/1.5.0.1 requests/2.22.0 setuptools/46.0.0.post20200309 requests-toolbelt/0.9.1 tqdm/4.42.1 CPython/3.7.6

File hashes

Hashes for KE-py-0.4.tar.gz
Algorithm Hash digest
SHA256 1ae729e8d0fb4784fc61bf69893fd8adf514104ba9e7deb34ae87193a9f668da
MD5 ee08b30c8c4b73eec22488f67ff42d8a
BLAKE2b-256 a131ec7637118d0b9e5d1a58bf1f6334449732cb7ff8d3254704702130636ba1

See more details on using hashes here.

File details

Details for the file KE_py-0.4-py2.py3-none-any.whl.

File metadata

  • Download URL: KE_py-0.4-py2.py3-none-any.whl
  • Upload date:
  • Size: 44.5 kB
  • Tags: Python 2, Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.1.1 pkginfo/1.5.0.1 requests/2.22.0 setuptools/46.0.0.post20200309 requests-toolbelt/0.9.1 tqdm/4.42.1 CPython/3.7.6

File hashes

Hashes for KE_py-0.4-py2.py3-none-any.whl
Algorithm Hash digest
SHA256 cc1d69bbd88de510734595aa1da4fb36717f7bc60e35cd51c936efd424d3e4a0
MD5 b3c0de39470f315cc0f57cf649cecad1
BLAKE2b-256 1468afe1b4b1b35cd6af7f7f1bf60733bcaad85ecc2174036314232b133e6c1a

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page