|
| 1 | +name: CI |
| 2 | + |
| 3 | +on: |
| 4 | + push: |
| 5 | + branches: |
| 6 | + - main |
| 7 | + pull_request: |
| 8 | + branches: |
| 9 | + - main |
| 10 | + schedule: |
| 11 | + - cron: "9 16 * * 1" |
| 12 | + |
| 13 | +jobs: |
| 14 | + build: |
| 15 | + strategy: |
| 16 | + fail-fast: false |
| 17 | + matrix: |
| 18 | + cfg: |
| 19 | + - conda-env: unix |
| 20 | + python-version: "3.12" |
| 21 | + julia-version: "1.10" |
| 22 | + label: conda |
| 23 | + runs-on: ubuntu-latest |
| 24 | + shell: 'bash -l {0}' |
| 25 | + |
| 26 | + - conda-env: null |
| 27 | + python-version: "3.12" |
| 28 | + julia-version: "1.10" |
| 29 | + label: installer |
| 30 | + runs-on: ubuntu-latest |
| 31 | + shell: 'bash -e {0}' |
| 32 | + |
| 33 | + - conda-env: unix |
| 34 | + python-version: "3.12" |
| 35 | + julia-version: "1.10" |
| 36 | + label: conda |
| 37 | + runs-on: macos-13 |
| 38 | + shell: 'bash -l {0}' |
| 39 | + |
| 40 | + - conda-env: null |
| 41 | + python-version: "3.12" |
| 42 | + julia-version: "1.10" |
| 43 | + label: installer |
| 44 | + runs-on: macos-13 |
| 45 | + # runs-on: macos-latest # fails b/c cbc can't compile on M1 (the GHA runners) |
| 46 | + shell: 'bash -e {0}' |
| 47 | + |
| 48 | + defaults: |
| 49 | + run: |
| 50 | + shell: ${{ matrix.cfg.shell }} |
| 51 | + |
| 52 | + name: "🐍 ${{ matrix.cfg.python-version }} • ${{ matrix.cfg.label }} • ${{ matrix.cfg.runs-on }}" |
| 53 | + runs-on: ${{ matrix.cfg.runs-on }} |
| 54 | + |
| 55 | + steps: |
| 56 | + - uses: actions/checkout@v4 |
| 57 | + with: |
| 58 | + fetch-depth: 0 |
| 59 | + |
| 60 | + - name: Install Conda Python ${{ matrix.cfg.python-version }} and power software |
| 61 | + if: matrix.cfg.label == 'conda' |
| 62 | + uses: conda-incubator/setup-miniconda@v3 |
| 63 | + with: |
| 64 | + activate-environment: test |
| 65 | + environment-file: devtools/conda-envs/${{ matrix.cfg.conda-env }}.yaml |
| 66 | + python-version: ${{ matrix.cfg.python-version }} |
| 67 | + auto-activate-base: false |
| 68 | + show-channel-urls: true |
| 69 | + add-pip-as-python-dependency: true |
| 70 | + conda-remove-defaults: true |
| 71 | + |
| 72 | + - name: Install Python ${{ matrix.cfg.python-version }} |
| 73 | + if: matrix.cfg.label == 'installer' |
| 74 | + uses: actions/setup-python@v4 |
| 75 | + with: |
| 76 | + python-version: ${{ matrix.cfg.python-version }} |
| 77 | + |
| 78 | + - name: Install Python power software |
| 79 | + if: matrix.cfg.label == 'installer' |
| 80 | + run: | |
| 81 | + uname -p |
| 82 | + which python pip |
| 83 | + python --version |
| 84 | + python -m pip install numpy pandas scipy pytest grid2op julia "pandapower==2.14.11" |
| 85 | +
|
| 86 | + - name: Install Julia ${{ matrix.cfg.julia-version }} |
| 87 | + if: matrix.cfg.label == 'installer' |
| 88 | + uses: julia-actions/setup-julia@v2 |
| 89 | + with: |
| 90 | + version: ${{ matrix.cfg.julia-version }} |
| 91 | + |
| 92 | + - name: Cache Julia |
| 93 | + if: matrix.cfg.label == 'installer' |
| 94 | + uses: julia-actions/cache@v2 |
| 95 | + with: |
| 96 | + cache-name: ${{ matrix.cfg-runs-on }}-test-${{ matrix.cfg.julia-version }}-${{ matrix.cfg.python-version }} |
| 97 | + cache-packages: false |
| 98 | + |
| 99 | + - name: Install Julia power software |
| 100 | + run: | |
| 101 | + julia -e ' |
| 102 | + using Pkg |
| 103 | + Pkg.add([ |
| 104 | + Pkg.PackageSpec(;name="Ipopt"), |
| 105 | + Pkg.PackageSpec(;name="PowerModels", version="0.21.3"), |
| 106 | + Pkg.PackageSpec(;name="PyCall"), |
| 107 | + Pkg.PackageSpec(;url="https://github.com/loriab/PandaModels.jl", rev="update_pm") |
| 108 | + ])' |
| 109 | +
|
| 110 | + - name: Install PandaModelsBackend |
| 111 | + run: | |
| 112 | + python -m pip install -e .[tests] |
| 113 | +
|
| 114 | + - name: Environment information |
| 115 | + run: | |
| 116 | + python -m pip list |
| 117 | + python -m pip list | grep -e power -e grid -e panda |
| 118 | + which python python-jl julia |
| 119 | + python --version |
| 120 | + python-jl --version |
| 121 | + julia --version |
| 122 | + julia -e 'using Pkg; Pkg.status(); Pkg.status(outdated=true)' |
| 123 | +
|
| 124 | + - name: Test PowerModels in Julia |
| 125 | + # if: false |
| 126 | + run: | |
| 127 | + julia -e 'using PyCall; math = pyimport("math"); print(math.sin(math.pi/4))' |
| 128 | + julia -e 'using Pkg; Pkg.test("PowerModels")' |
| 129 | + # PM testing above is clean but takes 6m, so optionally toggle off |
| 130 | +
|
| 131 | + - name: Test PandaModels in Julia |
| 132 | + run: | |
| 133 | + julia -e 'using Pkg; Pkg.add(Pkg.PackageSpec(;name="Ipopt", version="0.9"))' |
| 134 | + julia -e 'using Pkg; Pkg.status(); Pkg.status(outdated=true)' |
| 135 | + julia -e 'using PandaModels' |
| 136 | + julia -e 'using Pkg; Pkg.test("PandaModels")' |
| 137 | + # PdM testing above has a couple failures b/c Ipopt=1 unless downgrade (taking PM with it) |
| 138 | + # shortcut this step by commenting out the Pkg.test above |
| 139 | +
|
| 140 | + - name: Special setup Mac |
| 141 | + if: matrix.cfg.label == 'installer' && runner.os == 'macOS' |
| 142 | + run: | |
| 143 | + # warning: hard coded path |
| 144 | + julia -e 'ENV["PYTHON"]="/Users/runner/hostedtoolcache/Python/3.12.9/x64/bin/python"; using Pkg; Pkg.build("PyCall")' |
| 145 | +
|
| 146 | + - name: Special setup download delay |
| 147 | + if: runner.os == 'macOS' |
| 148 | + # file download in next section is flaky, esp. for Mac. use `sed -i "s;;;g"` for non-Mac |
| 149 | + run: | |
| 150 | + sed -E -i.bak "s;nb_retry=10;nb_retry=50;g" $(dirname $(which python))/../lib/python${{ matrix.cfg.python-version }}/site-packages/grid2op/MakeEnv/Make.py |
| 151 | + sed -E -i.bak "s;time.sleep(1);time.sleep(3);g" $(dirname $(which python))/../lib/python${{ matrix.cfg.python-version }}/site-packages/grid2op/MakeEnv/Make.py |
| 152 | +
|
| 153 | + - name: Test PowerModels in PandaPower |
| 154 | + run: | |
| 155 | + which python python-jl |
| 156 | + python-jl -m pytest -v $(dirname $(which python))/../lib/python${{ matrix.cfg.python-version }}/site-packages/pandapower/test/opf/test_pandamodels_runpm.py |
| 157 | + # use python-jl instead of python above if get a static libpython error |
| 158 | + # loc is simply $CONDA_PREFIX but the setup-python counterpart env.pythonLocation seems broken |
| 159 | + # PdP testing above has a couple failures b/c Ipopt=1 unless downgrade (taking PM with it) |
| 160 | +
|
| 161 | + - name: Test PandaModelsBackend |
| 162 | + # if: false # for now since there's some issues |
| 163 | + run: | |
| 164 | + cd tests |
| 165 | + which python python-jl |
| 166 | + python-jl test_basic_usage.py |
| 167 | + # python test_backend_api.py |
0 commit comments