Skip to content

Commit 32893a4

Browse files
committed
Merge branch main into feature/Cleanup-import-statements2 and resolve conflicts
Signed-off-by: Emanuele Brentegani <emabr90@gmail.com>
2 parents 69dc5bb + 645dbf9 commit 32893a4

File tree

74 files changed

+2364
-654
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

74 files changed

+2364
-654
lines changed

.github/workflows/build-test-release.yml

Lines changed: 9 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -13,11 +13,6 @@ on:
1313
type: boolean
1414
description: Create a (pre-)release when CI passes
1515
required: true
16-
secrets:
17-
PYPI_USER:
18-
required: true
19-
PYPI_PASS:
20-
required: true
2116
# run this workflow manually from the Actions tab
2217
workflow_dispatch:
2318
inputs:
@@ -44,12 +39,13 @@ jobs:
4439
python-version: "3.12"
4540

4641
- name: Set PyPI Version
47-
run: |
48-
pip install requests build
49-
python set_pypi_version.py
42+
uses: PowerGridModel/pgm-version-bump@main
5043

5144
- name: Build SDist
52-
run: python -m build --sdist --outdir wheelhouse .
45+
run: |
46+
cat PYPI_VERSION
47+
pip install build
48+
python -m build --sdist --outdir wheelhouse .
5349
5450
- name: Keep version file
5551
uses: actions/upload-artifact@v4
@@ -283,16 +279,14 @@ jobs:
283279
- name: Test
284280
run: pytest
285281

286-
publish-wheels:
282+
github-release:
283+
name: Create and release assets to GitHub
287284
needs: [build-cpp-test-linux, build-cpp-test-windows, build-cpp-test-macos, build-and-test-python, build-and-test-conda]
288285
# always run publish job but fail at the first step if previous jobs have been failed
289286
if: always()
290-
runs-on: ubuntu-24.04
287+
runs-on: ubuntu-latest
291288
permissions:
292289
contents: write
293-
env:
294-
TWINE_USERNAME: ${{ secrets.PYPI_USER }}
295-
TWINE_PASSWORD: ${{ secrets.PYPI_PASS }}
296290

297291
steps:
298292
- name: Fail fast
@@ -329,14 +323,7 @@ jobs:
329323
- name: Display tag
330324
run: echo "${{ steps.tag.outputs.tag }}"
331325

