Metadata-Version: 2.1
Name: pandahub
Version: 0.3.5
Summary: Data hub for pandapower and pandapipes networks based on MongoDB
Author-email: Jan Ulffers <jan.ulffers@iee.fraunhofer.de>, Leon Thurner <leon.thurner@retoflow.de>, Jannis Kupka <jannis.kupka@retoflow.de>, Mike Vogt <mike.vogt@iee.fraunhofer.de>, Joschka Thurner <joschka.thurner@retoflow.de>, Alexander Scheidler <alexander.scheidler@iee.fraunhofer.de>
License: Copyright (c) 2022 by University of Kassel, Fraunhofer Institute for Energy Economics
        and Energy System Technology (IEE) Kassel, retoflow GmbH individual contributors (see AUTHORS file for details).
        All rights reserved.
        
        Redistribution and use in source and binary forms, with or without modification, are permitted 
        provided that the following conditions are met:
        
        1. Redistributions of source code must retain the above copyright notice, this list of conditions
        and the following disclaimer.
        
        2. Redistributions in binary form must reproduce the above copyright notice, this list of
        conditions and the following disclaimer in the documentation and/or other materials provided
        with the distribution.
        
        3. Neither the name of the copyright holder nor the names of its contributors may be used to 
        endorse or promote products derived from this software without specific prior written permission.
        
        THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR 
        IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND 
        FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR 
        CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
        DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 
        DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
        WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY
        WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
        
Project-URL: Homepage, https://github.com/e2nIEE/pandahub
Project-URL: Documentation, https://pandapipes.readthedocs.io
Project-URL: Source, https://github.com/e2nIEE/pandahub
Project-URL: Repository, https://github.com/e2nIEE/pandahub.git
Project-URL: Issues, https://github.com/e2nIEE/pandahub/issues
Project-URL: Download, https://pypi.org/project/pandahub/#files
Project-URL: Changelog, https://github.com/e2nIEE/pandahub/blob/develop/CHANGELOG.md
Keywords: network,analysis,optimization,automation,grid,energy,engineering,simulation
Classifier: Development Status :: 5 - Production/Stable
Classifier: Environment :: Console
Classifier: Intended Audience :: Developers
Classifier: Intended Audience :: Education
Classifier: Intended Audience :: Science/Research
Classifier: License :: OSI Approved :: BSD License
Classifier: Natural Language :: English
Classifier: Operating System :: OS Independent
Classifier: Programming Language :: Python
Classifier: Programming Language :: Python :: 3
Classifier: Programming Language :: Python :: 3.8
Classifier: Programming Language :: Python :: 3.9
Classifier: Programming Language :: Python :: 3.10
Classifier: Programming Language :: Python :: 3.11
Classifier: Programming Language :: Python :: 3.12
Requires-Python: >=3.8
Description-Content-Type: text/markdown
Provides-Extra: docs
Provides-Extra: test
Provides-Extra: all
License-File: LICENSE
License-File: AUTHORS

[![pandapower](https://www.pandapower.org/images/pp.svg)](https://www.pandapower.org)         [![pandapipes](https://www.pandapipes.org/images/pp.svg)](https://www.pandapipes.org)

[![pandahub](https://badge.fury.io/py/pandahub.svg)](https://pypi.org/project/pandahub/) [![pandahub](https://img.shields.io/pypi/pyversions/pandahub.svg)](https://pypi.org/project/pandahub/) [![pandahub](https://img.shields.io/badge/License-BSD%203--Clause-blue.svg)](https://github.com/e2nIEE/pandahub/blob/master/LICENSE)


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 for local development, but also includes a client/server architecture that exposes all relevant methods as an API based on FastAPI. Access through the API is managed with a user management implementation based on FastAPI Users.

## Setup a local pandahub api

Steps to test the client/server structure locally:

1. Start a MongoDB on localhost:27017 (or another custom port)

2. Start the uvicorn server that exposes the API by navigating to "pandahub/api" and running:

   ```
   # windows
   set SECRET=secret & python main.py

   # linux
   SECRET=secret python main.py
   ```

   or if you don't run mongodb on the default port (27017)

   ```
   # windows
   set MONGODB_URL=mongodb://localhost:[mongo-port] & set SECRET=secret & python main.py

   # linux
   MONGODB_URL=mongodb://localhost:[mongo-port] SECRET=secret python main.py
   ```

   The API should now run on http://localhost:8002

   >**Note**
   >A full documentation of all api endpoints can be seen at http://localhost:8002/docs

   >**Note 2**
   >You can avoid always setting the environment variables for SECRET and MONGODB_URL by creating an `.env` file in `pandahub/api/` with the following content:
   >```
   >SECRET=secret
   >MONGODB_URL=mongodb://localhost:[mongo-port]
   >```

## Develop with Docker

`docker compose up` starts a mongodb container alongside pandahub with live reload available at http://localhost:8002.

If you want to connect to a running database, set the database url and specify only docker-compose.yml:

    MONGODB_URL=mongodb://localhost:[mongo-port] docker compose -f docker-compose.yml up



## Use pandahub api with pandahub client

1. Login with the pandahub client

   There are two ways to login with pandahub client

   - If you installed pandahub by pip or with setup.py just run `pandahub-login` in your shell.

   OR

   - Run the following in your python or IPython shell:

   ```
   from pandahub.client.user_management import login
   login()
   ```

   This will guide you through the login process.

2. You only need to login once. After you logged in successfully a configuration file (pandahub.config) containing an authentication token is created in your home directory and will be used every time you use the pandahub client. You only need to login again if you want to use a different instance of the pandahub api.
