Skip to content

Commit

Permalink
Merge branch 'main' into feature/csv-dir-store
Browse files Browse the repository at this point in the history
  • Loading branch information
bramstoeller committed Dec 21, 2022
2 parents bb50082 + 6693220 commit 548f89d
Show file tree
Hide file tree
Showing 111 changed files with 1,760 additions and 1,028 deletions.
2 changes: 1 addition & 1 deletion .github/dco.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# SPDX-FileCopyrightText: 2022 Contributors to the Power Grid Model IO project <[email protected]>
# SPDX-FileCopyrightText: 2022 Contributors to the Power Grid Model project <[email protected]>
#
# SPDX-License-Identifier: MPL-2.0

Expand Down
2 changes: 1 addition & 1 deletion .github/dependabot.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# SPDX-FileCopyrightText: 2022 Contributors to the Power Grid Model IO project <[email protected]>
# SPDX-FileCopyrightText: 2022 Contributors to the Power Grid Model project <[email protected]>
#
# SPDX-License-Identifier: MPL-2.0

Expand Down
158 changes: 130 additions & 28 deletions .github/workflows/build-test-and-sonar.yml
Original file line number Diff line number Diff line change
@@ -1,70 +1,172 @@
# SPDX-FileCopyrightText: 2022 Contributors to the Power Grid Model IO project <[email protected]>
# SPDX-FileCopyrightText: 2022 Contributors to the Power Grid Model project <[email protected]>
#
# SPDX-License-Identifier: MPL-2.0


name: Build, Test and Sonar
name: Build, Test, Sonar and Publish

on:
push:
branches:
- main
- 'release/**'
# run pipeline on pull request
pull_request:
# Allows you to run this workflow manually from the Actions tab
workflow_dispatch:

jobs:

build-python:
permissions:
contents: write
env:
TWINE_USERNAME: ${{ secrets.PYPI_USER }}
TWINE_PASSWORD: ${{ secrets.PYPI_PASS }}
if: (github.event_name == 'push') || (github.event_name == 'workflow_dispatch') || !startsWith(github.head_ref, 'release')
runs-on: ubuntu-latest
outputs:
version: ${{ steps.version.outputs.version }}
steps:
- uses: actions/checkout@v3
with:
fetch-depth: 0 # Shallow clones should be disabled for a better relevancy of analysis

- uses: actions/setup-python@v4
- name: Checkout source code
uses: actions/checkout@v3

- name: Setup Python 3.10
uses: actions/setup-python@v4
with:
python-version: "3.10"

- name: Build (Python 3.10)
- name: Build
run: pip wheel -v --no-deps -w wheelhouse .

- name: Save version
id: version
run: |
echo "::set-output name=version::$(cat PYPI_VERSION)"
run: echo "version=$(cat PYPI_VERSION)" >> $GITHUB_OUTPUT

- name: Test and Coverage for built wheel file
run: |
pip install power-grid-model-io[dev]==${{ steps.version.outputs.version }} --find-links=wheelhouse
pytest
- name: Store built wheel file
uses: actions/upload-artifact@v3
with:
name: power-grid-model-io
path: wheelhouse/

- name: Validation tests
run: pytest tests/validation --no-cov --verbose
sonar-cloud:
# only run sonar server in push event or pull request event from own repo
if: (github.event_name == 'push') || (github.event_name == 'workflow_dispatch') || (!startsWith(github.head_ref, 'release') && (github.event.pull_request.head.repo.owner.login == 'alliander-opensource'))
permissions:
contents: write
runs-on: ubuntu-latest
steps:

- name: Checkout source code
uses: actions/checkout@v3
with:
fetch-depth: 0 # Shallow clones should be disabled for a better relevancy of analysis

- name: Setup Python 3.10
uses: actions/setup-python@v4
with:
python-version: "3.10"

- name: Test and Coverage for sonar cloud in develop mode
- name: Install in develop mode
run: |
pip uninstall -y power-grid-model-io
pip install -e .[dev]
pytest --cov-report=xml:coverage.xml
- name: Test and Coverage
run: |
pytest --cov-report=xml:coverage.xml --cov-fail-under=0
# Fix relative paths in coverage file
# Known bug: https://community.sonarsource.com/t/sonar-on-github-actions-with-python-coverage-source-issue/36057
sed -i 's@/home/runner/work/power-grid-model-io/power-grid-model-io@/github/workspace@g' coverage.xml
- name: SonarCloud Scan
# only run sonar server in push event or pull request event from own repo
if: ${{ (github.event_name == 'push') || (github.event.pull_request.head.repo.owner.login == 'alliander-opensource') }}
uses: SonarSource/sonarcloud-github-action@master
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }}

