Skip to content

Commit 34906da

Browse files
github-actions[bot]olafmersmann
authored andcommitted
feat: Make YAML serialization deterministic
pydantic-yaml serializes model fields via model_dump_json() but set iteration is order depends on hash randomization, which is randomized per interpreter process, so `to_yaml_str()` produced a different ordering of these fields on every run even when the underlying data was unchanged. Add a `_CanonicalMixin` used by new `CanonicalModel`/`CanonicalRootModel` base classes in schema.py. Each defines a single model_serializer(mode="wrap") that inspects a model's actual field values at dump time and sorts any that are a `set` into a list.
1 parent 081c051 commit 34906da

4 files changed

Lines changed: 146 additions & 80 deletions

File tree

‎docs/index.html‎

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -890,11 +890,11 @@ <h2>OPL &ndash; Optimisation problem library</h2>
890890
<td></td>
891891
<td>>=1</td>
892892
<td></td>
893-
<td>MA-BBOB (IOHexperimenter) | IOHexperimenter</td>
893+
<td>IOHexperimenter | MA-BBOB (IOHexperimenter)</td>
894894
<td>C++/Python</td>
895895
<td></td>
896-
<td><a href="https://github.com/IOHprofiler/IOHexperimenter/blob/master/example/Competitions/MA-BBOB/Example_MABBOB.ipynb">https://github.com/IOHprofiler/IOHexperimenter/blob/master/example/Competitions/MA-BBOB/Example_MABBOB.ipynb</a> | <a href="https://github.com/IOHprofiler/IOHexperimenter">https://github.com/IOHprofiler/IOHexperimenter</a></td>
897-
<td>Example notebook for MA-BBOB in IOHexperimenter | IOHprofiler experimenter framework</td>
896+
<td><a href="https://github.com/IOHprofiler/IOHexperimenter">https://github.com/IOHprofiler/IOHexperimenter</a> | <a href="https://github.com/IOHprofiler/IOHexperimenter/blob/master/example/Competitions/MA-BBOB/Example_MABBOB.ipynb">https://github.com/IOHprofiler/IOHexperimenter/blob/master/example/Competitions/MA-BBOB/Example_MABBOB.ipynb</a></td>
897+
<td>IOHprofiler experimenter framework | Example notebook for MA-BBOB in IOHexperimenter</td>
898898
<td></td>
899899
<td></td>
900900
<td></td>
@@ -1710,11 +1710,11 @@ <h2>OPL &ndash; Optimisation problem library</h2>
17101710
<td></td>
17111711
<td>>=1</td>
17121712
<td></td>
1713-
<td>CEC2013 reference code | IOHexperimenter</td>
1713+
<td>IOHexperimenter | CEC2013 reference code</td>
17141714
<td>C++/Python</td>
17151715
<td></td>
1716-
<td><a href="https://github.com/P-N-Suganthan/CEC2013">https://github.com/P-N-Suganthan/CEC2013</a> | <a href="https://github.com/IOHprofiler/IOHexperimenter">https://github.com/IOHprofiler/IOHexperimenter</a></td>
1717-
<td>Suganthan's reference implementation | IOHprofiler experimenter framework</td>
1716+
<td><a href="https://github.com/IOHprofiler/IOHexperimenter">https://github.com/IOHprofiler/IOHexperimenter</a> | <a href="https://github.com/P-N-Suganthan/CEC2013">https://github.com/P-N-Suganthan/CEC2013</a></td>
1717+
<td>IOHprofiler experimenter framework | Suganthan's reference implementation</td>
17181718
<td></td>
17191719
<td></td>
17201720
<td></td>
@@ -1876,7 +1876,7 @@ <h2>OPL &ndash; Optimisation problem library</h2>
18761876
<td></td>
18771877
<td>CFD test problem suite</td>
18781878
<td></td>
1879-
<td>{'30s', '15m'}</td>
1879+
<td>{'15m', '30s'}</td>
18801880
<td><a href="https://bitbucket.org/arahat/cfd-test-problem-suite">https://bitbucket.org/arahat/cfd-test-problem-suite</a></td>
18811881
<td>Expensive real-world CFD-based test problems</td>
18821882
<td></td>
@@ -2696,7 +2696,7 @@ <h2>OPL &ndash; Optimisation problem library</h2>
26962696
<td></td>
26972697
<td>MECHBench</td>
26982698
<td>Python</td>
2699-
<td>{'7 minutes', '1 minute'}</td>
2699+
<td>{'1 minute', '7 minutes'}</td>
27002700
<td><a href="https://github.com/BayesOptApp/MECHBench">https://github.com/BayesOptApp/MECHBench</a></td>
27012701
<td>Structural mechanics design optimization benchmark</td>
27022702
<td></td>

