Skip to main content

pandapower pandapipes

pandahub pandahub pandahub

pandahub is a data hub for pandapower and pandapipes networks based on MongoDB. It allows you to store pandapower and pandapipes networks as well as timeseries in a MongoDB. pandahub allows you to access the database directly through the PandaHub class, but also provides a REST-API based on FastAPI. Access through the API is managed with a user management implementation based on FastAPI Users.

Development

docker compose up -d runs a mongodb container alongside a pandahub api instance with live reload available at http://localhost:8002. To connect to an existing database instead, set MONGODB_URL to the connection string through an environment variable / in you .env file.

Swagger UI is available at http://localhost:8002/docs.

If you develop on the library and do not need the fastapi app, docker compose up db -d starts only the mongodb container.

MongoClient handling

You can supply a mongodb connection string (or the host as connection string and user/password separately) either as arguments to PandaHub or by setting the following environment variables:

  • MONGODB_URL
  • MONGODB_USER (optional)
  • MONGODB_PASSWORD (optional)

These values are then used as default arguments when creating a PandaHub object.

By default, each instantiation of a PandaHub instance will create a new MongoClient instance. This is fine for interactive use or small scripts. To clean up the mongo client, call ph.close() on the instance once you are done with it.

When running the pandahub API as a web application, provide database credentials through the environment variables and additionally set PANDAHUB_GLOBAL_DB_CLIENT to true. A single, global mongodb client instance per process will then be used for all PandaHub instantiations, as recommended by pymongo.

You can use the following properties to access database resources from a PandaHub object:

  • ph.project_db: database of the activated project (e.g. ph.project_db.net_bus.find().to_list())
  • ph.mgmt_db: the user_management database
  • ph.users_collection: the users collection from the management database
  • ph.projects_collection: the projects collection from the management database

In case you want to access the database but do not need a PandaHub object, there are two convenience functions available:

from pandahub.lib import get_mongo_client

my_collection = get_mongo_client("db", "collection")
docs = collection.find().to_list()

PANDAHUB_GLOBAL_DB_CLIENT is respected, you either get the global client or a fresh instance, in which case you are responsible for cleaning up the connection.

from pandahub.lib import mongo_client

with mongo_client("db", "my_collection") as collection:
    docs = collection.find().to_list()

With the context manager, a new MongoClient is created (even if PANDAHUB_GLOBAL_DB_CLIENT is true) and closed on completion of the with block.

Metadata

Release files for pandahub 0.4.4

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for pandahub 0.4.4
File Size Uploaded Provenance Actions
pandahub-0.4.4.zip 68.2 kB Without provenance Details for pandahub-0.4.4.zip

Built distribution (wheel)

Table of built distributions (wheels) for pandahub 0.4.4
File Interpreter ABI Platform Actions
pandahub-0.4.4-py3-none-any.whl Python 3 none any Details for pandahub-0.4.4-py3-none-any.whl

Total release size: 124.6 kB

Release files / pandahub-0.4.4.zip

Download URL pandahub-0.4.4.zip
Size 68.2 kB
Tags Source
SHA-256 checksum
How to use checksums
79968c1b6c7ff66d4c77aed15b90a92c9f027338e0af6b74d0f5bf6f92f008cb
BLAKE2b-256 checksum
How to use checksums
daec7126ab8151c00d304315a7618c7e54738ad2f04e525bdb913e6ce88a01c3
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.1.0 CPython/3.10.18

Release files / pandahub-0.4.4-py3-none-any.whl

Download URL pandahub-0.4.4-py3-none-any.whl
Size 56.4 kB
Tags Python 3
SHA-256 checksum
How to use checksums
5020878f3d6898c4ff4d488d6625799d1e523ee9c8cf9311e98365046baab083
BLAKE2b-256 checksum
How to use checksums
59c6ecac233d0f5a0c627eabd7bea659eb957489ea35af540d566bd1a550ca9d
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.1.0 CPython/3.10.18

Security for pandahub 0.4.4

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Release history Release notifications | RSS feed

This release

0.4.4 This release

2 release files No provenance

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