Repository navigation
154 lines (136 loc) · 5.77 KB
/
Copy pathcreate.yml
File metadata and controls
154 lines (136 loc) · 5.77 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
name: Create missing datasets
on: workflow_dispatch
jobs:
detect:
runs-on: ubuntu-latest
outputs:
matrix: ${{ steps.set-matrix.outputs.missing_versions }}
steps:
- name: Checkout data repo
uses: actions/checkout@v5
- name: Checkout tenpy
uses: actions/checkout@v5
with:
fetch-depth: 0 # required to get all tags
repository: tenpy/tenpy
path: tenpy_repo
- name: List tenpy tags
working-directory: tenpy_repo
run: |
bare_versions=""
for version in $(git tag); do
[[ $version != v* ]] && echo "Skipping non-version tag: $version" && continue
[[ $version =~ v0.(1|2|3).0 ]] && echo "Skipping $version (too old, no export code)" && continue
echo "Adding: $version"
bare_versions="$bare_versions ${version#v}"
done
export_cmd="BARE_VERSIONS=${bare_versions# }"
echo
echo $export_cmd
echo $export_cmd >> $GITHUB_ENV
- id: set-matrix
name: Check for missing I/O datasets
run: |
missing_versions=""
for version in $BARE_VERSIONS; do
echo "Checking: $version"
pkl_file="data/exported_from_tenpy_$version.pkl"
hdf5_file="data/exported_from_tenpy_$version.hdf5"
if [ ! -f $pkl_file ] && [ -f tenpy_repo/tests/export_import_test/test_pickle.py ]; then
echo " $pkl_file missing"
missing_versions="$missing_versions $version"
elif [ ! -f $hdf5_file ] && [ -f tenpy_repo/tests/export_import_test/test_hdf5.py ]; then
echo " $hdf5_file missing"
missing_versions="$missing_versions $version"
fi
done
missing_versions=${missing_versions# }
export_cmd="missing_versions=[\"${missing_versions// /\", \"}\"]"
echo
echo $export_cmd
echo $export_cmd >> $GITHUB_OUTPUT
create:
needs: [detect]
runs-on: ubuntu-latest
if: ${{ needs.detect.outputs.matrix != '[""]' }}
defaults:
run:
shell: bash -el {0}
strategy:
fail-fast: false
matrix:
version: ${{ fromJson(needs.detect.outputs.matrix) }}
steps:
- name: Checkout data repo
uses: actions/checkout@v5
- name: Checkout tenpy
uses: actions/checkout@v5
with:
ref: v${{ matrix.version }}
repository: tenpy/tenpy
path: tenpy_repo
- name: Remove unused pylab imports
if: matrix.version == '0.4.0'
# v0.4.0 imports pylab but does not use it.
# rather than figuring out how to install it, we just remove the unused import statement
# also remove bugged lines from the __main__ block of test_pickle.py
run: |
sed -i '/import pylab as pl/d' tenpy_repo/tenpy/algorithms/tdvp.py
sed -i '/import pylab as pl/d' tenpy_repo/tests/tdvp_numpy.py
- name: Fix export_import script
if: matrix.version == '0.4.0' || matrix.version == '0.4.1' || matrix.version == '0.5.0'
# there are two lines in the __main__ block that seem outdated and need to be removed
run: |
sed -i '/for f, fn in test_data_import():/d' tenpy_repo/tests/export_import_test/test_pickle.py
sed -i '/f(fn)/d' tenpy_repo/tests/export_import_test/test_pickle.py
- name: Set up conda
uses: conda-incubator/setup-miniconda@v3
with:
auto-update-conda: true
channels: conda-forge,defaults
channel-priority: true
- name: Install dependencies
# note: always pin specific versions, to future proof the environment!
run: |
if [[ ${{ matrix.version }} =~ 0.(4|5|6|7).[0-9] ]]; then
conda install -y python==3.9 numpy==1.19.2 scipy==1.5.2
elif [[ ${{ matrix.version }} =~ 0.(8|9|10|11|99).[0-9] ]] || [[ ${{ matrix.version }} =~ 1.0.[0-2] ]]; then
conda install -y python==3.10 numpy==1.26.4 scipy==1.10.1
else
conda install -y python==3.13 numpy==2.3.2 scipy==1.16.1
fi
conda install pytest h5py
- name: Generate datasets
run: |
export PYTHONPATH="$PYTHONPATH:${{ github.workspace }}/tenpy_repo"
if [ -f tenpy_repo/tests/export_import_test/test_hdf5.py ]; then
python tenpy_repo/tests/export_import_test/test_hdf5.py
fi
if [ -f tenpy_repo/tests/export_import_test/test_pickle.py ]; then
python tenpy_repo/tests/export_import_test/test_pickle.py
fi
if [ ! -d tenpy_repo/tests/export_import_test/data ]; then
echo "No data was generated." >> $GITHUB_STEP_SUMMARY
exit 1
fi
- name: Rename datasets
if: matrix.version == '0.4.0' || matrix.version == '0.4.1' || matrix.version == '0.5.0'
# the naming convention for the files changed in 0.6.0
run: |
mv tenpy_repo/tests/export_import_test/data/pickled_from_tenpy_v${{ matrix.version }}.pkl \
tenpy_repo/tests/export_import_test/data/exported_from_tenpy_v${{ matrix.version }}.pkl
- name: Move datasets
run: |
mv tenpy_repo/tests/export_import_test/data/* data
- name: Make PR
uses: peter-evans/create-pull-request@v8
with:
add-paths: data/*
commit-message: Add dataset for v${{ matrix.version }}
committer: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
title: Add dataset for v${{ matrix.version }}
body: This PR is automatically created by the create.yml workflow
reviewers: Jakob-Unfried,jhauschild
base: main
delete-branch: true
branch: create-v${{ matrix.version }}