Skip to content

Commit

Permalink
forward compatibility with grid2op 1.10.0 by improving copy method
Browse files Browse the repository at this point in the history
  • Loading branch information
BDonnot committed Mar 14, 2024
1 parent a50fdc3 commit 8964709
Show file tree
Hide file tree
Showing 14 changed files with 329 additions and 472 deletions.
21 changes: 14 additions & 7 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -268,11 +268,17 @@ jobs:
size: medium # ("medium" "large" "xlarge" "2xlarge")
steps:
- checkout
# - run:
# name: "Install Python"
# command: choco install python --version=3.9 # use python 3.9 for windows test
- run: py -m pip install virtualenv
- run: py -m virtualenv venv_test
- run: choco install python --version=3.10 --force -y
- run: C:\Python310\python --version
- run: C:\Python310\python -m pip install --upgrade pip setuptools wheel
- run: C:\Python310\python -m pip install virtualenv
- run: C:\Python310\python -m virtualenv venv_test
- run:
name: "Chekc python / pip version in venv"
command: |
.\venv_test\Scripts\activate
python --version
pip --version
- run:
name: "Install grid2op from source"
command: |
Expand All @@ -286,15 +292,16 @@ jobs:
pip install -U pybind11
git submodule init
git submodule update
py setup.py build
py -m pip install -e .[test]
python setup.py build
python -m pip install -e .[test]
- run:
name: "make tests"
command: |
.\venv_test\Scripts\activate
cd lightsim2grid\tests
python -m unittest discover -v
workflows:
version: 2.1
compile:
Expand Down
236 changes: 189 additions & 47 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ on:

jobs:
manylinux_build:
# build wheels for some linux
name: Build linux ${{ matrix.python.name }} wheel
runs-on: ubuntu-latest
container: quay.io/pypa/manylinux2014_x86_64
Expand Down Expand Up @@ -40,11 +41,16 @@ jobs:
abi: cp311,
version: '3.11',
}
- {
name: cp312,
abi: cp312,
version: '3.12',
}

steps:

- name: Checkout sources
uses: actions/checkout@v1
uses: actions/checkout@v3
with:
submodules: true

