Skip to content

Commit 32c8bd7

Browse files
authored
Merge branch 'main' into current-sensor-validation-tests
2 parents c0a52d8 + 4040fbd commit 32c8bd7

File tree

15 files changed

+640
-233
lines changed

15 files changed

+640
-233
lines changed

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

+1-1
Original file line numberDiff line numberDiff line change
@@ -208,7 +208,7 @@ jobs:
208208
xcode-version: latest-stable
209209

210210
- name: Build wheels
211-
uses: pypa/cibuildwheel@v2.23.2
211+
uses: pypa/cibuildwheel@v2.23.3
212212
# GitHub Actions specific build parameters
213213
env:
214214
# pass GitHub runner info into Linux container

.github/workflows/ci.yml

+45
Original file line numberDiff line numberDiff line change
@@ -61,3 +61,48 @@ jobs:
6161

6262
steps:
6363
- run: echo "ci passed"
64+
65+
publish:
66+
name: Publish to PyPI
67+
runs-on: ubuntu-latest
68+
permissions:
69+
contents: write
70+
id-token: write # Required for Trusted Publishing
71+
needs: build-test-release
72+
if: (github.event_name == 'workflow_dispatch') || github.event_name == 'push'
73+
74+
steps:
75+
- name: Download assets from GitHub release
76+
uses: robinraju/release-downloader@v1
77+
with:
78+
repository: ${{ github.repository }}
79+
# download the latest release
80+
latest: true
81+
# don't download pre-releases
82+
preRelease: false
83+
fileName: "*"
84+
# don't download GitHub-generated source tar and zip files
85+
tarBall: false
86+
zipBall: false
87+
# create a directory to store the downloaded assets
88+
out-file-path: assets-to-publish
89+
# don't extract downloaded files
90+
extract: false
91+
92+
- name: List downloaded assets
93+
run: ls -la assets-to-publish
94+
95+
- name: Upload assets to PyPI
96+
uses: pypa/gh-action-pypi-publish@release/v1
97+
with:
98+
# To test, use the TestPyPI:
99+
# repository-url: https://test.pypi.org/legacy/
100+
# You must also create an account and project on TestPyPI,
101+
# as well as set the trusted-publisher in the project settings:
102+
# https://docs.pypi.org/trusted-publishers/adding-a-publisher/
103+
# To publish to the official PyPI repository, just keep
104+
# repository-url commented out.
105+
packages-dir: assets-to-publish
106+
skip-existing: true
107+
print-hash: true
108+
verbose: true

.github/workflows/publish-pypi.yml

