一个小库,提供对超导graphql api的编程访问。

cooper-pair的Python项目详细描述


配对

cooper_pair是一个python库,提供对超导graphql api的编程访问。

它支持有限数量的通用用例。(见下文。) cooper_pairnot打算用作graphql的通用集成库。 最有用的graphql查询是notcooper_pairapi中受支持。

为什么要限制用例?

graphql是一种可组合的查询语言。允许的查询空间很大,而且 开发人员有权为给定的作业选择正确的查询。这种夫妻关系的发展 在使用api并允许每个api更快移动的开发过程中, 独立地。

在一个硬Python库中封装一个灵活的API将完全达到这个目的。

相反,把cooper_pair看作是训练车轮。它使快速连接变得容易 并执行一些常见的函数。它还提供了一组示例 查询以了解如何使用GraphQL和同素异形API。

换句话说,cooper-pair可以帮助您开始,但是您将能够获得更多 一旦你学会了使用graphql查询它。

安装

cd cooper-pair
pip install .

或者,

pip install git+ssh://git@github.com/superconductive/cooper.git#egg=cooper_pair&subdirectory=pair

用法

实例化api

from cooper_pair import CooperPair

pair = CooperPair(
    graphql_endpoint="http://my-data-valet-url:3010/graphql",
    email='my_user@some_email.com',
    password='my_very_secure_password'
)

列出数据集

response = pair.list_datasets()
print( json.dumps(response, indent=2))

获取数据集

response = pair.get_dataset("RGF2YXNldPoxODl=")
print( json.dumps(response, indent=2))

列出检查点

response = pair.list_checkpoints()
print( json.dumps(response, indent=2) )
创建一个新的数据集,并根据现有的检查点对其进行评估

从数据帧:

my_df = pd.DataFrame({
    "x" : [1,2,3,4,5],
    "y" : [6,7,8,9,10],
})
response = pair.evaluate_checkpoint_on_pandas_df(
    checkpoint_id="Q2hlY2twb2ludDox",
    pandas_df=my_df,
    filename="my_dataframe_name"
)
evaluation_id = response['addEvaluation']['evaluation']['id']
dataset_id = response['addEvaluation']['evaluation']['dataset']['id']

从文件:

with open('my_file.csv', 'rb') as fd:
    dataset = pair.evaluate_checkpoint_on_file(
        checkpoint_id="Q2hlY2twb2ludDox",
        fd=fd,
    )
evaluation_id = response['addEvaluation']['evaluation']['id']
dataset_id = response['addEvaluation']['evaluation']['dataset']['id']

注意:评估是异步的。当同素异形体第一次返回响应时, 它将有status="created"。当一个工人捡起它时,它将变为pending, 然后根据评估结果来successfailed

您可以按如下方式查询状态:

response = pair.query("""
        query evaluationQuery($id: ID!) {
            evaluation(id: $id) {
                id,
                status
            }
        }
    """,
    variables={
        'id' : evaluation_id
})
print(response)

从json创建新的检查点

import json
with open('checkpoint_definition.json', 'rb') as fd:
    checkpoint_config = json.load(fd)

pair.add_checkpoint_from_expectations_config(
    checkpoint_config, "Checkpoint Name")

欢迎加入QQ群-->: 979659372 Python中文网_新手群

推荐PyPI第三方库


热门话题
java Requestcontextholder在spring 4中具有并发访问权限。IBMWebSphere上的x Web应用程序?   java如何下载、设置和使用Eclipse?   java如何组合这些mysql语句   java JDBC无法连接到openshift上的mysql数据库   如果存在允许正确处理的重载,java对于方便的方法来说是否可行?   使用hibernate序列的java Spring MVC不存在   具有路径的java Selenium ChromeDriver负载扩展问题   读一本书。java中的java文件   退出队列时,Java队列程序结果为空   Java lambda返回带有重复代码问题的列表   java使用意图从其他活动传递数据并在listview中显示   java如何在java中创建JSON输出   java Android:在不破坏或暂停活动的情况下关闭显示   支持Android电视和手机的java多apk   关于Java应用程序测试和调试的一组问题   如何在JavaSE中使用jdbcRealmShiro进行授权   在java中是否有一个无异常检查的URL解析实用程序?   当页面上有多个相同类型的元素时,java会选择一个特定的元素   递归需要帮助发现java代码中的缺陷