Expand All @@ -65,45 +71,60 @@ jobs:
python3 setup.py bdist_wheel
auditwheel repair dist/*.whl
- name: Build source archive
if: matrix.python.name == 'cp311'
run: python setup.py sdist

- name: Install wheel
run: pip3 install wheelhouse/*.whl --user

- name: Install GDB
run: yum install -y gdb
# - name: Install GDB
# run: yum install -y gdb

- name: Check package can be imported
run: |
# python3 -c "import lightsim2grid"
# python3 -c "from lightsim2grid import *"
# python3 -c "from lightsim2grid.newtonpf import newtonpf"
gdb -batch -ex r --args python3 -c "from lightsim2grid import *" -ex backtrace
python3 -c "import lightsim2grid"
python3 -c "from lightsim2grid import *"
python3 -c "from lightsim2grid.newtonpf import newtonpf"
- name: Check LightSimBackend can be imported
- name: Fix urllib3 (python 3.7)
if: matrix.python.name == 'cp37'
run:
pip install urllib3==1.26.6
# otherwise urllib3 v2.0 only supports OpenSSL 1.1.1+, currently the 'ssl' module is compiled with 'OpenSSL 1.0.2k-fips 26 Jan 2017'

- name: Check LightSimBackend can be imported (install grid2op)
run: |
python3 -m pip install grid2op
python3 -c "from lightsim2grid import LightSimBackend"
python3 -c "from lightsim2grid import LightSimBackend; import grid2op; env = grid2op.make('l2rpn_case14_sandbox', test=True, backend=LightSimBackend())"
python3 -m pip freeze
- name: Check LightSimBackend can be imported 1
run:
python3 -v -c "from lightsim2grid import LightSimBackend"

- name: Check LightSimBackend can be imported 2
run:
python3 -v -c "from lightsim2grid import LightSimBackend; import grid2op; env = grid2op.make('l2rpn_case14_sandbox', test=True, backend=LightSimBackend())"

- name: Upload wheel
uses: actions/upload-artifact@v2
uses: actions/upload-artifact@v3
with:
name: lightsim2grid-wheel-linux-${{ matrix.python.name }}
path: wheelhouse/*.whl

macos_windows_build:
name: Build ${{ matrix.config.name }} ${{ matrix.python.name }} wheel
runs-on: ${{ matrix.config.os }}
- name: Upload source archive
uses: actions/upload-artifact@v3
if: matrix.python.name == 'cp311'
with:
name: lightsim2grid-sources
path: dist/*.tar.gz

windows_build:
# build wheels for windows
name: Build windows ${{ matrix.python.name }} wheel
runs-on: windows-2019
strategy:
matrix:
config:
- {
name: darwin,
os: macos-latest,
}
- {
name: windows,
os: windows-2019,
}
python:
- {
name: cp37,
Expand All @@ -125,33 +146,33 @@ jobs:
name: cp311,
version: '3.11',
}
- {
name: cp312,
version: '3.12',
}
env:
RUNNER_OS: windows-2019
PYTHON_VERSION: ${{ matrix.python.version }}

steps:

- name: Checkout sources
uses: actions/checkout@v1
uses: actions/checkout@v3
with:
submodules: true

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

- name: Install Python dependencies
run: |
python -m pip install --upgrade pip
python -m pip install --upgrade setuptools
python -m pip install -r requirements.txt
- name: Compile SuiteSparse make
if: matrix.config.name == 'darwin'
run: |
make
export __O3_OPTIM=1
python3 setup.py build
- name: Compile SuiteSparse cmake
if: matrix.config.name == 'windows'
run: |
cd build_cmake
python generate_c_files.py
Expand All @@ -168,10 +189,6 @@ jobs:
- name: Build wheel
run: python setup.py bdist_wheel

- name: Build source archive
if: matrix.config.name == 'darwin' && matrix.python.name == 'cp39'
run: python setup.py sdist

- name: Install wheel
shell: bash
run: python -m pip install dist/*.whl --user
Expand All @@ -189,33 +206,158 @@ jobs:
python -c "from lightsim2grid import LightSimBackend; import grid2op; env = grid2op.make('l2rpn_case14_sandbox', test=True, backend=LightSimBackend())"
- name: Upload wheel
uses: actions/upload-artifact@v2
uses: actions/upload-artifact@v3
with:
name: lightsim2grid-wheel-${{ matrix.config.name }}-${{ matrix.python.name }}
path: dist/*.whl

- name: Upload source archive
uses: actions/upload-artifact@v2
if: matrix.config.name == 'darwin' && matrix.python.name == 'cp39'
macos_build_37:
# build wheel for python 3.7 for macos
name: Build macos ${{ matrix.python.name }} wheel
runs-on: macos-latest
strategy:
matrix:
python:
- {
name: cp37,
version: '3.7',
}
steps:
- name: Checkout sources
uses: actions/checkout@v3
with:
name: lightsim2grid-sources
path: dist/*.tar.gz
submodules: true

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

- name: Install Python dependencies
run: |
python -m pip install --upgrade pip
python -m pip install -r requirements.txt
- name: Compile SuiteSparse make
run: |
make
export __O3_OPTIM=1
python3 setup.py build
- name: Build wheel
run: python setup.py bdist_wheel

- name: Install wheel
shell: bash
run: python -m pip install dist/*.whl --user

- name: Check package can be imported
run: |
python -c "import lightsim2grid"
python -c "from lightsim2grid import *"
python -c "from lightsim2grid.newtonpf import newtonpf"
- name: Check LightSimBackend can be imported
run: |
python -m pip install grid2op
python -c "from lightsim2grid import LightSimBackend"
python -c "from lightsim2grid import LightSimBackend; import grid2op; env = grid2op.make('l2rpn_case14_sandbox', test=True, backend=LightSimBackend())"
- name: Upload wheel
uses: actions/upload-artifact@v3
with:
name: lightsim2grid-wheel-darwin-${{ matrix.python.name }}
path: dist/*.whl

macos_build_38_:
# build wheel for python 3.8 and above for macos
name: Build darwin ${{ matrix.python.name }} wheel
runs-on: macos-latest
strategy:
matrix:
python:
- {
name: cp38,
version: '3.8',
}
- {
name: cp39,
version: '3.9',
}
- {
name: cp310,
version: '3.10',
}
- {
name: cp311,
version: '3.11',
}
- {
name: cp312,
version: '3.12',
}
env:
RUNNER_OS: macos-latest
PYTHON_VERSION: ${{ matrix.python.version }}

steps:

- name: Checkout sources
uses: actions/checkout@v3
with:
submodules: true

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

- name: Set Additional Envs
shell: bash
run: |
echo "PYTHON_SUBVERSION=$(echo $PYTHON_VERSION | cut -c 3-)" >> $GITHUB_ENV
echo "DEPLOY=$( [[ $GITHUB_EVENT_NAME == 'push' && $GITHUB_REF == 'refs/tags'* ]] && echo 'True' || echo 'False' )" >> $GITHUB_ENV
- name: Compile with cibuildwheel
uses: pypa/[email protected]
env:
CIBW_BUILD: "cp3${{env.PYTHON_SUBVERSION}}-*" # see https://github.com/cvxpy/cvxpy/blob/master/.github/workflows/build.yml
CIBW_ARCHS_LINUX: auto aarch64 # not used I believe
CIBW_ARCHS_MACOS: x86_64 arm64
CIBW_ENVIRONMENT: __O3_OPTIM=1
CIBW_BEFORE_ALL: python -m pip install --upgrade setuptools wheel pybind11
CIBW_BEFORE_BUILD: make clean && make CC=clang CXX=clang++ # and not CIBW_BEFORE_ALL !
CIBW_TEST_REQUIRES: grid2op pandapower
CIBW_TEST_SKIP: "cp312-* *-macosx_arm64" # to silence warning "While arm64 wheels can be built on x86_64, they cannot be tested."
CIBW_TEST_COMMAND: >
python -c "import lightsim2grid" &&
python -c "from lightsim2grid import *" &&
python -c "from lightsim2grid.newtonpf import newtonpf" &&
python -c "from lightsim2grid.solver import KLUSolver" &&
python -c "from lightsim2grid import LightSimBackend" &&
python -c "from lightsim2grid import LightSimBackend; import grid2op; env = grid2op.make('l2rpn_case14_sandbox', test=True, backend=LightSimBackend())"
- name: Upload wheel
uses: actions/upload-artifact@v3
with:
name: wheels-darwin-${{ matrix.python.name }}
path: ./wheelhouse/*.whl

package:
name: Package wheels
runs-on: ubuntu-latest
needs: [manylinux_build, macos_windows_build]
needs: [manylinux_build, windows_build, macos_build_37, macos_build_38_]

steps:
- name: Download wheels
uses: actions/download-artifact@v2
uses: actions/download-artifact@v3
with:
path: download

- name: Upload wheels
uses: actions/upload-artifact@v2
uses: actions/upload-artifact@v3
with:
name: lightsim2grid-wheels
path: |
download/**/*.whl
download/**/*.tar.gz
download/**/*.tar.gz
11 changes: 9 additions & 2 deletions .readthedocs.yml
Original file line number Diff line number Diff line change
@@ -1,13 +1,20 @@
version: 2
version: "2"

submodules:
include:
- SuiteSparse
- eigen
recursive: true

build:
os: "ubuntu-22.04"
tools:
python: "3.10"

sphinx:
configuration: docs/conf.py

python:
version: 3.8
install:
- method: pip
path: .
Expand Down
Loading

0 comments on commit 8964709

Please sign in to comment.