quartic-sdk


Namequartic-sdk JSON
Version 3.3.0 PyPI version JSON
download
home_pagehttps://github.com/Quarticai/QuarticSDK/
SummaryQuarticSDK is the SDK package which exposes the APIs to the user
upload_time2024-09-12 04:46:19
maintainerNone
docs_urlNone
authorQuartic.ai engineering team
requires_pythonNone
licenseMIT
keywords quartic quarticsdk
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI No Travis.
coveralls test coverage No coveralls.
            # QuarticSDK

> Quartic SDK is Quartic.ai's external software development kit which allows users to use assets, tags, and other intelligence outside the Quartic AI Platform. Using the Quartic SDK, third party developers who have access to the Quartic AI Platform can build custom applications.

[![Documentation Status](https://readthedocs.org/projects/quarticsdk/badge/?version=stable)](https://quarticsdk.readthedocs.io/en/stable/?badge=stable)

## Installation
---
Install using `pip`

```
pip install quartic-sdk
```
to Install complete package with all supported model libraries:
```
pip install quartic-sdk[complete]
```

...or follow the following steps to install it from the source:
```
git clone https://github.com/Quarticai/QuarticSDK/
python setup.py install
```

## Example
---
Comprehensive documentation is available at https://quarticsdk.readthedocs.io/en/latest/

Here's an example on how the Quartic SDK can be used:

#### Getting the assets, tags, batches from the server
```python
# For getting raw data we need to use freeflowpaginated query using Graphql Client
# Below is the example for the same
# Assuming that the Quartic.ai server is hosted at `https://test.quartic.ai/`, 
# with the login credentials as username and password is "testuser" and `testpassword respectively, 
# then use GraphqlClient in the following format.

from quartic_sdk import GraphqlClient

client = GraphqlClient(url='https://test.quartic.ai/', username='testuser', password='testpassword')

# Executing Query by:

query='''
query MyQuery($offset_map: CustomDict, $startTime: String!, $stopTime: String!, $tags: [Int]!, $limit: Int) 
{
  freeflowPaginated (startTime: $startTime, stopTime: $stopTime, tags: $tags, limit: $limit, offsetMap: $offset_map ) 
}
'''
# The varaibles passsed are as follows:
# tags (required) : This is list of ids in int datatype
# startTime (required) : startTime in epoch but in string format
# stopTime (required) : stopTime in epoch but in string format
# limit (optional) : limit the datapoints of query. defaults to 1500
# offset_map (optional) : Dictionary where key is tag_id and value is the next offset returned by query executed.

variables={
  "tags": [
    21295
  ],
  "startTime": "1706693453221",
  "stopTime": "1706697053222",
  "limit": 2,
  "offset_map": {}
}

result = client.execute_query(query=query, variables=variables)

#You should see the following result:

{
  "data": {
    "freeflowPaginated": {
      "data": {
        "21295": {
          "data": [
            [
              1706693453500,
              808
            ],
            [
              1706693454000,
              809
            ]
          ]
        }
      },
      "offset_map":{"21295":4}
      "status": 200
    }
  }
}

#using the offset in result you can create the next offset in following way and recall the execute query function
variables = {
  "tags": [
    21295
  ],
  "startTime": "1706693453221",
  "stopTime": "1706697053222",
  "limit": 2,
  "offset_map": offset_map
}

result = client.execute_query(query=query,variables=variables)

#You should see the following result:

{
  "data": {
    "freeflowPaginated": {
      "data": {
        "21295": {
          "data": [
            [
              1706693454500,
              810
            ],
            [
              1706693455000,
              811
            ]
          ]
        }
      },
      "offset_map":{"21295":6}
      "status": 200
    }
  }
}

```

```python

# Assuming that the Quartic.ai server is hosted at `https://test.quartic.ai/`, 
# with the login credentials as username and password is "testuser" and `testpassword respectively, 
# then use GraphqlClient in the following format.

from quartic_sdk import GraphqlClient

client = GraphqlClient(url='https://test.quartic.ai/', username='testuser', password='testpassword')

# Executing Query by:

query='''
query MyQuery {
  Site {
    id
    name
  }
}
'''

result = client.execute_query(query=query)

# To execute query asynchronously use the function below.

#You should see the following result:

{'data': {'Site': [{'id': '1', 'name': 'quartic'}, {'id': '8', 'name': 'ABC site 1'}, {'id': '12', 'name': 'XYZ 123'}]}

async def execute_graphql_query():
    query='''
        query MyQuery {
          Site {
            id
            name
          }
        }
        '''
    resp = await client.execute_async_query(query=query)
    return resp

# Note: The above function will return a coroutine object.

# Example to upload a file.

query = '''
    mutation($file: Upload!, $edge_connector: Int!, $date_format: DateTime!) {
        uploadTelemetryCsv(
            file: $file,
            fileName: "123",
            edgeConnector: $edge_connector,
            dateFormat: $date_format
            )
            {
            taskId
            status
        }
    }
'''


variables = {
    'file': open('<path/to/file>', 'rb'),
    'edge_connector': 'edgeConnector Id',
    'date_format': 'DatTime format'
}

response = client.execute_query(query=query, variables=variables)


```



## Documentation
---
To run the documentation locally, run the following commands in terminal:
```
cd docs
make html

cd docs/source
sphinx-build -b html . _build
open build/html/index.html
```

## Test Cases
---
To run the behaviour test cases, run the command:
```
aloe
```
To run the unit test cases, run the command:
```
pytest
```



            

Raw data

            {
    "_id": null,
    "home_page": "https://github.com/Quarticai/QuarticSDK/",
    "name": "quartic-sdk",
    "maintainer": null,
    "docs_url": null,
    "requires_python": null,
    "maintainer_email": null,
    "keywords": "Quartic, QuarticSDK",
    "author": "Quartic.ai engineering team",
    "author_email": "tech@quartic.ai",
    "download_url": "https://files.pythonhosted.org/packages/32/84/70a83c9720b5bc6d958b8c01ddecfd23be168655f6044eb8f2719f77ce8e/quartic-sdk-3.3.0.tar.gz",
    "platform": null,
    "description": "# QuarticSDK\n\n> Quartic SDK is Quartic.ai's external software development kit which allows users to use assets, tags, and other intelligence outside the Quartic AI Platform. Using the Quartic SDK, third party developers who have access to the Quartic AI Platform can build custom applications.\n\n[![Documentation Status](https://readthedocs.org/projects/quarticsdk/badge/?version=stable)](https://quarticsdk.readthedocs.io/en/stable/?badge=stable)\n\n## Installation\n---\nInstall using `pip`\n\n```\npip install quartic-sdk\n```\nto Install complete package with all supported model libraries:\n```\npip install quartic-sdk[complete]\n```\n\n...or follow the following steps to install it from the source:\n```\ngit clone https://github.com/Quarticai/QuarticSDK/\npython setup.py install\n```\n\n## Example\n---\nComprehensive documentation is available at https://quarticsdk.readthedocs.io/en/latest/\n\nHere's an example on how the Quartic SDK can be used:\n\n#### Getting the assets, tags, batches from the server\n```python\n# For getting raw data we need to use freeflowpaginated query using Graphql Client\n# Below is the example for the same\n# Assuming that the Quartic.ai server is hosted at `https://test.quartic.ai/`, \n# with the login credentials as username and password is \"testuser\" and `testpassword respectively, \n# then use GraphqlClient in the following format.\n\nfrom quartic_sdk import GraphqlClient\n\nclient = GraphqlClient(url='https://test.quartic.ai/', username='testuser', password='testpassword')\n\n# Executing Query by:\n\nquery='''\nquery MyQuery($offset_map: CustomDict, $startTime: String!, $stopTime: String!, $tags: [Int]!, $limit: Int) \n{\n  freeflowPaginated (startTime: $startTime, stopTime: $stopTime, tags: $tags, limit: $limit, offsetMap: $offset_map ) \n}\n'''\n# The varaibles passsed are as follows:\n# tags (required) : This is list of ids in int datatype\n# startTime (required) : startTime in epoch but in string format\n# stopTime (required) : stopTime in epoch but in string format\n# limit (optional) : limit the datapoints of query. defaults to 1500\n# offset_map (optional) : Dictionary where key is tag_id and value is the next offset returned by query executed.\n\nvariables={\n  \"tags\": [\n    21295\n  ],\n  \"startTime\": \"1706693453221\",\n  \"stopTime\": \"1706697053222\",\n  \"limit\": 2,\n  \"offset_map\": {}\n}\n\nresult = client.execute_query(query=query, variables=variables)\n\n#You should see the following result:\n\n{\n  \"data\": {\n    \"freeflowPaginated\": {\n      \"data\": {\n        \"21295\": {\n          \"data\": [\n            [\n              1706693453500,\n              808\n            ],\n            [\n              1706693454000,\n              809\n            ]\n          ]\n        }\n      },\n      \"offset_map\":{\"21295\":4}\n      \"status\": 200\n    }\n  }\n}\n\n#using the offset in result you can create the next offset in following way and recall the execute query function\nvariables = {\n  \"tags\": [\n    21295\n  ],\n  \"startTime\": \"1706693453221\",\n  \"stopTime\": \"1706697053222\",\n  \"limit\": 2,\n  \"offset_map\": offset_map\n}\n\nresult = client.execute_query(query=query,variables=variables)\n\n#You should see the following result:\n\n{\n  \"data\": {\n    \"freeflowPaginated\": {\n      \"data\": {\n        \"21295\": {\n          \"data\": [\n            [\n              1706693454500,\n              810\n            ],\n            [\n              1706693455000,\n              811\n            ]\n          ]\n        }\n      },\n      \"offset_map\":{\"21295\":6}\n      \"status\": 200\n    }\n  }\n}\n\n```\n\n```python\n\n# Assuming that the Quartic.ai server is hosted at `https://test.quartic.ai/`, \n# with the login credentials as username and password is \"testuser\" and `testpassword respectively, \n# then use GraphqlClient in the following format.\n\nfrom quartic_sdk import GraphqlClient\n\nclient = GraphqlClient(url='https://test.quartic.ai/', username='testuser', password='testpassword')\n\n# Executing Query by:\n\nquery='''\nquery MyQuery {\n  Site {\n    id\n    name\n  }\n}\n'''\n\nresult = client.execute_query(query=query)\n\n# To execute query asynchronously use the function below.\n\n#You should see the following result:\n\n{'data': {'Site': [{'id': '1', 'name': 'quartic'}, {'id': '8', 'name': 'ABC site 1'}, {'id': '12', 'name': 'XYZ 123'}]}\n\nasync def execute_graphql_query():\n    query='''\n        query MyQuery {\n          Site {\n            id\n            name\n          }\n        }\n        '''\n    resp = await client.execute_async_query(query=query)\n    return resp\n\n# Note: The above function will return a coroutine object.\n\n# Example to upload a file.\n\nquery = '''\n    mutation($file: Upload!, $edge_connector: Int!, $date_format: DateTime!) {\n        uploadTelemetryCsv(\n            file: $file,\n            fileName: \"123\",\n            edgeConnector: $edge_connector,\n            dateFormat: $date_format\n            )\n            {\n            taskId\n            status\n        }\n    }\n'''\n\n\nvariables = {\n    'file': open('<path/to/file>', 'rb'),\n    'edge_connector': 'edgeConnector Id',\n    'date_format': 'DatTime format'\n}\n\nresponse = client.execute_query(query=query, variables=variables)\n\n\n```\n\n\n\n## Documentation\n---\nTo run the documentation locally, run the following commands in terminal:\n```\ncd docs\nmake html\n\ncd docs/source\nsphinx-build -b html . _build\nopen build/html/index.html\n```\n\n## Test Cases\n---\nTo run the behaviour test cases, run the command:\n```\naloe\n```\nTo run the unit test cases, run the command:\n```\npytest\n```\n\n\n",
    "bugtrack_url": null,
    "license": "MIT",
    "summary": "QuarticSDK is the SDK package which exposes the APIs to the user",
    "version": "3.3.0",
    "project_urls": {
        "Homepage": "https://github.com/Quarticai/QuarticSDK/"
    },
    "split_keywords": [
        "quartic",
        " quarticsdk"
    ],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "0ce16a740253bea578c850c729049df638e2ac7c2ac5ba505b257eafd6f2e88d",
                "md5": "e50c4a1ece96705ce9cb8de664c15a70",
                "sha256": "15c7458b929396de11ef5aa28223bd8dd262dbd96054e4a801c381c53712d457"
            },
            "downloads": -1,
            "filename": "quartic_sdk-3.3.0-py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "e50c4a1ece96705ce9cb8de664c15a70",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": null,
            "size": 54047,
            "upload_time": "2024-09-12T04:46:16",
            "upload_time_iso_8601": "2024-09-12T04:46:16.301529Z",
            "url": "https://files.pythonhosted.org/packages/0c/e1/6a740253bea578c850c729049df638e2ac7c2ac5ba505b257eafd6f2e88d/quartic_sdk-3.3.0-py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "328470a83c9720b5bc6d958b8c01ddecfd23be168655f6044eb8f2719f77ce8e",
                "md5": "17878444cfce1a2d14633ec269cc1c83",
                "sha256": "596d33ac43ecd00c7843c95739020bcbaa3b0fa5e699878a56750536241f52e3"
            },
            "downloads": -1,
            "filename": "quartic-sdk-3.3.0.tar.gz",
            "has_sig": false,
            "md5_digest": "17878444cfce1a2d14633ec269cc1c83",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": null,
            "size": 35408,
            "upload_time": "2024-09-12T04:46:19",
            "upload_time_iso_8601": "2024-09-12T04:46:19.276561Z",
            "url": "https://files.pythonhosted.org/packages/32/84/70a83c9720b5bc6d958b8c01ddecfd23be168655f6044eb8f2719f77ce8e/quartic-sdk-3.3.0.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2024-09-12 04:46:19",
    "github": true,
    "gitlab": false,
    "bitbucket": false,
    "codeberg": false,
    "github_user": "Quarticai",
    "github_project": "QuarticSDK",
    "github_not_found": true,
    "lcname": "quartic-sdk"
}
        
Elapsed time: 2.52110s