Skip to main content

qronos-client

Python client for QRonos

Installation

This package can be installed via pip:

pip install qronos-client

Example Usage

Authentication

from qronos import QRonosClient

# Create client and login
qronos = QRonosClient(host='https://dev.qronos.xyz')
token, expiry = qronos.login(username='Quentin', password='Rogers')

# Alternatively, if you already have a token
qronos = QRonosClient(host='https://dev.qronos.xyz', token='ABCDEFGHIJKLMN')

# Logout
qronos.logout(all_tokens=True)

Tracker (Item) Data Import

# Import Tracker (Item) Data
job_id = qronos.tracker_import(
    tracker_id=24,
    unique_columns=["Part Number", "Weight"], 
    can_add_item=True,
    can_delete_item=False,
    data=[{"Part Number": "A1", "Weight": 5}, {"Part Number": "A2", "Weight": 8}],
)

Stage Data Import

# Import Stage Data
job_id = qronos.stage_import(
    stage_id=2,
    data=[{"Part Number": "A1", "leadtime": 5}, {"Part Number": "A2", "actual": "2020-10-26"}],
)

Stage Data Import by Tracker Stage

# Import Stage Data
job_id = qronos.stage_import(
    tracker_stage_id=2,
    data=[{"Part Number": "A1", "leadtime": 5}, {"Part Number": "A2", "actual": "2020-10-26"}],
)

Import Status

# Check Status of an Import
status = qronos.import_status(job_id=job_id)

Delete Items

# Delete Items
job_id = qronos.delete_items(
    tracker_id=2, 
    data=["A", "B"],
)

Paginated services

The get_item_attributes, get_item_stages , get_item_stage_history and get_all_item_attribute_history services return paginated responses in the form:

{
    "next": "http://127.0.0.1:8000/api/attributes/?cursor=cD0x&page_size=1",
    "previous": null,
    "items": [{}, ...]
}

The next and previous fields contain the API url for the next/previous pages respectively. If there are no next or previous pages the value would be null.

All items can be returned as a single list of items by the get_all_item_data method.

Following are some usage examples for the get_item_attributes service. Pagination works the same way for all the services. I.e. you can use the same example by just changing the name of the service.

# Request the first page of data
data = qronos.get_item_attributes(
    tracker=3,
    page_size=2,
)

# Request the next page. This will use the same page_size as the previous request.
data = qronos.get_item_attributes(
    tracker=3,
    page=data.get("next")
)
# Request the next next page. Use page_size to change the size of the page.
data = qronos.get_item_attributes(
    tracker=3,
    page=data.get("next"),
    page_size=10,
)

# Request the previous page
data = qronos.get_item_attributes(
    tracker=3,
    page=data.get("previous")
)

# Requesting all the pages using a while loop
all_data = []
data = qronos.get_item_attributes(tracker=3, page_size=10)
all_data.extend(data.get('items'))
while nextp := data.get('next'):
    data = qronos.get_item_attributes(tracker=3, page=nextp)
    all_data.extend(data.get('items'))

Get Item Attribute Data

  • At minimum you must request a tracker or a unique_key/unique_keys
  • You cannot request both a unique_key and unique_keys
  • Use page_size to change the size of the paginated result
  • Use page to navigate to next/previous page
# Get Item Attribute Data by tracker 
item_data = qronos.get_item_attributes(
    tracker=3,
    show_non_mastered=False,
    show_mastered=True,
)

# Get Item Attribute Data by unique keys
item_data = qronos.get_item_attributes(
    unique_keys=["800000689", "800000726", "800000727"],
    show_non_mastered=True,
    show_mastered=True,
)

# Get Item Attribute Data by single unique key
item_data = qronos.get_item_attributes(
    unique_key="800000689",
    show_non_mastered=False,
    show_mastered=True,
)

# Get Item Attribute Data by single unique key for only a single tracker
item_data = qronos.get_item_attributes(
    unique_key="800000689",
    tracker=4,
    show_non_mastered=False,
    show_mastered=True,
)

Get Item Stage Data

  • At minimum you must request a tracker or a unique_key/unique_keys
  • You cannot request both a unique_key and unique_keys
  • You cannot request both a stage and stages
  • You cannot request both a tracker_stage and tracker_stages
  • You cannot request a combinations of stage and tracker_stage fields
  • Use page_size to change the size of the paginated result
  • Use page to navigate to next/previous page
