Skip to main content

QuarticSDK is the SDK package which exposes the APIs to the user

Project description

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

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

# 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
    }
  }
}
# 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

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

quartic-sdk-gsk-3.5.0.tar.gz (51.5 kB view details)

Uploaded Source

Built Distribution

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

quartic_sdk_gsk-3.5.0-py3-none-any.whl (80.9 kB view details)

Uploaded Python 3

File details

Details for the file quartic-sdk-gsk-3.5.0.tar.gz.

File metadata

  • Download URL: quartic-sdk-gsk-3.5.0.tar.gz
  • Upload date:
  • Size: 51.5 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.6.0 importlib_metadata/8.4.0 pkginfo/1.11.1 requests/2.32.3 requests-toolbelt/1.0.0 tqdm/4.66.5 CPython/3.9.5

File hashes

Hashes for quartic-sdk-gsk-3.5.0.tar.gz
Algorithm Hash digest
SHA256 45788e36b1cf4197b24dae0705b1591dff98fc6c457dd066e755458072184838
MD5 bec40e6ff8c01e4c6baff5690618cefd
BLAKE2b-256 bc849eed96dd66f62ceaea681c8f5c3cef930e51b851766b231d3c15a00eea6d

See more details on using hashes here.

File details

Details for the file quartic_sdk_gsk-3.5.0-py3-none-any.whl.

File metadata

  • Download URL: quartic_sdk_gsk-3.5.0-py3-none-any.whl
  • Upload date:
  • Size: 80.9 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.6.0 importlib_metadata/8.4.0 pkginfo/1.11.1 requests/2.32.3 requests-toolbelt/1.0.0 tqdm/4.66.5 CPython/3.9.5

File hashes

Hashes for quartic_sdk_gsk-3.5.0-py3-none-any.whl
Algorithm Hash digest
SHA256 616c667288971b5511f7bb62bb93e29545403c706297e086686f9eab61e7e9be
MD5 64a2eb64e0683f9fcdd4edc0232f9f04
BLAKE2b-256 d641ee1b88f92e1164b863f1de00258fb763883dda4033fbbccd48e2b5e11abc

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