Skip to main content

Description

Python utilities supporting Expert API integrations with StellaSpark Nexus, a real-time digital twin platform for monitoring and simulating the natural and built environment. These utilities are primarily intended for calculations, data pipelines, and automation workflows that interact with Nexus on a database-level.

Compatible with Python 3.7 – 3.14.

About StellaSpark Nexus

StellaSpark Nexus is a digital twin platform that combines geospatial data and time series and turns it into interactive 2D/3D maps, dashboards and a unified API. It is used by governments, NGOs, utilities, contractors, engineers, and technical consultants to unify live data, run operational forecasts and scenario analysis, and share insights across organizations and public stakeholders. It is used in domains such as:

  • Urban planning
  • Infrastructure and construction
  • Water and environmental management
  • Energy and utilities
  • Mobility and telecommunications
  • Real estate

The platform integrates live data from sensors, virtually all geospatial file formats, databases, and external APIs (REST/WFS/database), enabling monitoring, analysis, simulation, and secure data sharing. This repository contains Python utilities that support those workflows.

Installation

Install via PyPI:

pip install stellaspark-utils

Usage

from sqlalchemy import text
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 memory 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(text("<sql_query>")).all()

# This SQL transaction is NOT limited by working memory. Only use if you deliberately need to bypass the
# work_mem cap:
with db_manager.engine.connect() as connection:
    result = connection.execute(text("<sql_query>")).all()

Development

Build devcontainer image

cd <project_root>
docker-compose build stellaspark_utils
Test coverage (release 4.0)
Name                        Stmts   Miss  Cover
-----------------------------------------------
setup.py                       10     10     0%
stellaspark_utils/db.py       177    112    37%
stellaspark_utils/text.py     110     87    21%
-----------------------------------------------
TOTAL                         297    209    30%

Release

Preparation
  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 steps
cd <project_root>
make_nice           # Autoformat python code
pytest              # Test against every Python version listed in setup.py's classifiers
build               # Runs pip-audit
release             # When prompted for password use your PyPI token including the 'pypi-' prefix

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-4.2.tar.gz (15.8 kB view details)

Uploaded Source

File details

Details for the file stellaspark_utils-4.2.tar.gz.

File metadata

  • Download URL: stellaspark_utils-4.2.tar.gz
  • Upload date:
  • Size: 15.8 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/7.0.0 CPython/3.12.9

File hashes

Hashes for stellaspark_utils-4.2.tar.gz
Algorithm Hash digest
SHA256 4e87622839b4de61eb5b9dd530f440ff366c958854bcad9bfe7170d681999624
MD5 12d7cd211e8d292593bf1ea0fec068c6
BLAKE2b-256 c2f328bae1d9b066ee3497cf07b06ea41f1cad09127b3ca66970861715f16575

See more details on using hashes here.

Release history Release notifications | RSS feed

4.5

1 file

4.4

1 file

4.3

1 file

This release

4.2 This release

1 file

4.1

1 file

4.0

1 file

3.2

1 file

3.1

1 file

3.0

1 file

2.6

1 file

2.5

1 file

2.4

1 file

2.3

1 file

2.2

1 file

2.1

1 file

2.0

1 file

1.9

1 file

1.8

1 file

1.7

1 file

1.6

1 file

1.5

1 file

1.4

1 file

1.3

1 file

1.2

1 file

1.1

1 file

1.0

1 file

0.9

1 file

0.8

1 file

0.7

1 file

0.6

1 file

0.5

1 file

0.4

1 file

0.3

1 file

0.2

1 file

0.1

1 file

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