-55
This file was deleted.
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,131 @@
1+
<!--
2+
SPDX-FileCopyrightText: Contributors to the Power Grid Model project <powergridmodel@lfenergy.org>
3+
4+
SPDX-License-Identifier: MPL-2.0
5+
-->
6+
7+
# High-level design
8+
9+
The power-grid-model follows a typical dynamic/shared library approach, in which the user
10+
interface is separated from the core implementation using a strict system boundary. Depending
11+
on the use case and programming language used by the user to call the interface, the user can
12+
opt to interface with the C API in different ways.
13+
14+
## Layers of abstraction
15+
16+
For the sake of explanation, we consider the
17+
following layers of abstraction, in increasing order of ease-of-use and abstraction.
18+
19+
* Raw system interface
20+
* System symbols only
21+
* Everything is handled by the user, including which symbols are supported
22+
* Exposition-only
23+
* Exposes the supported symbols in a language supported by the user
24+
* Memory management and error handling is the responsibility of the user
25+
* Simple wrapper
26+
* Wraps the interface in a language supported by the user
27+
* Handles memory management, basic error handling and type conversions
28+
* Contains no additional features except maybe some basic utility tools
29+
* The feature-rich layer
30+
* Extensive wrapper around the interface with easy functionality exposure and utility functions
31+
* Extensive type checks
32+
33+
## Existing library interfaces
34+
35+
The following library interfaces are currently included in the power-grid-model.
36+
37+
| Interface type | Status | Layer | Explanation | Supported by |
38+
| -------------- | ------------ | ------------------ | --------------------------------------------------------------- | --------------------------------------------------- |
39+
| C API | Stable | Raw interface | Shared object / DLL that contains the core implementation | All programming languages with dynamic load support |
40+
| C headers | Stable | Exposition-only | Exposition-only library using dynamic linking | C and C++ |
41+
| C++ headers | Experimental | Wrapper | Handles memory management and basic error handling | C++ |
42+
| Python library | Stable | Feature-rich layer | Library with useful functions, conversions and extensive checks | Python |
43+
44+
Note that the Python library in turn also follows the pattern of a feature-rich library that uses a
45+
module-internal wrapper layer core module, that wraps the exposition-only core module, that exposes
46+
the raw interface.
47+
48+
This can be visualized graphically as follows.
49+
50+
```{mermaid}
51+
:title: Full design
52+
53+
flowchart TD
54+
classDef user_node fill:#9f6,stroke:#333,stroke-width:2px
55+
classDef public_interface fill:#69f,stroke:#333,stroke-width:2px
56+
classDef experimental_interface fill:#99b,stroke:#333,stroke-width:2px
57+
classDef private_interface fill:#999,stroke:#333,stroke-width:2px
58+
classDef inclusion_method fill:#ddd,stroke:#fff,stroke-width:2px
59+
60+
subgraph User
61+
any_language_user(["Any language user"]):::user_node
62+
c_user(["C user"]):::user_node
63+
cpp_user(["C++ user"]):::user_node
64+
python_user(["Python user"]):::user_node
65+
end
66+
67+
dynamic_loading{ }:::inclusion_method
68+
c_includes{ }:::inclusion_method
69+
70+
subgraph Raw interface
71+
power_grid_model_c_dll("power_grid_model_c<br>(shared library)"):::public_interface
72+
end
73+
74+
subgraph Exposition
75+
power_grid_model_c("power_grid_model_c<br>(C library)"):::public_interface
76+
power_grid_core_python("power_grid_model._core<br>.power_grid_core.py<br>(exposition-only<br>Python module)"):::private_interface
77+
end
78+
79+
subgraph Wrapper
80+
power_grid_model_cpp("power_grid_model_cpp<br>(experimental,<br>C++ library)"):::experimental_interface
81+
power_grid_model_core_python("power_grid_model._core<br>(Python wrapper library)"):::private_interface
82+
end
83+
84+
subgraph Feature-rich library
85+
power_grid_model_python("power_grid_model<br>(Python library)"):::public_interface
86+
end
87+
88+
any_language_user --> dynamic_loading
89+
c_includes --> dynamic_loading
90+
dynamic_loading -->|dynamic loading| power_grid_model_c_dll
91+
c_user --> c_includes
92+
cpp_user --> c_includes
93+
c_includes -->|links +<br>includes| power_grid_model_c -->|dynamic linking| power_grid_model_c_dll
94+
cpp_user -->|experimental<br>links +<br>includes| power_grid_model_cpp -->|links +<br>includes| power_grid_model_c
95+
python_user -->|import| power_grid_model_python -->|internal import| power_grid_model_core_python -->|internal import| power_grid_core_python -->|"CDLL<br>(dynamic loading)"| power_grid_model_c_dll
96+
```
97+
98+
## Creating a custom library or interface
99+
100+
We seek to provide an optimal user experience, but with the sheer amount of programming languages and
101+
features, it would be impossible to provide a full feature-rich library for every single one. We,
102+
being a {{ "[community-driven]({}/GOVERNANCE.md)".format(pgm_project_contribution) }} project strongly in
103+
favor of modern software engineering practices, therefore encourage people to create their own
104+
libraries and interfaces to improve their own experience. There are several possible reasons a user
105+
may want to create their own library or interface, e.g.:
106+
107+
* Support for a new programming language
108+
* Extending library support for a specific programming language
109+
* A custom wrapper that provides extra features or useful commands for specific custom requirements
110+
111+
In all cases, it is recommended that the user determines their own desired
112+
[layer of abstraction](#layers-of-abstraction) and then creates internal wrappers for all
113+
lower-level ones, following the same pattern as the power-grid-model
114+
[uses internally](#existing-library-interfaces) for the custom interfaces.
115+
116+
### Hosting a custom library or interface
117+
118+
The Power Grid Model organization supports people creating and hosting custom libraries and
119+
interfaces. If you are doing so and are willing to notify us, please create an item on our
120+
[discussion board](https://github.com/orgs/PowerGridModel/discussions) on GitHub. The Power Grid
121+
Model organization will review your item and we may decide to mention your custom library on our
122+
project website and documentation.
123+
124+
### Contributing a custom library or interface
125+
126+
When a custom library or interface becomes mature enough and the circumstances allow making it
127+
publicly available, please consider contributing it to the Power Grid Model organization. If you are
128+
considering contributing your custom library or interface, please read and follow our
129+
{{ "[contributing guidelines]({}/CONTRIBUTING.md)".format(pgm_project_contribution) }} and open an
130+
item on our [discussion board](https://github.com/orgs/PowerGridModel/discussions) on GitHub. The
131+
Power Grid Model organization will review your item and contact you accordingly.

docs/conf.py

+6
Original file line numberDiff line numberDiff line change
@@ -25,9 +25,13 @@
2525
commit_version = git.Repo(search_parent_directories=True).head.object.hexsha
2626
link_head_gh_blob = link_head_gh + "blob/" + commit_version
2727
link_head_gh_tree = link_head_gh + "tree/" + commit_version
28+
pgm_project_root = ""
29+
pgm_project_contribution = pgm_project_root + "/contribution"
2830
else:
2931
link_head_gh_blob = ""
3032
link_head_gh_tree = ""
33+
pgm_project_root = "https://github.com/PowerGridModel/.github/blob/main"
34+
pgm_project_contribution = pgm_project_root
3135

3236

3337
# -- General configuration ---------------------------------------------------
@@ -78,6 +82,8 @@
7882
myst_substitutions = {
7983
"gh_link_head_blob": link_head_gh_blob,
8084
"gh_link_head_tree": link_head_gh_tree,
85+
"pgm_project_root": pgm_project_root,
86+
"pgm_project_contribution": pgm_project_contribution,
8187
}
8288

8389

docs/index.md

+1
Original file line numberDiff line numberDiff line change
@@ -108,6 +108,7 @@ algorithms/lu-solver
108108
advanced_documentation/native-data-interface
109109
advanced_documentation/build-guide
110110
advanced_documentation/c-api
111+
advanced_documentation/high-level-design
111112
advanced_documentation/core-design
112113
advanced_documentation/python-wrapper-design
113114
```

0 commit comments

Comments
 (0)