# Get Item Stage Data for a tracker 
stage_data = qronos.get_item_stages(tracker=3)

# Get Item Stage Data by unique keys
stage_data = qronos.get_item_stages(unique_keys=["800000689", "800000726", "800000727"])

# Get Item Stage Data by single unique key but only for a single stage
stage_data = qronos.get_item_stages(
    unique_key="800000689",
    stage=54,
)

# Get Item Stage Data by single unique key but only for a single tracker stage
stage_data = qronos.get_item_stages(
    unique_key="800000689",
    tracker_stage=12,
)

# Get Item Stage Data for a list of stages on a certain tracker
stage_data = qronos.get_item_stages(
    tracker=4,
    stages=[54, 55, 56],
)

# Get Item Stage Data for a list of tracker stages on a certain tracker
stage_data = qronos.get_item_stages(
    tracker=4,
    tracker_stages=[12, 13, 14],
)

Get Item Stage History Data

Get the history of changes to ItemStages. Request follow the same pattern as for Get Item Stage with the addition of the following options:

#  Get changes between a start and end date on a particular tracker
stage_history_data = qronos.get_item_stage_history(
    tracker=4,
    interval_start_date="2020-12-25",  # using ISO-8601 format (YYYY-MM-DD)
    interval_end_date="2021-12-25",
  
)

# Get ItemStageHistory for the changes to the "actual" and "leadtime" fields of ItemStages on a particular tracker
stage_history_data = qronos.get_item_stage_history(
    tracker=4,
    fields=["actual", "leadtime"]
  
)

Get All Data Methods

  • These methods will loop through each page and aggregate the data into a single list of items.

    • get_all_item_attributes
    • get_all_item_stages
    • get_all_item_stage_history
    • get_all_item_attribute_history
# Get all Item Attribute Data for a tracker 
attributes_data = qronos.get_all_item_attributes(tracker=3)

# Get all Item Stage Data for a tracker 
stage__data = qronos.get_all_item_stages(tracker=3)

# Get all Item Stage History Data for a tracker 
attribute_data = qronos.get_all_item_stage_history(tracker=3)

# Get all Item Attribute History Data for a tracker & attributes
attribute_history = qronos.get_all_item_attribute_history(
  tracker=4,
  attribute_names=["Attribute A", "Attribute B"],
  page_size=500,
)

Testing

Please speak with a QRonos Demo Site Admin for credentials in order to run the tests.

Release files for qronos-client 1.8.2

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for qronos-client 1.8.2
File Size Uploaded
qronos_client-1.8.2.tar.gz 8.0 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for qronos-client 1.8.2
File Interpreter ABI Platform
qronos_client-1.8.2-py3-none-any.whl Python 3 none any Details

Total release size: 14.7 kB

Release files / qronos_client-1.8.2.tar.gz

Download URL qronos_client-1.8.2.tar.gz
Size 8.0 kB
Tags Source
SHA-256 checksum
How to use checksums
b36854cb6c6ac0045caf9cd8a3e0b0c1d0ab11e06c2ff2b30cd7a932d1a61443
BLAKE2b-256 checksum
How to use checksums
a021c4b0b1d6c1412cf881ae57c202e457945d23df1352c3f2eb3f35931ccb75
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/5.0.0 CPython/3.12.2

Release files / qronos_client-1.8.2-py3-none-any.whl

Download URL qronos_client-1.8.2-py3-none-any.whl
Size 6.7 kB
Tags Python 3
SHA-256 checksum
How to use checksums
6a224ef9ba5bfc8a5497e62ef28c6f27deaab1e7aa536fc663c25b0cd4090da6
BLAKE2b-256 checksum
How to use checksums
ef1c24d36d376390b2f7256afef56beb6ef8f87dc6c0754fb603e58ddeba5c4d
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/5.0.0 CPython/3.12.2

Release history Release notifications | RSS feed

This release

1.8.2 This release

2 release files

1.8.1

2 release files

1.7.4

2 release files

1.7.3

2 release files

1.7.2

2 release files

1.7.1

2 release files

1.6.0

2 release files

1.5.0

2 release files

1.4.0

2 release files

1.3.0

2 release files

1.2.0

2 release files

1.1.0

2 release files

1.0.0

2 release files

0.0.2

2 release files

0.0.1

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page