Skip to main content

Python Client for Datastore APIs

Project description

#Datastore Client

Project TCT图像与信息存储数据库 Datastore python版Client

##示例

if __name__ == "__main__":
    #test code
    #this test code shows that:
    #   crate a lot of raw datas
    #   upload them to datastore
    #   gather them togher to create a dataset name 'L-in-H'
    #   and query them out in tow style
    log.getLogger().setLevel(log.INFO)

    #DataStore Client, next coming: DataStore Command Line Tools
    client = Client(
        graphql_entrance = 'http://127.0.0.1:8080',
        minio_entrance = '127.0.0.1:9001',
        graphql_path="/v1/graphql/",
        minio_secure=False,
        download_path='./test_data'
    )
    

    for i in range(20):
        with open('./test_data/test{}.txt'.format(i), 'w+') as f:
            import random
            f.write(str('hi'))

    raws = client.raw.create('./test_data/', metadata={
        'bucket': 'raws', #the name of the bucket
        'source': 'tell me more detail where this object come from!',
        'class_tree': {
            'big_image': 'HSIL',
            'cell': 'LSIL',
            'instance': 'independent'
            },
        'hi':'this is a test, you can add any key you want',
        'but': 'every resources has a prototype keys that you must contains'
        }
    )

    err, dataset = client.dataset.create(name='L-in-H', metadata={
        "note": 'this dataset contains all the LSIL cell from HSIL big image'
        })

    err, dataset_with_raws = client.dataset.add_raws(
        dataset=dataset,
        resources=raws
        )

    err, raws = client.raw.query("""
        {
            dataset_id: {
                _eq: 1
            }
        }
        """)

    err, res = client.queryer.query(
        """
        {
          data_raw(where: {metadata: {_contains: {class_tree: {cell: "LSIL"}}}, tag: {_eq: "latest"}}, distinct_on: id) {
            id
            metadata
            tag
            version
            url
            name
          }
        }
        """
        )
    raws = res['data']['data_raw']
    print(client.downloader.download(raws))

    for i in range(20):
        os.remove('test_data/test{}.txt'.format(i))

##Package Document

使用python函数 help(object)查看文档

##Datastore API Reference

请参阅在线文档

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

DatastoreClient-0.0.7.tar.gz (9.2 kB view details)

Uploaded Source

File details

Details for the file DatastoreClient-0.0.7.tar.gz.

File metadata

  • Download URL: DatastoreClient-0.0.7.tar.gz
  • Upload date:
  • Size: 9.2 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/1.13.0 pkginfo/1.5.0.1 requests/2.21.0 setuptools/40.8.0 requests-toolbelt/0.9.1 tqdm/4.32.2 CPython/3.7.3

File hashes

Hashes for DatastoreClient-0.0.7.tar.gz
Algorithm Hash digest
SHA256 6b17f6ea5667d7e4435f61bb19781ffe563713842a91421ed6dd85ccf8abc158
MD5 9396cf9bdc42505aa6c3a4c436dd3a08
BLAKE2b-256 0083db2b39be1597e36f1bb298f56f728974364cdb2d1402a2793379e2f21c0c

See more details on using hashes here.

Supported by

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