332-
- name: Upload wheels
333-
if: (inputs.create_release)
334-
run: |
335-
pip install twine
336-
echo "Publish to PyPI..."
337-
twine upload --verbose wheelhouse/*
338-
339-
- name: Release
326+
- name: Create GitHub release
340327
uses: softprops/action-gh-release@v2
341328
if: (inputs.create_release)
342329
with:

.github/workflows/check-code-quality.yml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,12 @@ jobs:
6161
sudo apt-get update && sudo apt-get install -y clang-format-18
6262
find . -regex '.*\.\(h\|c\|cpp\|hpp\|cc\|cxx\)' -exec clang-format-18 -style=file -i {} \;
6363
64+
- name: Install and run markdownlint
65+
run: |
66+
npm install -g markdownlint-cli
67+
echo "Running markdownlint"
68+
markdownlint --fix .
69+
6470
- name: If needed raise error
6571
run: |
6672

.github/workflows/ci.yml

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -43,9 +43,6 @@ jobs:
4343
# create_release becomes true if the event that triggered this workflow is "push" on main
4444
# otherwise create_release becomes false
4545
create_release: ${{ (github.event_name == 'workflow_dispatch' && inputs.create_release) || github.event_name == 'push'}}
46-
secrets:
47-
PYPI_USER: ${{ secrets.PYPI_USER }}
48-
PYPI_PASS: ${{ secrets.PYPI_PASS }}
4946

5047
check-code-quality:
5148
uses: "./.github/workflows/check-code-quality.yml"

.github/workflows/nightly.yml

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -21,9 +21,6 @@ jobs:
2121
contents: write
2222
with:
2323
create_release: false
24-
secrets:
25-
PYPI_USER: user
26-
PYPI_PASS: pass
2724

2825
check-code-quality:
2926
uses: "./.github/workflows/check-code-quality.yml"

.github/workflows/publish-pypi.yml

Lines changed: 55 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,55 @@
1+
# SPDX-FileCopyrightText: Contributors to the Power Grid Model project <powergridmodel@lfenergy.org>
2+
#
3+
# SPDX-License-Identifier: MPL-2.0
4+
5+
name: Publish to PyPI
6+
7+
on:
8+
release:
9+
types: [published]
10+
workflow_dispatch:
11+
12+
permissions:
13+
contents: write
14+
id-token: write # Required for Trusted Publishing
15+
16+
jobs:
17+
publish:
18+
name: Publish to PyPI
19+
runs-on: ubuntu-latest
20+
21+
steps:
22+
- name: Download assets from GitHub release
23+
uses: robinraju/release-downloader@v1
24+
with:
25+
repository: ${{ github.repository }}
26+
# download the latest release
27+
latest: true
28+
# don't donwload pre-releases
29+
preRelease: false
30+
fileName: "*"
31+
# don't download GitHub-generated source tar and zip files
32+
tarBall: false
33+
zipBall: false
34+
# create a directory to store the downloaded assets
35+
out-file-path: assets-to-publish
36+
# don't extract downloaded files
37+
extract: false
38+
39+
- name: List downloaded assets
40+
run: ls -la assets-to-publish
41+
42+
- name: Upload assets to PyPI
43+
uses: pypa/gh-action-pypi-publish@release/v1
44+
with:
45+
# To test, use the TestPyPI:
46+
# repository-url: https://test.pypi.org/legacy/
47+
# You must also create an account and project on TestPyPI,
48+
# as well as set the trusted-publisher in the project settings:
49+
# https://docs.pypi.org/trusted-publishers/adding-a-publisher/
50+
# To publish to the official PyPI repository, just keep
51+
# repository-url commented out.
52+
packages-dir: assets-to-publish
53+
skip-existing: true
54+
print-hash: true
55+
verbose: true

.markdownlint.yaml

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
# SPDX-FileCopyrightText: Contributors to the Power Grid Model project <powergridmodel@lfenergy.org>
2+
#
3+
# SPDX-License-Identifier: MPL-2.0
4+
5+
# MD001/heading-increment : Heading levels should only increment by one level at a time : https://github.com/DavidAnson/markdownlint/blob/v0.37.4/doc/md001.md
6+
MD001: false
7+
8+
# MD013/line-length : Line length : https://github.com/DavidAnson/markdownlint/blob/v0.37.4/doc/md013.md
9+
MD013: false
10+
# # Number of characters
11+
# line_length: 80
12+
# # Number of characters for headings
13+
# heading_line_length: 80
14+
# # Number of characters for code blocks
15+
# code_block_line_length: 80
16+
# # Include code blocks
17+
# code_blocks: true
18+
# # Include tables
19+
# tables: true
20+
# # Include headings
21+
# headings: true
22+
# # Strict length checking
23+
# strict: false
24+
# # Stern length checking
25+
# stern: false
26+
27+
# MD024/no-duplicate-heading : Multiple headings with the same content : https://github.com/DavidAnson/markdownlint/blob/v0.37.4/doc/md024.md
28+
MD024: false

.pre-commit-config.yaml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,3 +41,8 @@ repos:
4141
hooks:
4242
- id: clang-format
4343
types_or: [ c++, c ]
44+
- repo: https://github.com/igorshubovych/markdownlint-cli
45+
rev: v0.44.0
46+
hooks:
47+
- id: markdownlint
48+
args: ["--fix"]

.vscode/extensions.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@
2424
"matepek.vscode-catch2-test-adapter",
2525
"cschlosser.doxdocgen",
2626
"fredericbonnet.cmake-test-adapter",
27-
"sonarsource.sonarlint-vscode"
27+
"sonarsource.sonarlint-vscode",
28+
"davidanson.vscode-markdownlint"
2829
]
2930
}

README.md

Lines changed: 9 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -4,16 +4,13 @@ SPDX-FileCopyrightText: Contributors to the Power Grid Model project <powergridm
44
SPDX-License-Identifier: MPL-2.0
55
-->
66

7-
[![PyPI version](https://badge.fury.io/py/power-grid-model.svg?no-cache)](https://badge.fury.io/py/power-grid-model)
7+
[![PyPI version](https://badge.fury.io/py/power-grid-model.svg?no-cache)](https://badge.fury.io/py/power-grid-model) <!-- markdownlint-disable-line first-line-h1 -->
88
[![Anaconda-Server Badge](https://anaconda.org/conda-forge/power-grid-model/badges/version.svg?no-cache)](https://anaconda.org/conda-forge/power-grid-model)
99
[![License: MPL2.0](https://img.shields.io/badge/License-MPL2.0-informational.svg)](https://github.com/PowerGridModel/power-grid-model/blob/main/LICENSE)
1010
[![Downloads](https://static.pepy.tech/badge/power-grid-model)](https://pepy.tech/project/power-grid-model)
1111
[![Downloads](https://static.pepy.tech/badge/power-grid-model/month)](https://pepy.tech/project/power-grid-model)
1212

13-
[![Build and Test C++ and Python](https://github.com/PowerGridModel/power-grid-model/actions/workflows/ci.yml/badge.svg)](https://github.com/PowerGridModel/power-grid-model/actions/workflows/build-test-release.yml)
14-
[![Check Code Quality](https://github.com/PowerGridModel/power-grid-model/actions/workflows/ci.yml/badge.svg)](https://github.com/PowerGridModel/power-grid-model/actions/workflows/check-code-quality.yml)
15-
[![Clang Tidy](https://github.com/PowerGridModel/power-grid-model/actions/workflows/ci.yml/badge.svg)](https://github.com/PowerGridModel/power-grid-model/actions/workflows/clang-tidy.yml)
16-
[![REUSE Compliance Check](https://github.com/PowerGridModel/power-grid-model/actions/workflows/ci.yml/badge.svg)](https://github.com/PowerGridModel/power-grid-model/actions/workflows/reuse-compliance.yml)
13+
[![CI Build](https://github.com/PowerGridModel/power-grid-model/actions/workflows/ci.yml/badge.svg)](https://github.com/PowerGridModel/power-grid-model/actions/workflows/ci.yml)
1714
[![docs](https://readthedocs.org/projects/power-grid-model/badge/)](https://power-grid-model.readthedocs.io/en/stable/)
1815

1916
[![Quality Gate Status](https://sonarcloud.io/api/project_badges/measure?project=PowerGridModel_power-grid-model&metric=alert_status)](https://sonarcloud.io/summary/new_code?id=PowerGridModel_power-grid-model)
@@ -27,7 +24,7 @@ SPDX-License-Identifier: MPL-2.0
2724

2825
[![DOI](https://zenodo.org/badge/DOI/10.5281/zenodo.8054429.svg)](https://zenodo.org/record/8054429)
2926

30-
[![](https://github.com/PowerGridModel/.github/blob/main/artwork/svg/color.svg)](#)
27+
[![Power Grid Model logo](https://github.com/PowerGridModel/.github/blob/main/artwork/svg/color.svg)](#) <!-- markdownlint-disable-line no-empty-links -->
3128

3229
# Power Grid Model
3330

@@ -53,15 +50,15 @@ Want to be updated on the latest news and releases? Subscribe to the Power Grid
5350

5451
You can directly install the package from PyPI.
5552

56-
```
53+
```sh
5754
pip install power-grid-model
5855
```
5956

6057
### Install from Conda
6158

6259
If you are using `conda`, you can directly install the package from `conda-forge` channel.
6360

64-
```
61+
```sh
6562
conda install -c conda-forge power-grid-model
6663
```
6764

@@ -71,7 +68,7 @@ To install the library from source, refer to the [Build Guide](https://power-gri
7168

7269
## Examples
7370

74-
Please refer to [Examples](https://github.com/PowerGridModel/power-grid-model-workshop/tree/main/examples) for more detailed examples for power flow and state estimation.
71+
Please refer to [Examples](https://github.com/PowerGridModel/power-grid-model-workshop/tree/main/examples) for more detailed examples for power flow and state estimation.
7572
Notebooks for validating the input data and exporting input/output data are also included.
7673

7774
## License
@@ -80,14 +77,14 @@ This project is licensed under the Mozilla Public License, version 2.0 - see [LI
8077

8178
## Licenses third-party libraries
8279

83-
This project includes third-party libraries,
80+
This project includes third-party libraries,
8481
which are licensed under their own respective Open-Source licenses.
85-
SPDX-License-Identifier headers are used to show which license is applicable.
82+
SPDX-License-Identifier headers are used to show which license is applicable.
8683
The concerning license files can be found in the [LICENSES](https://github.com/PowerGridModel/power-grid-model/tree/main/LICENSES) directory.
8784

8885
## Contributing
8986

90-
Please read [CODE_OF_CONDUCT](https://github.com/PowerGridModel/.github/blob/main/CODE_OF_CONDUCT.md), [CONTRIBUTING](https://github.com/PowerGridModel/.github/blob/main/CONTRIBUTING.md), [PROJECT GOVERNANCE](https://github.com/PowerGridModel/.github/blob/main/GOVERNANCE.md) and [RELEASE](https://github.com/PowerGridModel/.github/blob/main/RELEASE.md) for details on the process
87+
Please read [CODE_OF_CONDUCT](https://github.com/PowerGridModel/.github/blob/main/CODE_OF_CONDUCT.md), [CONTRIBUTING](https://github.com/PowerGridModel/.github/blob/main/CONTRIBUTING.md), [PROJECT GOVERNANCE](https://github.com/PowerGridModel/.github/blob/main/GOVERNANCE.md) and [RELEASE](https://github.com/PowerGridModel/.github/blob/main/RELEASE.md) for details on the process
9188
for submitting pull requests to us.
9289

9390
Visit [Contribute](https://github.com/PowerGridModel/power-grid-model/contribute) for a list of good first issues in this repo.

docs/advanced_documentation/c-api.md

Lines changed: 16 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -7,18 +7,18 @@ SPDX-License-Identifier: MPL-2.0
77
# Use Power Grid Model through C API
88

99
While many users use Python API for Power Grid Model.
10-
This library also provides a C API.
11-
The main use case of C API is to integrate Power Grid Model into a non-Python application/library, namely, C, C++, JAVA, C#, etc.
10+
This library also provides a C API.
11+
The main use case of C API is to integrate Power Grid Model into a non-Python application/library, namely, C, C++, JAVA, C#, etc.
1212

13-
The C API consists of some
13+
The C API consists of some
1414
{{ "[header files]({}/power_grid_model_c/power_grid_model_c/include)".format(gh_link_head_blob) }}
15-
and a dynamic library (`.so` or `.dll`) built by a
15+
and a dynamic library (`.so` or `.dll`) built by a
1616
{{ "[cmake project]({}/power_grid_model_c/power_grid_model_c/CMakeLists.txt)".format(gh_link_head_blob) }}.
1717
Please refer to the [Build Guide](./build-guide.md) about how to build the library.
1818

1919
You can refer to the [C API Reference](../api_reference/power-grid-model-c-api-reference.rst)
20-
for a detailed documentation of the API.
21-
Please also have a look at an
20+
for a detailed documentation of the API.
21+
Please also have a look at an
2222
{{ "[example]({}/power_grid_model_c_example/main.c)".format(gh_link_head_blob) }}
2323
of C program to use this C API.
2424

@@ -37,7 +37,7 @@ and making it available to their binaries, e.g. by adding its location to `PATH`
3737

3838
## Opaque struct/pointer
3939

40-
As a common C API practice, we use [opaque struct/pointer](https://en.wikipedia.org/wiki/Opaque_pointer) in the API.
40+
As a common C API practice, we use [opaque struct/pointer](https://en.wikipedia.org/wiki/Opaque_pointer) in the API.
4141
The user creates the object by `PGM_create_*` function and release the object by `PGM_destroy_*` function.
4242
In other function calls, the user provide the relevant opaque pointer as the argument.
4343
The real memory layout of the object is unknown to the user.
@@ -50,21 +50,21 @@ Moreover, we might want to also retrieve some meta information from the calculat
5050
The C API uses a handle opaque object `PGM_Handle` to store all these kinds of error messages and information.
5151
You need to pass a handle pointer to most of the functions in the C API.
5252

53-
For example, after calling `PGM_create_model`, you can use `PGM_error_code` and `PGM_error_message`
53+
For example, after calling `PGM_create_model`, you can use `PGM_error_code` and `PGM_error_message`
5454
to check if there is error during the creation and the error message.
5555

5656
If you are calling the C API in multiple threads, each thread should have its own handle object created by `PGM_create_handle`.
5757

5858
## Calculation options
5959

60-
To execute a power grid calculation you need to specify many options,
60+
To execute a power grid calculation you need to specify many options,
6161
e.g., maximum number of iterations, error tolerance, etc.
6262
We could have declared all the calculation options as individual arguments in the `PGM_calculate` function.
63-
However, due to the lack of default argument in C,
63+
However, due to the lack of default argument in C,
6464
this would mean that the C API has a breaking change everytime we add a new option,
6565
which happends very often.
6666

67-
To solve this issue, we use another opaque object `PGM_Options`. The user creates an object with default options by `PGM_create_options`. You can then specify individual options by `PGM_set_*`.
67+
To solve this issue, we use another opaque object `PGM_Options`. The user creates an object with default options by `PGM_create_options`. You can then specify individual options by `PGM_set_*`.
6868
In the `PGM_calculate` function you need to pass a pointer to `PGM_Options`.
6969
In this way, we can ensure the API backwards compatibility.
7070
If we add a new option, it will get a default value in the `PGM_create_options` function.
@@ -77,7 +77,7 @@ For compatibility reasons, that format is dictated by the C API using the `PGM_m
7777

7878
We define the following concepts in the data hierarchy:
7979

80-
* Dataset: a collection of data buffers for a given purpose.
80+
* Dataset: a collection of data buffers for a given purpose.
8181
At this moment, we have four dataset types: `input`, `update`, `sym_output`, `asym_output`.
8282
* Component: a data buffer with the representation of all attributes of a physical grid component in our [data model](../user_manual/components.md), e.g., `node`.
8383
* Attribute: a property of given component. For example, `u_rated` attribute of `node` is the rated voltage of the node.
@@ -126,7 +126,7 @@ Data buffers are almost always allocated and freed in the heap. We provide two w
126126

127127
* You can use the function `PGM_create_buffer` and `PGM_destroy_buffer` to create and destroy buffer.
128128
In this way, the library is handling the memory (de-)allocation.
129-
* You can call some memory (de-)allocation function in your own code according to your platform,
129+
* You can call some memory (de-)allocation function in your own code according to your platform,
130130
e.g., `aligned_alloc` and `free`.
131131
You need to first call `PGM_meta_*` functions to retrieve the size and alignment of a component.
132132

@@ -141,10 +141,10 @@ Once you have the data buffer, you need to set or get attributes. We provide two
141141

142142
* You can use the function `PGM_buffer_set_value` and `PGM_buffer_get_value` to get and set values.
143143
* You can do pointer cast directly on the buffer pointer, by shifting the pointer to proper offset
144-
and cast it to a certain value type.
144+
and cast it to a certain value type.
145145
You need to first call `PGM_meta_*` functions to retrieve the correct offset.
146146

147-
Pointer cast is generally more efficient and flexible because you are not calling into the
147+
Pointer cast is generally more efficient and flexible because you are not calling into the
148148
dynamic library everytime. But it requires the user to retrieve the offset information first.
149149
Using the buffer helper function is more convenient but with some overhead.
150150

@@ -153,7 +153,7 @@ Using the buffer helper function is more convenient but with some overhead.
153153
In the C API we have a function `PGM_buffer_set_nan` which sets all the attributes in a buffer to `NaN`.
154154
In the calculation core, if an optional attribute is `NaN`, it will use the default value.
155155

156-
If you just want to set some attributes and keep everything else as `NaN`,
156+
If you just want to set some attributes and keep everything else as `NaN`,
157157
calling `PGM_buffer_set_nan` before you set attribute is convenient.
158158
This is useful especially in `update` dataset because you do not always update all the mutable attributes.
159159

0 commit comments

Comments
 (0)