unit-tests:
needs: build-python
strategy:
matrix:
os: [ubuntu-latest, macos-latest, windows-latest]
python: ["3.8", "3.9", "3.10", "3.11"]
fail-fast: false
runs-on: ${{ matrix.os }}

steps:

- name: Checkout source code
uses: actions/checkout@v3

- name: Setup Python ${{ matrix.python }}
uses: actions/setup-python@v4
with:
python-version: ${{ matrix.python }}

- name: Load built wheel file
uses: actions/download-artifact@v3
with:
name: power-grid-model-io
path: wheelhouse/

- name: Install built wheel file
run: pip install power-grid-model-io[dev]==${{ needs.build-python.outputs.version }} --find-links=wheelhouse

- name: Unit test and coverage
run: pytest --verbose

validation-tests:
needs: build-python
strategy:
matrix:
os: [ubuntu-latest, macos-latest, windows-latest]
python: ["3.8", "3.9", "3.10", "3.11"]
fail-fast: false
runs-on: ${{ matrix.os }}

steps:

- name: Checkout source code
uses: actions/checkout@v3

- name: Setup Python ${{ matrix.python }}
uses: actions/setup-python@v4
with:
python-version: ${{ matrix.python }}

- name: Load built wheel file
uses: actions/download-artifact@v3
with:
name: power-grid-model-io
path: wheelhouse/

- name: Install built wheel file
run: pip install power-grid-model-io[dev]==${{ needs.build-python.outputs.version }} --find-links=wheelhouse

- name: Validation tests
run: pytest tests/validation --no-cov --verbose

publish:
needs:
- build-python
- unit-tests
- validation-tests
- sonar-cloud
permissions:
contents: write
env:
TWINE_USERNAME: ${{ secrets.PYPI_USER }}
TWINE_PASSWORD: ${{ secrets.PYPI_PASS }}
runs-on: ubuntu-latest
steps:
- name: Setup Python 3.10
uses: actions/setup-python@v4
with:
python-version: "3.10"

- name: Load built wheel file
uses: actions/download-artifact@v3
with:
name: power-grid-model-io
path: wheelhouse/

