Skip to content

Commit

Permalink
initial commit
Browse files Browse the repository at this point in the history
  • Loading branch information
lthurner committed Mar 28, 2022
0 parents commit 5e5ae22
Show file tree
Hide file tree
Showing 50 changed files with 3,317 additions and 0 deletions.
21 changes: 21 additions & 0 deletions .editorconfig
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
# http://editorconfig.org

root = true

[*]
indent_style = space
indent_size = 4
trim_trailing_whitespace = true
insert_final_newline = true
charset = utf-8
end_of_line = lf

[*.bat]
indent_style = tab
end_of_line = crlf

[LICENSE]
insert_final_newline = false

[Makefile]
indent_style = tab
15 changes: 15 additions & 0 deletions .github/ISSUE_TEMPLATE.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
* pandahub version:
* Python version:
* Operating System:

### Description

Describe what you were trying to get done.
Tell us what happened, what went wrong, and what you expected to happen.

### What I Did

```
Paste the command(s) you ran and the output.
If there was a crash, please include the traceback here.
```
44 changes: 44 additions & 0 deletions .github/workflows/github_test_action.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
name: pandahub

on:
push:
branches: '*'

jobs:
build:

runs-on: ubuntu-latest
strategy:
matrix:
python-version: ['3.8']

services:
mongodb:
image: mongo:latest
ports:
- 27017:27017

steps:
- uses: actions/checkout@v2
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v2
with:
python-version: ${{ matrix.python-version }}
- name: Install dependencies
run: |
python -m pip install --upgrade pip
python -m pip install pytest
pip install -r requirements.txt
pip install -r requirements_dev.txt
pip install .["all"]
- name: List of installed packages
run: |
pip list
- name: Test with pytest and Codecov
run: |
pytest --cov=./ --cov-report=xml
- name: Upload coverage to Codecov
uses: codecov/codecov-action@v2
with:
fail_ci_if_error: true
token: ${{ secrets.CODECOV_TOKEN }}
110 changes: 110 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,110 @@
# Byte-compiled / optimized / DLL files
__pycache__/
*.py[cod]
*$py.class

# C extensions
*.so

# Distribution / packaging
.Python
env/
build/
develop-eggs/
dist/
downloads/
eggs/
.eggs/
lib/
lib64/
parts/
sdist/
var/
wheels/
*.egg-info/
.installed.cfg
*.egg

# PyInstaller
# Usually these files are written by a python script from a template
# before PyInstaller builds the exe, so as to inject date/other infos into it.
*.manifest
*.spec

# Installer logs
pip-log.txt
pip-delete-this-directory.txt

# Unit test / coverage reports
htmlcov/
.tox/
.coverage
.coverage.*
.cache
nosetests.xml
coverage.xml
*.cover
.hypothesis/
.pytest_cache/

# Translations
*.mo
*.pot

# Django stuff:
*.log
local_settings.py

# Flask stuff:
instance/
.webassets-cache

# Scrapy stuff:
.scrapy

# Sphinx documentation
docs/_build/

# PyBuilder
target/

# Jupyter Notebook
.ipynb_checkpoints

# pyenv
.python-version

# celery beat schedule file
celerybeat-schedule

# SageMath parsed files
*.sage.py

# dotenv
.env

# virtualenv
.venv
venv/
ENV/

# Spyder project settings
.spyderproject
.spyproject

# Rope project settings
.ropeproject

# mkdocs documentation
/site

# mypy
.mypy_cache/

# IDE settings
.vscode/

# Pycharm
.idea

!pandahub/lib
13 changes: 13 additions & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
# Config file for automatic testing at travis-ci.com

language: python
python:
- 3.8

# Command to install dependencies, e.g. pip install -r requirements.txt --use-mirrors
install: pip install -U tox-travis

# Command to run tests, e.g. python setup.py test
script: tox


6 changes: 6 additions & 0 deletions AUTHORS
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
- Jan Ulffers
- Mike Vogt
- Leon Thurner
- Jannis Kupka
- Joschka Thurner
- Alexander Scheidler
4 changes: 4 additions & 0 deletions CHANGELOG.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
Change Log

[0.1.0]- 2021-11-02
----------------------
8 changes: 8 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
FROM python:3.9 as dev
ENV PYTHONUNBUFFERED 1
ENV PYTHONPATH /code/
WORKDIR /code
COPY ./requirements.txt .
RUN pip install -r requirements.txt
RUN pip install watchdog pyyaml
CMD uvicorn --host "0.0.0.0" --port "8002" "pandahub.api.main:app" --reload
25 changes: 25 additions & 0 deletions LICENSE
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
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.
10 changes: 10 additions & 0 deletions MANIFEST.in
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
include CONTRIBUTING.rst
include HISTORY.rst
include LICENSE
include README.rst

recursive-include tests *
recursive-exclude * __pycache__
recursive-exclude * *.py[co]

recursive-include docs *.rst conf.py Makefile make.bat *.jpg *.png *.gif
70 changes: 70 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,70 @@
# pandahub

## 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.
25 changes: 25 additions & 0 deletions README.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
=========
pandahub
=========






Collection of backend tools and programs for our pandas'



Features
--------

* TODO

Credits
-------

This package was created with Cookiecutter_ and the `audreyr/cookiecutter-pypackage`_ project template.

.. _Cookiecutter: https://github.com/audreyr/cookiecutter
.. _`audreyr/cookiecutter-pypackage`: https://github.com/audreyr/cookiecutter-pypackage
11 changes: 11 additions & 0 deletions docker-compose-override.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
version: '3.7'
services:
pandahub:
depends_on:
- db

db:
image: mongo:latest
restart: always
volumes:
- pandahub_mongodb_data:/data/db
15 changes: 15 additions & 0 deletions docker-compose.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
version: '3.7'
services:
pandahub:
image: dev/pandahub
build: .
environment:
- SECRET=devonly!
- MONGODB_URL=${MONGODB_URL:-mongodb://db:27017}
ports:
- "8002:8002"
volumes:
- ./pandahub:/code/pandahub



4 changes: 4 additions & 0 deletions pandahub/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
from pandahub.lib.PandaHub import PandaHub, PandaHubError
from pandahub.client.PandaHubClient import PandaHubClient


Empty file added pandahub/api/__init__.py
Empty file.
Loading

0 comments on commit 5e5ae22

Please sign in to comment.