Skip to content

Commit 768e309

Browse files
authored
Merge pull request #714 from BDonnot/bd_dev
Upgrade to recent version (numpy, scipy, pandapower and python)
2 parents 38dbea8 + d8004b0 commit 768e309

Some content is hidden

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

44 files changed

+1087
-684
lines changed

.circleci/config.yml

Lines changed: 67 additions & 58 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ version: 2.1
33
executors:
44
grid2op-executor:
55
docker:
6-
- image: python:3.10
6+
- image: python:3.12
77
working_directory: /Grid2Op
88

99
python37:
@@ -14,16 +14,19 @@ executors:
1414
- image: python:3.8
1515
python39:
1616
docker:
17-
- image: python:3.9
17+
- image: cimg/python:3.9
1818
python310:
1919
docker:
20-
- image: python:3.10
20+
- image: cimg/python:3.10
2121
python311:
2222
docker:
23-
- image: python:3.11
23+
- image: cimg/python:3.11
2424
python312:
2525
docker:
2626
- image: cimg/python:3.12
27+
python313:
28+
docker:
29+
- image: cimg/python:3.13
2730

2831
jobs:
2932
test:
@@ -203,10 +206,6 @@ jobs:
203206
resource_class: small
204207
steps:
205208
- checkout
206-
- run:
207-
command: |
208-
apt-get update
209-
apt-get install -y coinor-cbc
210209
- run: python -m pip install virtualenv
211210
- run: python -m virtualenv venv_test
212211
- run:
@@ -230,10 +229,6 @@ jobs:
230229
resource_class: small
231230
steps:
232231
- checkout
233-
- run:
234-
command: |
235-
apt-get update
236-
apt-get install -y coinor-cbc
237232
- run: python -m pip install virtualenv
238233
- run: python -m virtualenv venv_test
239234
- run:
@@ -253,24 +248,22 @@ jobs:
253248
python -m unittest grid2op/tests/test_basic_env_ls.py
254249
255250
test_chronix2grid:
256-
executor: python310 # needs to be 38: whl of lightsim were not released for 3.10 at the time
251+
executor: python310
257252
resource_class: small
258253
steps:
259254
- checkout
260-
- run:
261-
command: |
262-
apt-get update
263-
apt-get install -y coinor-cbc
255+
- run: sudo apt update
256+
- run: sudo apt install -y coinor-cbc
264257
- run: python -m pip install virtualenv
265258
- run: python -m virtualenv venv_test
266259
- run:
267260
command: |
268261
source venv_test/bin/activate
269-
python -m pip install -U pip setuptools wheel "numpy==1.26.4"
262+
python -m pip install -U pip setuptools wheel
270263
- run:
271264
command: |
272265
source venv_test/bin/activate
273-
python -m pip install -e .[chronix2grid] "linopy==0.3.8" "scs==3.2.4.post1" "ecos==2.0.13" "pillow==10.3.0" "numpy==1.26.4" "xarray==2024.3.0"
266+
python -m pip install -e .[chronix2grid]
274267
pip freeze
275268
- run:
276269
command: |
@@ -283,33 +276,52 @@ jobs:
283276
resource_class: small
284277
steps:
285278
- checkout
286-
- run:
287-
command: |
288-
apt-get update
289-
apt-get install -y coinor-cbc
290279
- run: python -m pip install virtualenv
291280
- run: python -m virtualenv venv_test
292281
- run:
293282
command: |
294283
export _GRID2OP_FORCE_TEST=1
295284
source venv_test/bin/activate
296-
python -m pip install -U pip setuptools wheel "numpy>=1.20,<1.21" "pandas<2.2" "scipy==1.10.1" "pillow<10.4.0" numba
285+
python -m pip install -U pip setuptools wheel numba
297286
python -m pip uninstall -y grid2op
298287
- run:
299-
command: | # issue with previous more simple install, so I fix some versions
288+
command: | # oldest numpy version (supported by python version) is also newest supported by grid2op
300289
source venv_test/bin/activate
301-
python -m pip install "numpy>=1.20,<1.21" "pandas<2.2" "scipy==1.10.1" numba .
290+
python -m pip install "numpy>=2,<2.1" .
302291
pip freeze
303292
- run:
304293
command: |
305294
source venv_test/bin/activate
306295
export _GRID2OP_FORCE_TEST=1
307296
cd /tmp
308297
grid2op.testinstall
298+
299+
install310:
300+
executor: python310
301+
resource_class: small
302+
steps:
303+
- checkout
304+
- run: python -m pip install virtualenv
305+
- run: python -m virtualenv venv_test
309306
- run:
310307
command: |
311308
source venv_test/bin/activate
312-
python -m pip install "numpy>=1.26,<1.27" "pandas<2.2" "scipy<1.12" numba "pillow<10.4.0"
309+
python -m pip install -U pip setuptools wheel
310+
- run:
311+
command: | # oldest numpy version >= 2 supported by python 3.10
312+
source venv_test/bin/activate
313+
python -m pip install -U "numpy>=2,<2.1" numba .
314+
pip freeze
315+
- run:
316+
command: |
317+
source venv_test/bin/activate
318+
export _GRID2OP_FORCE_TEST=1
319+
cd /tmp
320+
grid2op.testinstall
321+
- run:
322+
command: | # most recent numpy version
323+
source venv_test/bin/activate
324+
python -m pip install -U numpy numba .
313325
pip freeze
314326
- run:
315327
command: |
@@ -318,26 +330,21 @@ jobs:
318330
cd /tmp
319331
grid2op.testinstall
320332
321-
install310:
322-
executor: python310
333+
install311:
334+
executor: python311
323335
resource_class: small
324336
steps:
325337
- checkout
326-
- run:
327-
command: |
328-
apt-get update
329-
apt-get install -y coinor-cbc
330338
- run: python -m pip install virtualenv
331339
- run: python -m virtualenv venv_test
332340
- run:
333341
command: |
334342
source venv_test/bin/activate
335343
python -m pip install -U pip setuptools wheel
336-
python -m pip install -U numba
337344
- run:
338-
command: |
345+
command: | # oldest numpy version >= 2 supported by python 3.11
339346
source venv_test/bin/activate
340-
python -m pip install -U "numpy>=1.21,<1.22" "pandas<2.2" "scipy<1.12" numba .
347+
python -m pip install -U "numpy>=2,<2.1" numba .
341348
pip freeze
342349
- run:
343350
command: |
@@ -346,36 +353,31 @@ jobs:
346353
cd /tmp
347354
grid2op.testinstall
348355
- run:
349-
command: |
356+
command: | # most recent numpy version
350357
source venv_test/bin/activate
351-
python -m pip install -U "numpy>=1.26,<1.27" "pandas<2.2" "scipy<1.12" numba
358+
python -m pip install -U numpy numba .
352359
pip freeze
353360
- run:
354361
command: |
355362
source venv_test/bin/activate
356363
export _GRID2OP_FORCE_TEST=1
357364
cd /tmp
358365
grid2op.testinstall
359-
360-
install311:
361-
executor: python311
366+
install312:
367+
executor: python312
362368
resource_class: small
363369
steps:
364370
- checkout
365-
- run:
366-
command: |
367-
apt-get update
368-
apt-get install -y coinor-cbc
369371
- run: python -m pip install virtualenv
370372
- run: python -m virtualenv venv_test
371373
- run:
372374
command: |
373375
source venv_test/bin/activate
374376
python -m pip install -U pip setuptools wheel
375377
- run:
376-
command: |
378+
command: | # oldest numpy version >= 2 supported by python 3.12
377379
source venv_test/bin/activate
378-
python -m pip install -U "numpy>=1.23,<1.24" "pandas<2.2" "scipy<1.12" numba .
380+
python -m pip install -U "numpy>=2,<2.1" numba .
379381
pip freeze
380382
- run:
381383
command: |
@@ -384,36 +386,42 @@ jobs:
384386
cd /tmp
385387
grid2op.testinstall
386388
- run:
387-
command: |
389+
command: | # most recent numpy version
388390
source venv_test/bin/activate
389-
python -m pip install -U "numpy>=1.26,<1.27" "pandas<2.2" "scipy<1.12" numba
391+
python -m pip install -U numpy numba .
390392
pip freeze
391393
- run:
392394
command: |
393395
source venv_test/bin/activate
394396
export _GRID2OP_FORCE_TEST=1
395397
cd /tmp
396398
grid2op.testinstall
397-
install312:
398-
executor: python312
399+
install313:
400+
executor: python313
399401
resource_class: small
400402
steps:
401403
- checkout
402-
- run:
403-
command: |
404-
sudo apt-get update
405-
sudo apt-get install -y coinor-cbc
406404
- run: python -m pip install virtualenv
407405
- run: python -m virtualenv venv_test
408406
- run:
409407
command: |
410408
source venv_test/bin/activate
411409
python -m pip install -U pip setuptools wheel
412-
# python -m pip install -U numba # not on python 3.12 at the moment
413410
- run:
414-
command: |
411+
command: | # oldest numpy version >= 2 supported by python 3.13
412+
source venv_test/bin/activate
413+
python -m pip install -U "numpy>=2.1,<2.2" .
414+
pip freeze
415+
- run:
416+
command: |
417+
source venv_test/bin/activate
418+
export _GRID2OP_FORCE_TEST=1
419+
cd /tmp
420+
grid2op.testinstall
421+
- run:
422+
command: | # most recent numpy version
415423
source venv_test/bin/activate
416-
python -m pip install -U "numpy>=1.26,<1.27" "pandas<2.2" "scipy<1.12" .
424+
python -m pip install -U numpy .
417425
pip freeze
418426
- run:
419427
command: |
@@ -438,6 +446,7 @@ workflows:
438446
- install310
439447
- install311
440448
- install312
449+
- install313
441450

