Skip to main content

A collection of python utilities for StellaSpark Nexus Digital Twin

Project description

Description

A collection of python utilities for StellaSpark Nexus Digital Twin technology. Ready to use for 3.7 >= python >= 3.11.

Usage

Examples
from stellaspark_utils.db import get_indexes, DatabaseManager
from stellaspark_utils.text import parse_time_placeholders

# DatabaseManager is a wrapper around a SQLAlchemy engine to set working memomry and pool_size the DRY way.

# Example 1 instance with argument 'db_url'
db_url = "postgres://<user>:<password>@<host>:<port>/<name>"
db_manager = DatabaseManager(db_url=db_url, max_mb_mem_per_db_worker=64, engine_pool_size=2)

# Example 2 instance with argument 'db_settings'
db_settings = {"USER":"<user>", "PASSWORD":"<password>", "HOST":"<host>", "PORT":"<port>", "NAME":"<name>"}
db_manager = DatabaseManager(db_settings=db_settings, max_mb_mem_per_db_worker=64, engine_pool_size=2)

# This sql transaction is limited by working memory (max_mb_mem_per_db_worker):
result = db_manager.execute("<sql_query>").all()

# This is also limited by working memory:
with db_manager.get_connection() as connection:
    result = connection.execute("<sql_query>").all()

# This sql transaction is NOT limited by working memory, so please do not use.
result = db_manager.engine.execute("<sql_query>").all()

Development

Build using command line

cd <project_root>
docker-compose build stellaspark_utils

Build and Run/debug using VS Code

  1. Open this directory in VS Code
  2. Or in 'Remote Explorer' (left top screen) choose 'New Dev Container'. Or click 'Open a Remote Window (left bottom screen) and then choose 'Reopen in Container'
  3. Now edit 'run_helper_id' in main.py then run the code

Autoformat code:

cd <project_root>
make_nice

Test

cd <project_root>
pytest

Prepare release

  1. Create a Pypi account and after registering, make sure your account has a pypi token
  2. Update version in setup.py
  3. Update the CHANGES.rst with a change message and release date of today
  4. Optionally, autoformat code (see above)
  5. Push changes to GitHub (preferably in a branch 'release__')

Release manually

cd <project_root>
rmdir /s /q "dist"                                      # Remove dist dir (to avoid uploading old distributions)                       
pipenv shell                                            # Activate pipenv environnment (see 'Create an environment' above)
python setup.py sdist                                   # Create distribution (with a '.tar.gz' in it)
twine check dist/*                                      # Validate all distibutions in stellaspark_utils/dist
twine upload dist/*                                     # Upload distribution to pypi.org
# You will be prompted for a username and password: 
# - for the username, use __token__ (yes literally '__token__')
# - for the password, use the pypi token value, including the 'pypi-' prefix

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

stellaspark-utils-2.2.tar.gz (13.8 kB view details)

Uploaded Source

File details

Details for the file stellaspark-utils-2.2.tar.gz.

File metadata

  • Download URL: stellaspark-utils-2.2.tar.gz
  • Upload date:
  • Size: 13.8 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.2 CPython/3.7.9

File hashes

Hashes for stellaspark-utils-2.2.tar.gz
Algorithm Hash digest
SHA256 49bd521bd5c56f78bd32f449254b5e4c54512691659765e59da8f4fdcfecbe91
MD5 3b9fe4fb76544a6ef25b9f551653cbd9
BLAKE2b-256 3cf73b5b9939329761654c3ef33eb75787d2171087035b2cfa02b134a5032199

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