Cannlytics provides a user-friendly interface to quickly receive samples, perform analyses, collect and review results, and publish certificates of analysis (CoAs). There are also built in logistics, CRM (client relationship management), inventory management, and invoicing tools.
Project description
Cannlytics Engine
Cannlytics provides a user-friendly interface to quickly receive samples, perform analyses, collect and review results, and publish certificates of analysis (CoAs). There are also built in logistics, CRM (client relationship management), inventory management, and invoicing tools. The Cannlytics engine comes with batteries included, but you are always welcome to supercharge your setup with modifications and custom components.
Installation
You can install the Cannlytics engine from PyPI.
pip install cannlytics
Database Usage
Cannlytics utilizes Firebase for back-end services. Firebase is initialized with firebase.initialize_firebase
, which returns a Firestore database instance. A generic example of using the cannlytics package is as follows.
from cannlytics import firebase
# TODO: Set the path to your Firebase service account.
os.environ["GOOGLE_APPLICATION_CREDENTIALS"] = ""
# Initialize Firebase
database = firebase.initialize_firebase()
# Get a document.
lab = firebase.get_document("labs/cannlytics")
You will need to provide credentials for your application by setting the GOOGLE_APPLICATION_CREDENTIALS environment variable. Set the environment variable GOOGLE_APPLICATION_CREDENTIALS to the file path of the JSON file that contains your service account key. This variable only applies to your current shell session, so if you open a new session, set the variable again.
Firestore
The Firestore functions utilize create_reference
to turn a path into a document or collection reference, depending on the length of the path. Odd length paths refer to collections and even length paths refer to documents. For example, users
is a collection of users, users/{uid}
is a user's document, and users/{uid}/logs
is a sub-collection of logs for the user. With this functionality, you can easily get documents as follows.
# Get all user documents.
users = firebase.get_collection("users")
# Get a document.
user = firebase.get_document("users/xyz")
And create or update documents as follows.
from datetime import datetime
# Create a user log.
timestamp = datetime.now().strftime("%Y-%m-%d_%H-%M-%S")
firebase.update_document(f"users/xyz/logs/{timestamp}", {
"activity": "Something happened",
"created_at": timestamp,
"updated_at": timestamp
})
# Update the user.
firebase.update_document(f"users/xyz", {
"recent_activity": timestamp,
})
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
Hashes for cannlytics-0.0.2-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 6cd3bf2d84bea85e1ec80b4cdb1b6d4850598750b7d2433ce375c57f07ec87f1 |
|
MD5 | e4c8deaee5a9428299470c668ee45171 |
|
BLAKE2b-256 | f7d1542167b2b2d40fba6a2e2cd28edc78bc6238a21f316fdf9ad9016b7e6b35 |