Python SDK to support the Luco data observability tool.
Project description
Luco API Python SDK
Giles Matthews: giles.matthews@redkite.com
Purpose
Provide a generalised Python interface to interact with the Luco API.
How to Use
Install the library from PyPI using PIP
pip install LucoPy
Import the LucoApi class from the LucoPy library in your script and create an object of the LucoApi class using the appropriate credentials.
from LucoPy import LucoApi
api = LucoApi(base_url, tenant_id, client_id, client_secret, resource_id)
Authentication
In order to make calls to the API endpoints, the sdk must be able to generate an authenticated access token. Authentication is managed by the ApiCore class using an identity provided during the instantiation of a LucoApi object.
In order to use a service principle, the required credentials must be passed as arguments to the LucoApi class when instantiating it. These credentials are:
- tenant_id
- client_id
- client_secret
- resource_id
Alterntively, a managed identity can be passed into the SDK via the identity
kwarg when instantiating the LucoApi class. The idenity object passed to this kwarg must have a generate_token() method which returns an access token and expiry datetime.
LucoApi Class
LucoApi(base_url, tenant_id=None, client_id=None, client_secret=None, resource_id=None, identity=None, timeout=20, log=False)
This class acts as the gateway to the Luco platform. An instance of this class should be created at the beginning of each script, API calls are then made through the ApiCore which handles the necessary authentication. Use the log
argument to turn logging on or off. Logs are sent to a log.txt file in the home directory. The timeout
option defines the maximum time (seconds) to wait for an HTTPS response from the API before causing a fail.
-
find_slot_id(tag, slot_sequence) --> int
GET /slots/search
-
.get_submission(slot_id, submission_id) --> Submission object
GET /slots/{slotId}/submissions/{submissionId}
-
.create_submission(slot_id) --> Submission object
POST /slots/{slotId}/submissions
-
.find_submission_in_slot_sequence(slotId, submissionId, OnlyCompletedSubmissions=False, TimeDifference=None, FindClosest='historic') --> dict
GET /slots/{slotId}/submissions/{submissionId}/search
-
.find_submissions_by_slot_sequence(slotSequence, onlyLatestSlot=True, onlyDeliveredSlots=True, onlyCompletedSubmissions=True, onlyLatestSubmission=True, expectedAfterUtc=None, expectedBeforeUtc=None) --> dict
GET /slotsequences/submissions
-
.find_latest_submission_by_slot_sequence(slotSequence, expectedAfterUtc=None, expectedBeforeUtc=None) --> slotId, submissionId
GET /slotsequences/submissions
Submission Class
Submission(slot_id, submission_id, core)
Much of the functionality is handled at the Submission level. A Submission object is created by the get_submission or create_submission methods of the LucoApi class. These objects store the definition of the corressponding submission and handle methods relating to it.
-
.params(group=None, key=None) --> dict or value type
Search slot parameters by group name and key name
-
.get_metrics(stages=None, metrics=None) --> dict
GET /slots/{slotID}/submissions/{submissionID}/metrics
-
.get_quality() --> dict
GET /slots/{slotID}/submissions/{submissionID}/quality
-
.submit_run_environment(stage=None, run_environments=None) --> Bool
POST /slots/{slotID}/submissions/{submissionID}/runenvironment
-
.submit_metrics(stage, metric=None, value=None, metrics=None) --> Bool
POST /slots/{slotID}/submissions/{submissionID}/metrics
-
.submit_quality(stage, tool=None, results=None, dataset=None, action=None) --> Bool
POST /slots/{slotID}/submissions/{submissionID}/quality
-
.submit_status(status, stage=None, type=None, message=None, modified_by=None) --> Bool
POST /slots/{slotID}/submissions/{submissionID}/status
-
.submit_completed_status() --> Bool
POST /slots/{slotID}/submissions/{submissionID}/status
Version History
LucoPy-1.2.0
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
File details
Details for the file LucoPy-1.2.0.tar.gz
.
File metadata
- Download URL: LucoPy-1.2.0.tar.gz
- Upload date:
- Size: 7.9 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.8.0 pkginfo/1.8.2 readme-renderer/34.0 requests/2.27.1 requests-toolbelt/0.9.1 urllib3/1.26.9 tqdm/4.64.0 importlib-metadata/4.8.3 keyring/23.4.1 rfc3986/1.5.0 colorama/0.4.4 CPython/3.6.15
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 8bf4668cfc62fe4c116039f2d1fadab89e0c5a8de536f18f37cac7db7266f28d |
|
MD5 | 0b159a0d5b88fa75d81dcc9802279fdd |
|
BLAKE2b-256 | cf2562c68b7466af529748f6e29b0c379026b31fcdd69f537c69b3ae5cf2dfe3 |
File details
Details for the file LucoPy-1.2.0-py3-none-any.whl
.
File metadata
- Download URL: LucoPy-1.2.0-py3-none-any.whl
- Upload date:
- Size: 9.6 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.8.0 pkginfo/1.8.2 readme-renderer/34.0 requests/2.27.1 requests-toolbelt/0.9.1 urllib3/1.26.9 tqdm/4.64.0 importlib-metadata/4.8.3 keyring/23.4.1 rfc3986/1.5.0 colorama/0.4.4 CPython/3.6.15
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 170f87d0ead83780e5dc4dc95f3bf9216ec4d58f999a3f7cdefcca3401930449 |
|
MD5 | a70a230a29b892814aa472192c216080 |
|
BLAKE2b-256 | 7c206afdfa51ef92e4dd64b1d0383dfd55e20474626517180401d5149c15afd8 |