The repository or configuration that created this release differ from a previous release. View details.
PandaModelsBackend
PandaModelsBackend provides a high-fidelity backend for Grid2op that uses PowerModels.jl. It achieves this using a pandapower interface that calls PandaModels.jl using PyCall to call Julia functions from Python.
Installation & Usage
pip install pandamodelsbackend
Refer to test_basic_usage for full independently runable example.
import grid2op
import pandapower as pp
from pandamodelsbackend import PandaModelsBackend
...
pp_net = pp.from_json(network_file) # Load PandaPower JSON
backend = PandaModelsBackend(pp_net)
env = grid2op.make(env_name, backend=backend)
Setting up the Development Environment
For newcomers to Julia, setting up a software stack with compatible Python and Julia is perhaps the trickiest part of using PandaModelsBackend.
Like Python, one can get Julia through an installer provided by the language developers or through a package manager, like conda.
Both are shown below and are demonstrated (sort-of, for installers) in GitHub Actions CI.
You'll need to separately install certain dependencies into Python and others into Julia. You never need to enter the Julia REPL.
If you get tangled up, the CI file is a good, proven route to consult.
Docs at pandapower may also be helpful.
There are a lot of acceptable ways to get Python+Julia working, so as long as python-jl pandamodelsbackend/tests/test_backend_api.py is working at the end, you're probably good to run grid2op.
Notes
- This software stack won't work on M1 Macs.
- Conda can be used for Python and Julia for Linux and Intel Macs. There isn't a
juliapackage for Silicon Macs, so you'll need to use the Julia installer (+ conda or installer Python). - A few problems and solutions have been collected here.
Using a Python virtual environment
-
Create a python virtual environment
python3 -m venv venv-
If you don't have virtual env installed refer to this link
-
To activate your environment:
source venv/bin/activate -
Install grid2op, pandapower
pip install grid2op pandapowerpip install julia
-
-
Julia Installation refer to this
-
set your path variable to find Julia e.g., on MAC
export PATH=/Applications/Julia-1.11.app/Contents/Resources/julia/bin:$PATH -
Add PowerModels, PandaModels Packages in Julia Run Juila on command prompt. Access the package manager in julia by typing ]. Now install the packages: add Ipopt PowerModels.
-
Build PyCall: The library PyCall allows to use Python from inside julia. By default, PyCall uses the Conda.jl package to install a Miniconda distribution private to Julia. To use an already installed Python distribution (e.g. Anaconda), set the PYTHON environment variable inside the Julia prompt.
Find path to your python in venv:
which pythone.g., - /bin/pythonOn MacOS:
ENV["PYTHON"]="<your python path>"
Access the package manager again in julia by typing ]. Now install the packages:
add PyCall. To pass the python environment variable, running build PyCall inside the julia package manager may be necessary. -
Using Conda
A Linux install script is provided at linux_conda_install.sh using Conda for Python and Julia dependencies. A snapshot (not necessarily latest) is shown below.
- copy a conda env spec file like unix.yaml. Customize python version, environment name, etc.
Build
git clone https://github.com/MOSSLab-MIT/PandaModelsBackend.git
cd PandaModelsBackend
python3 -m build
pip install -e .
Test
cd pandamodelsbackend/tests
python test_backend_api.py
# depending on installation, `python-jl` may be needed instead of `python` above
Release Procedure
- On a local clone on branch
main, update the CHANGELOG with PRs, the new version number, and the release date. Commit it. - Make an annotated tag for the new version. Push it along with any cleanup commits (e.g., changelog above). If you've forked the repo, "origin" will probably be "upstream". See
git remote -vfor names. You may need to disable direct push in Settings (Branches,main, Edit)
git tag -a v0.5.0 -m "v0.5.0"
git push --atomic origin main v0.5.0
- The CI workflow will take over publication to PyPI and making a GitHub release. You can edit the frontmatter for the latter through the GitHub web interface with any particular details (and perhaps a link to the CHANGELOG section).
Troubleshooting the Software Stack
-
Problem: Your Python interpreter "/path/to/miniconda/envs/rl2grid/bin/python" is statically linked to libpython. Currently, PyJulia does not fully support such Python interpreter.
Solution: Use
python-jlfrom conda (or Julia installation) instead ofpython. -
Problem: A pip installation involves compiling, and system compilers aren't working.
Solution:
conda install cxx-compiler -c conda-forgeand rerun pip. -
Problem: AttributeError in pandapower file d2Sbus_dV2.
Solution: This was fixed between v2.14.9 and master for csr_matrix?. Alternately, edit the
diagVto below:/path/to/site-packages/pandapower/pypower/d2Sbus_dV2.py: try: # added /path/to/site-packages/pandapower/pypower/d2Sbus_dV2.py: D = Ybus.H * diagV # indented /path/to/site-packages/pandapower/pypower/d2Sbus_dV2.py: except AttributeError: # added /path/to/site-packages/pandapower/pypower/d2Sbus_dV2.py: D = Ybus.getH() * diagV # added -
Problem: Package testing for PowerModels, PandaModels, or PandaPower shows a few (not all) failures.
Solution: For a clean test suite, PowerModels needs Ipopt>=1 and the others need Ipopt<1. To toggle, do something like the below. See CI for a known working testing sequence.
julia -e 'using Pkg; Pkg.add(Pkg.PackageSpec(;name="Ipopt", version="0.9")); using Ipopt'
Metadata
Release files for pandamodelsbackend 0.2.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Change of provenance
The repository or configuration that created these release files differ from that of a previous release.
We recommend inspecting the repository and configuration before proceeding. View details.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| pandamodelsbackend-0.2.0.tar.gz | 1.1 MB | With provenance | Details for pandamodelsbackend-0.2.0.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| pandamodelsbackend-0.2.0-py3-none-any.whl | Python 3 | none | any | Details for pandamodelsbackend-0.2.0-py3-none-any.whl |
Total release size: 1.1 MB
Release files / pandamodelsbackend-0.2.0.tar.gz
Change of provenance
This file belongs to a release with changed provenance: the repository or configuration that created the release files differ from that of a previous release.
We recommend inspecting the repository and configuration before proceeding. View details.
| Download URL | pandamodelsbackend-0.2.0.tar.gz |
|---|---|
| Size | 1.1 MB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
e507068856fd2c85a5fd3a2d57e5ee7c44a8ad170e65a50b05ed58ec071ada0b
|
|
BLAKE2b-256 checksum How to use checksums |
a2cecbebd27d3b27c27371c1b3487e89b3c0964214571a7a7484dc3a7fc2f6b4
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/6.1.0 CPython/3.12.9
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Apr 2, 2025.
Transparency logRelease files / pandamodelsbackend-0.2.0-py3-none-any.whl
Change of provenance
This file belongs to a release with changed provenance: the repository or configuration that created the release files differ from that of a previous release.
We recommend inspecting the repository and configuration before proceeding. View details.
| Download URL | pandamodelsbackend-0.2.0-py3-none-any.whl |
|---|---|
| Size | 22.3 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
68c5161075767c8e338f9ca6b48735be3b3eff1de2db351fbb71760cc7020c20
|
|
BLAKE2b-256 checksum How to use checksums |
091a4c3395c99fffbcae7f728a5f5b0763605afecabbed51c9de2d810d62b0d3
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/6.1.0 CPython/3.12.9
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Apr 2, 2025.
Transparency logSecurity for pandamodelsbackend 0.2.0
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
Change of provenance
The repository and configuration that created this release differ from a previous release.
While this could reflect a routine change by the project maintainers, it may also indicate that the release files have been compromised.
Repository
Attestation for pandamodelsbackend-0.2.0.tar.gz
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Apr 2, 2025.
Transparency logA note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.