Getting Started
Welcome to GWC’s Python Library Documentation!
This software is in a very early stage of development, and is regularly being iterated upon and improved. Please note that this library should not be considered to be in a stable state. Should you notice any bugs it is greatly appreciated if you can open an issue in our github!
Installation
To install this library on your computer simply run:
python3 -m venv venv # create a virtual environment
source venv/bin/activate # activate your virtual environment
pip install ursa_sync # install ursa_sync python library to the virtual environment
Or to install directly to your base system (not reccomended) you may run:
pip install ursa_sync
To verify that the installation was successful you can enter a python shell and run:
import ursa_sync as ursa
Getting a Database Key
As we are releasing this as a pre-beta software library for iteration and development for our close internal circle (at first), you must reach out to us directly to attain database access.
If you’d like to participate in the beta trial of ursa software, please reach out to us at hello@gwc-solutions.ch and we will be happy to discuss providing you with a key and a test instance.
Redis Installation
On our roadmap, is the integration of local redis cluster instances. This allows users to access data directly from within their system’s memory, which is spooled there, or synced there, from a master cluster instance running on GWC’s servers.
This feature is not yet implemented, and it is therefore unnecessary to install redis cluster in order to run this library.
First Steps
After you’ve installed your library, and you’ve set the necessary environment variables including the database password, redis password, hosts, ports etc… (instructions provided upon onboarding), you’re ready to import the library:
# Import required objects
from ursa_sync.backend import TimeSeries
from ursa_sync import session
# Open a session with the database
db = session()
...
... # Anything you want to do.
...
db.close()
Recommended Patterns
Because there are backend connections to an RDBMS (PostgreSQL), cache connections (Redis) and connections to TimeSeries database (Promethius) for historical data access, it is necessary to manage your sessions carefully to avoid exhausting the resources of the backend system.
The reccomended pattern for managing all database sessions is as follows.
# Import required objects
from ursa_sync.backend import TimeSeries
from ursa_sync import session
# Open a session with the database
db = session()
# Handle all your production code within a try statement
try:
...
# Various database operations, or data access steps here
...
# Optional Exception handling
except Exception as e:
raise CustomError(f"Something went wrong! Exception caught: {e}")
# Mandatory finally block:
finally:
# Close the database session here.
db.close()