442451
# gather_test_report:
443452
# requires:

.github/workflows/main.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -118,7 +118,7 @@ jobs:
118118
}
119119
- {
120120
name: windows,
121-
os: windows-2019,
121+
os: windows-2022,
122122
}
123123
python:
124124
- {
@@ -208,7 +208,7 @@ jobs:
208208
}
209209
# - {
210210
# name: windows,
211-
# os: windows-2019,
211+
# os: windows-2022,
212212
# }
213213
- {
214214
name: ubuntu,

CHANGELOG.rst

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -105,10 +105,16 @@ Native multi agents support:
105105
- [BREAKING] the `info` returned argument of `env.step(...)` function
106106
does not have the unclear `is_redispatching_illegal` key. This key has been
107107
replaced (without any change to its signification) with `failed_redispatching`
108+
- [FIXED] issue 713
109+
- [FIXED] pandapower 3 compatibility
110+
- [ADDED] compatibility with numpy 2, scipy >= 1.14 and python 3.13
111+
- [ADDED] some examples showing how grid2op can be use to solve some specific
112+
kind of problem (related to N-1 safety and phase shift transformer).
108113
- [IMPROVED] clarity of the `failed_redispatching` key of the `info` returned value
109114
of the `env.step` function (previously called `is_redispatching_illegal` which
110115
was not clear)
111-
116+
- [IMPROVED] way to load back class stored in json format
117+
- [IMPROVED] the way the Observation class can be overriden
112118

113119
[1.11.0] - 2025-04-14
114120
-----------------------
Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
from encodings.punycode import T
2+
from grid2op.Agent import BaseAgent
3+
from grid2op.Action import ActionSpace
4+
from grid2op.Environment import BaseEnv
5+
# NB: this agent is, from grid2o point of view
6+
# "cheating" because it can access the env.backend._grid
7+
# attribute when acting (so it does access private information).
8+
# This is for a now a "hack" and will be better handled in
9+
# future grid2op versions.
10+
# This means that, for now, you cannot use properly with "simulate"
11+
# for example
12+
13+
# NB: as PST are not handled (yet, any contribution welcomed) in grid2op
14+
# this agent is for now limited to environment using pandapower backend.
15+
16+
17+
class AgentRandomPST(BaseAgent):
18+
def __init__(self,
19+
action_space: ActionSpace,
20+
env: BaseEnv):
21+
super().__init__(action_space)
22+
self._backend = env.backend._grid
23+
24+
def act(self, observation, reward, done = False):
25+
26+
# perform a "random" PST action
27+
which_trafo = self.space_prng.randint(self._backend._grid.trafo["tap_phase_shifter"].sum())
28+
trafo_pst_ids = self._backend._grid.trafo["tap_phase_shifter"].values.nonzero()[0]
29+
trafo_id = trafo_pst_ids[which_trafo]
30+
31+
which_tap = self.space_prng.choice([-2, -1, 0, 1, 2], size=1)[0]
32+
self._backend._grid.trafo.loc[trafo_id, "tap_pos"] = which_tap
33+
print(f"{trafo_id=}, {which_tap=}")
34+
# return the base grid2op action (do nothing in this case)
35+
return super().act(observation, reward, done)

0 commit comments

Comments
 (0)