‎docs/problems.html‎

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -864,11 +864,11 @@
864864
<td></td>
865865
<td>>=1</td>
866866
<td></td>
867-
<td>MA-BBOB (IOHexperimenter) | IOHexperimenter</td>
867+
<td>IOHexperimenter | MA-BBOB (IOHexperimenter)</td>
868868
<td>C++/Python</td>
869869
<td></td>
870-
<td><a href="https://github.com/IOHprofiler/IOHexperimenter/blob/master/example/Competitions/MA-BBOB/Example_MABBOB.ipynb">https://github.com/IOHprofiler/IOHexperimenter/blob/master/example/Competitions/MA-BBOB/Example_MABBOB.ipynb</a> | <a href="https://github.com/IOHprofiler/IOHexperimenter">https://github.com/IOHprofiler/IOHexperimenter</a></td>
871-
<td>Example notebook for MA-BBOB in IOHexperimenter | IOHprofiler experimenter framework</td>
870+
<td><a href="https://github.com/IOHprofiler/IOHexperimenter">https://github.com/IOHprofiler/IOHexperimenter</a> | <a href="https://github.com/IOHprofiler/IOHexperimenter/blob/master/example/Competitions/MA-BBOB/Example_MABBOB.ipynb">https://github.com/IOHprofiler/IOHexperimenter/blob/master/example/Competitions/MA-BBOB/Example_MABBOB.ipynb</a></td>
871+
<td>IOHprofiler experimenter framework | Example notebook for MA-BBOB in IOHexperimenter</td>
872872
<td></td>
873873
<td></td>
874874
<td></td>
@@ -1684,11 +1684,11 @@
16841684
<td></td>
16851685
<td>>=1</td>
16861686
<td></td>
1687-
<td>CEC2013 reference code | IOHexperimenter</td>
1687+
<td>IOHexperimenter | CEC2013 reference code</td>
16881688
<td>C++/Python</td>
16891689
<td></td>
1690-
<td><a href="https://github.com/P-N-Suganthan/CEC2013">https://github.com/P-N-Suganthan/CEC2013</a> | <a href="https://github.com/IOHprofiler/IOHexperimenter">https://github.com/IOHprofiler/IOHexperimenter</a></td>
1691-
<td>Suganthan's reference implementation | IOHprofiler experimenter framework</td>
1690+
<td><a href="https://github.com/IOHprofiler/IOHexperimenter">https://github.com/IOHprofiler/IOHexperimenter</a> | <a href="https://github.com/P-N-Suganthan/CEC2013">https://github.com/P-N-Suganthan/CEC2013</a></td>
1691+
<td>IOHprofiler experimenter framework | Suganthan's reference implementation</td>
16921692
<td></td>
16931693
<td></td>
16941694
<td></td>
@@ -1850,7 +1850,7 @@
18501850
<td></td>
18511851
<td>CFD test problem suite</td>
18521852
<td></td>
1853-
<td>{'30s', '15m'}</td>
1853+
<td>{'15m', '30s'}</td>
18541854
<td><a href="https://bitbucket.org/arahat/cfd-test-problem-suite">https://bitbucket.org/arahat/cfd-test-problem-suite</a></td>
18551855
<td>Expensive real-world CFD-based test problems</td>
18561856
<td></td>
@@ -2670,7 +2670,7 @@
26702670
<td></td>
26712671
<td>MECHBench</td>
26722672
<td>Python</td>
2673-
<td>{'7 minutes', '1 minute'}</td>
2673+
<td>{'1 minute', '7 minutes'}</td>
26742674
<td><a href="https://github.com/BayesOptApp/MECHBench">https://github.com/BayesOptApp/MECHBench</a></td>
26752675
<td>Structural mechanics design optimization benchmark</td>
26762676
<td></td>

0 commit comments

Comments
 (0)