- name: Upload wheels
if: (github.event_name == 'push') || (github.event_name == 'workflow_dispatch')
run: |
Expand All @@ -73,12 +175,12 @@ jobs:
twine upload --verbose wheelhouse/*
- name: Release
uses: softprops/action-gh-release@v1
if: (github.event_name == 'push') || (github.event_name == 'workflow_dispatch')
uses: softprops/action-gh-release@v1
with:
files: |
./wheelhouse/*.whl
tag_name: v${{ steps.version.outputs.version }}
prerelease: ${{ contains(steps.version.outputs.version, 'rc') || contains(steps.version.outputs.version, 'a') }}
tag_name: v${{ needs.build-python.outputs.version }}
prerelease: ${{ contains(needs.build-python.outputs.version, 'rc') || contains(needs.build-python.outputs.version, 'a') }}
generate_release_notes: true
target_commitish: ${{ github.sha }}
2 changes: 1 addition & 1 deletion .github/workflows/check-blocking-labels.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# SPDX-FileCopyrightText: 2022 Contributors to the Power Grid Model IO project <[email protected]>
# SPDX-FileCopyrightText: 2022 Contributors to the Power Grid Model project <[email protected]>
#
# SPDX-License-Identifier: MPL-2.0

Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/check-code-quality.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# SPDX-FileCopyrightText: 2022 Contributors to the Power Grid Model IO project <[email protected]>
# SPDX-FileCopyrightText: 2022 Contributors to the Power Grid Model project <[email protected]>
#
# SPDX-License-Identifier: MPL-2.0

Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/reuse-compliance.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# SPDX-FileCopyrightText: 2022 Contributors to the Power Grid Model IO project <[email protected]>
# SPDX-FileCopyrightText: 2022 Contributors to the Power Grid Model project <[email protected]>
#
# SPDX-License-Identifier: MPL-2.0

Expand Down
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# SPDX-FileCopyrightText: 2022 Contributors to the Power Grid Model IO project <[email protected]>
# SPDX-FileCopyrightText: 2022 Contributors to the Power Grid Model project <[email protected]>
#
# SPDX-License-Identifier: MPL-2.0

Expand All @@ -10,6 +10,7 @@ wheelhouse/

# temporary_files
__pycache__/
*.stackdump
.coverage
.ipynb_checkpoints/
.mypy_cache/
Expand Down
2 changes: 1 addition & 1 deletion .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# SPDX-FileCopyrightText: 2022 Contributors to the Power Grid Model IO project <[email protected]>
# SPDX-FileCopyrightText: 2022 Contributors to the Power Grid Model project <[email protected]>
#
# SPDX-License-Identifier: MPL-2.0

Expand Down
2 changes: 1 addition & 1 deletion CONTRIBUTING.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<!--
SPDX-FileCopyrightText: 2022 Contributors to the Power Grid Model IO project <[email protected]>
SPDX-FileCopyrightText: 2022 Contributors to the Power Grid Model project <[email protected]>
SPDX-License-Identifier: MPL-2.0
-->

Expand Down
2 changes: 1 addition & 1 deletion PROJECT_GOVERNANCE.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<!--
SPDX-FileCopyrightText: 2022 Contributors to the Power Grid Model IO project <[email protected]>
SPDX-FileCopyrightText: 2022 Contributors to the Power Grid Model project <[email protected]>
SPDX-License-Identifier: MPL-2.0
-->

Expand Down
3 changes: 1 addition & 2 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<!--
SPDX-FileCopyrightText: 2022 Contributors to the Power Grid Model IO project <[email protected]>
SPDX-FileCopyrightText: 2022 Contributors to the Power Grid Model project <[email protected]>
SPDX-License-Identifier: MPL-2.0
-->
Expand Down Expand Up @@ -27,7 +27,6 @@ For detailed documentation, see [Read the Docs](https://power-grid-model-io.read

# Examples
* [PGM JSON Example](docs/examples/pgm_json_example.ipynb)
* [Vision/Gaia Example](docs/examples/vision_gaia_example.ipynb)


# License
Expand Down
2 changes: 1 addition & 1 deletion RELEASE.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<!--
SPDX-FileCopyrightText: 2022 Contributors to the Power Grid Model IO project <[email protected]>
SPDX-FileCopyrightText: 2022 Contributors to the Power Grid Model project <[email protected]>
SPDX-License-Identifier: MPL-2.0
-->

Expand Down
2 changes: 1 addition & 1 deletion SUPPORT.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<!--
SPDX-FileCopyrightText: 2022 Contributors to the Power Grid Model IO project <[email protected]>
SPDX-FileCopyrightText: 2022 Contributors to the Power Grid Model project <[email protected]>
SPDX-License-Identifier: MPL-2.0
-->

Expand Down
2 changes: 1 addition & 1 deletion VERSION
Original file line number Diff line number Diff line change
@@ -1 +1 @@
1.0
1.1
2 changes: 1 addition & 1 deletion VERSION.license
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
SPDX-FileCopyrightText: 2022 Contributors to the Power Grid Model IO project <[email protected]>
SPDX-FileCopyrightText: 2022 Contributors to the Power Grid Model project <[email protected]>

SPDX-License-Identifier: MPL-2.0
8 changes: 4 additions & 4 deletions docs/converters/converter.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<!--
SPDX-FileCopyrightText: 2022 Contributors to the Power Grid Model IO project <[email protected]>
SPDX-FileCopyrightText: 2022 Contributors to the Power Grid Model project <[email protected]>
SPDX-License-Identifier: MPL-2.0
-->
Expand All @@ -12,15 +12,15 @@ Here, we shall discuss their basic structure and guidelines for building a custo
Use the examples notebooks to understand how to convert data from the respective formats.

- **PGM JSON Converter:** Refer to the [PGM JSON Example](../examples/pgm_json_example.ipynb)
- **VisonExcelConverter** and **GaiaExcelConverter:** Refer to the [Vision and Gaia Example](../examples/vision_gaia_example.ipynb)
- **VisonExcelConverter** Refer to the [Vision Example](../examples/vision_example.ipynb)
- **Pandapower Converter:** Converts [pandapower network](https://pandapower.readthedocs.io/en/stable/elements.html), which is a dictionary of dataframes, to power-grid-model data.

Refer to [converters](../power_grid_model_io.md#converters) in API documentation for more details

## Structure

`VisonExcelConverter` and `GaiaExcelConverter` are inherited from [tabular converters](tabular_converter.md) for excel exports of vision and gaia respectively.
All 4 converters are derived from the base {py:class}`power_grid_model_io.converters.base_converter`.
The `VisonExcelConverter` extends the [tabular converters](tabular_converter.md) for Excel exports of Vision.
All converters are derived from the base {py:class}`power_grid_model_io.converters.base_converter`.
The usable functions for loading, saving and converting the data are located in the base class.
The private functions (`_load_data`, `_parse_data` and `_serialize_data`) are overloaded based on the specific type of converter (ie. excel, json or pandapower).
It is recommended to create any custom converter in a similar way.
Expand Down
Loading

0 comments on commit 548f89d

Please sign in to comment.