Spaces:
Sleeping
Sleeping
MilesCranmer
commited on
Commit
•
314b695
1
Parent(s):
06d99a7
Create workflow to update the backend automatically
Browse files
.github/workflows/update_backend.yml
ADDED
@@ -0,0 +1,58 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
name: PySR backend update
|
2 |
+
on:
|
3 |
+
schedule:
|
4 |
+
- cron: '00 00 * * *'
|
5 |
+
workflow_dispatch:
|
6 |
+
jobs:
|
7 |
+
update_compat:
|
8 |
+
runs-on: ubuntu-latest
|
9 |
+
steps:
|
10 |
+
- uses: actions/checkout@v3
|
11 |
+
- uses: julia-actions/setup-julia@v1
|
12 |
+
- uses: julia-actions/cache@v1
|
13 |
+
- uses: actions/setup-python@v4
|
14 |
+
|
15 |
+
- name: "Install PySR"
|
16 |
+
run: |
|
17 |
+
python -m pip install --upgrade pip
|
18 |
+
pip install -r requirements.txt
|
19 |
+
python setup.py install
|
20 |
+
# Not needed:
|
21 |
+
# python -c 'import pysr; pysr.install()'
|
22 |
+
|
23 |
+
- name: "Get SymbolicRegression.jl latest version"
|
24 |
+
id: get-latest
|
25 |
+
run: |
|
26 |
+
cd $(mktemp -d)
|
27 |
+
git clone https://github.com/MilesCranmer/SymbolicRegression.jl
|
28 |
+
cd SymbolicRegression.jl
|
29 |
+
echo "version=$(git describe --tags --abbrev=0 | sed 's/^v//')" >> $GITHUB_OUTPUT
|
30 |
+
|
31 |
+
- name: "Get SymbolicRegression.jl version used in PySR"
|
32 |
+
id: get-current
|
33 |
+
run: |
|
34 |
+
echo "version=$(python -c 'import pysr; print(pysr.version.__symbolic_regression_jl_version__)' 2>/dev/null)" >> $GITHUB_OUTPUT
|
35 |
+
|
36 |
+
# If versions are different, we want to take our checked-out version,
|
37 |
+
# create a new branch called "update_compat_{...}", where the "..."
|
38 |
+
# is a timestamp. We then want to
|
39 |
+
# go to pysr/version.py, bump the patch version of PySR (__version__),
|
40 |
+
# set the version of __symbolic_regression_jl_version__ to the latest
|
41 |
+
# version of SymbolicRegression.jl, and then commit and push.
|
42 |
+
# Finally, we will open a PR from this branch to master.
|
43 |
+
- name: "Update versions"
|
44 |
+
if: ${{ steps.get-latest.outputs.version != steps.get-current.outputs.version }}
|
45 |
+
run: |
|
46 |
+
# Bump PySR patch number:
|
47 |
+
CURRENT_PYSR_PATCH_VERSION=$(python -c 'import pysr; print(pysr.version.__version__.split(".")[-1])' 2>/dev/null)
|
48 |
+
NEW_PYSR_PATCH_VERSION=$((CURRENT_PYSR_PATCH_VERSION + 1))
|
49 |
+
sed -i "s/^__version__ = .*/__version__ = \"$(python -c 'import pysr; print(".".join(pysr.version.__version__.split(".")[:-1]))' 2>/dev/null).${NEW_PYSR_PATCH_VERSION}\"/" pysr/version.py
|
50 |
+
|
51 |
+
# Set SymbolicRegression.jl version:
|
52 |
+
sed -i "s/^__symbolic_regression_jl_version__ = .*/__symbolic_regression_jl_version__ = \"${{ steps.get-latest.outputs.version }}\"/" pysr/version.py
|
53 |
+
|
54 |
+
git add pysr/version.py
|
55 |
+
git commit -m "Update backend version to v${{ steps.get-latest.outputs.version }}"
|
56 |
+
|
57 |
+
- name: "Create PR"
|
58 |
+
uses: peter-evans/create-pull-request@v3
|