Skip to content

Commit

Permalink
Merge pull request #748 from MilesCranmer/release-v1-beta
Browse files Browse the repository at this point in the history
Update to 1.0 backend
  • Loading branch information
MilesCranmer authored Nov 30, 2024
2 parents e8f1c70 + 0aaf3b9 commit ce07dc8
Show file tree
Hide file tree
Showing 46 changed files with 1,787 additions and 714 deletions.
61 changes: 38 additions & 23 deletions .github/workflows/CI.yml
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,8 @@ jobs:
os: [ubuntu-latest]
test-id: [main]
include:
- julia-version: '1.6'
python-version: '3.8'
- julia-version: '1.10'
python-version: '3.10'
os: ubuntu-latest
test-id: include
- julia-version: '1'
Expand All @@ -58,26 +58,18 @@ jobs:
- name: "Install PySR"
run: |
python -m pip install --upgrade pip
pip install .
pip install '.[dev]'
python -c 'import pysr'
- name: "Assert Julia version"
if: ${{ matrix.julia-version != '1'}}
run: python3 -c "from pysr import jl; assert jl.VERSION.major == jl.seval('v\"${{ matrix.julia-version }}\"').major; assert jl.VERSION.minor == jl.seval('v\"${{ matrix.julia-version }}\"').minor"
- name: "Install test dependencies"
run: pip install coverage coveralls pytest nbval
- name: "Set up coverage for subprocesses"
run: echo 'import coverage; coverage.process_startup()' > "${{ github.workspace }}/sitecustomize.py"
- name: "Run tests"
run: coverage run -m pysr test main,cli,startup
- name: "Install JAX"
run: pip install jax jaxlib # (optional import)
if: ${{ matrix.test-id == 'main' }}
- name: "Run JAX tests"
run: coverage run --append -m pysr test jax
if: ${{ matrix.test-id == 'main' }}
- name: "Install Torch"
run: pip install torch # (optional import)
if: ${{ matrix.test-id == 'main' }}
- name: "Run Torch tests"
run: coverage run --append -m pysr test torch
if: ${{ matrix.test-id == 'main' }}
Expand All @@ -97,15 +89,15 @@ jobs:
julia-version: ['1']
include:
- os: ubuntu-latest
python-version: '3.8'
julia-version: '1.6'
python-version: '3.10'
julia-version: '1.10'
steps:
- uses: actions/checkout@v4
- uses: actions/setup-python@v5
- name: "Install PySR"
run: |
python -m pip install --upgrade pip
pip install .
pip install '.[dev]'
- name: "Run development test"
run: PYSR_TEST_JULIA_VERSION=${{ matrix.julia-version }} PYSR_TEST_PYTHON_VERSION=${{ matrix.python-version }} python -m pysr test dev

Expand All @@ -131,7 +123,7 @@ jobs:
- name: "Set up Conda"
uses: conda-incubator/setup-miniconda@v3
with:
miniforge-variant: Mambaforge
miniforge-variant: Miniforge3
miniforge-version: latest
auto-activate-base: true
python-version: ${{ matrix.python-version }}
Expand Down Expand Up @@ -176,7 +168,7 @@ jobs:
matrix:
python-version:
- '3.12'
- '3.8'
- '3.10'
os: ['ubuntu-latest']

steps:
Expand All @@ -189,14 +181,37 @@ jobs:
- name: "Install PySR and all dependencies"
run: |
python -m pip install --upgrade pip
pip install .
pip install mypy
- name: "Install additional dependencies"
run: python -m pip install jax jaxlib torch
if: ${{ matrix.python-version != '3.8' }}
pip install '.[dev]'
- name: "Run mypy"
run: python -m mypy --install-types --non-interactive pysr
if: ${{ matrix.python-version != '3.8' }}
if: ${{ matrix.python-version != '3.10' }}
- name: "Run compatible mypy"
run: python -m mypy --ignore-missing-imports pysr
if: ${{ matrix.python-version == '3.8' }}
if: ${{ matrix.python-version == '3.10' }}

beartype:
name: Test with beartype
runs-on: ubuntu-latest
defaults:
run:
shell: bash -l {0}
env:
PYSR_USE_BEARTYPE: "1"
strategy:
matrix:
python-version: ['3.12']
os: ['ubuntu-latest']

steps:
- uses: actions/checkout@v4
- name: "Set up Python"
uses: actions/setup-python@v5
with:
python-version: ${{ matrix.python-version }}
cache: pip
- name: "Install PySR and all dependencies"
run: |
python -m pip install --upgrade pip
pip install '.[dev]'
- name: "Run tests"
run: python -m pysr test main,jax,torch
3 changes: 1 addition & 2 deletions .github/workflows/CI_Windows.yml
Original file line number Diff line number Diff line change
Expand Up @@ -46,8 +46,7 @@ jobs:
- name: "Install PySR"
run: |
python -m pip install --upgrade pip
pip install pytest nbval "numpy<2.0.0"
pip install .
pip install '.[dev]'
python -c 'import pysr'
- name: "Run tests"
run: |
Expand Down
6 changes: 3 additions & 3 deletions .github/workflows/CI_conda_forge.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,17 +20,17 @@ jobs:
strategy:
fail-fast: false
matrix:
python-version: ['3.9', '3.10', '3.11', '3.12']
python-version: ['3.10', '3.11', '3.12']
os: ['ubuntu-latest']
use-mamba: [true, false]
include:
- python-version: 3.9
- python-version: 3.10
os: 'windows-latest'
use-mamba: true
- python-version: 3.12
os: 'windows-latest'
use-mamba: true
- python-version: 3.9
- python-version: 3.10
os: 'macos-latest'
use-mamba: true
- python-version: 3.12
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/CI_docker_large_nightly.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,8 @@ jobs:
strategy:
fail-fast: false
matrix:
julia-version: ['1.6', '1']
python-version: ['3.8', '3.12']
julia-version: ['1.10', '1']
python-version: ['3.10', '3.12']
os: [ubuntu-latest]
arch: ['linux/amd64', 'linux/arm64']

Expand Down
7 changes: 3 additions & 4 deletions .github/workflows/CI_large_nightly.yml
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,8 @@ jobs:
strategy:
fail-fast: false
matrix:
julia-version: ['1.6', '1.8', '1.10']
python-version: ['3.8', '3.10', '3.12']
julia-version: ['1.10', '1']
python-version: ['3.10', '3.12']
os: [ubuntu-latest, macos-latest, windows-latest]

steps:
Expand All @@ -40,8 +40,7 @@ jobs:
- name: "Install PySR"
run: |
python -m pip install --upgrade pip
pip install pytest nbval
pip install .
pip install '.[dev]'
python -c 'import pysr'
- name: "Assert Julia version"
if: ${{ matrix.julia-version != '1'}}
Expand Down
7 changes: 1 addition & 6 deletions .github/workflows/CI_mac.yml
Original file line number Diff line number Diff line change
Expand Up @@ -46,17 +46,12 @@ jobs:
- name: "Install PySR"
run: |
python -m pip install --upgrade pip
pip install pytest nbval
pip install .
pip install '.[dev]'
python -c 'import pysr'
- name: "Run tests"
run: |
python -m pysr test main,cli,startup
- name: "Install JAX"
run: pip install jax jaxlib # (optional import)
- name: "Run JAX tests"
run: python -m pysr test jax
- name: "Install Torch"
run: pip install torch # (optional import)
- name: "Run Torch tests"
run: python -m pysr test torch
17 changes: 15 additions & 2 deletions .github/workflows/docs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -25,13 +25,26 @@ jobs:
- name: "Set up Python"
uses: actions/setup-python@v5
with:
python-version: 3.9
python-version: 3.12
cache: pip
- name: "Install packages for docs building"
run: pip install -r docs/requirements.txt
- name: "Install PySR"
run: pip install . && python -c 'import pysr'
- name: "Build API docs"
run: cd docs && ./gen_docs.sh
- name: "Deploy documentation"
- name: "Deploy documentation to primary repository"
run: mkdocs gh-deploy --force
- name: "Deploy documentation to secondary repository"
env:
DEPLOY_KEY: ${{ secrets.DAMTP_DEPLOY_KEY }}
run: |
# Set up SSH key for authentication
mkdir -p ~/.ssh
echo "$DEPLOY_KEY" > ~/.ssh/id_rsa
chmod 600 ~/.ssh/id_rsa
ssh-keyscan github.com >> ~/.ssh/known_hosts
git checkout gh-pages
git remote add secondary [email protected]:ai-damtp-cam-ac-uk/pysr.git
git push secondary gh-pages --force
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -25,3 +25,5 @@ site
venv
requirements-dev.lock
requirements.lock
outputs
.mypy_cache
5 changes: 2 additions & 3 deletions Apptainer.def
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
# Build an Apptainer SIF file containing a working copy of PySR and its prereqs
Bootstrap: docker
From: julia:1.10.4-bullseye
From: julia:1.11.1-bullseye
Stage: jl

Bootstrap: docker
From: python:3.12-bullseye
From: python:3.12.6-bullseye
Stage: runtime

%environment
Expand All @@ -19,7 +19,6 @@ Stage: runtime
/usr/local/julia /usr/local/julia

%files
./requirements.txt /pysr/requirements.txt
./pyproject.toml /pysr/pyproject.toml
./setup.py /pysr/setup.py
./pysr /pysr/pysr
Expand Down
4 changes: 2 additions & 2 deletions CONTRIBUTORS.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ In this guide you will get an overview of the contribution workflow from opening

## New contributor guide

To get an overview of the project, read PySR's [README](README.md). The [PySR docs](https://astroautomata.com/PySR/) give additional information.
To get an overview of the project, read PySR's [README](README.md). The [PySR docs](https://ai.damtp.cam.ac.uk/pysr/) give additional information.
Here are some resources to help you get started with open source contributions in general:

- [Finding ways to contribute to open source on GitHub](https://docs.github.com/en/get-started/exploring-projects-on-github/finding-ways-to-contribute-to-open-source-on-github)
Expand Down Expand Up @@ -39,7 +39,7 @@ Scan through our [existing issues](https://github.com/MilesCranmer/PySR/issues)
2. Create a working branch and start with your changes!

3. (Optional) If you would like to make changes to PySR itself, skip to step 4. However, if you are interested in making changes to the _symbolic regression code_ itself,
check out the [guide](https://astroautomata.com/PySR/backend/) on modifying a custom SymbolicRegression.jl library.
check out the [guide](https://ai.damtp.cam.ac.uk/pysr/backend/) on modifying a custom SymbolicRegression.jl library.
In this case, you might instead be interested in making suggestions to the [SymbolicRegression.jl](http://github.com/MilesCranmer/SymbolicRegression.jl) library.

4. You can install your local version of PySR with `python setup.py install`, and run tests with `python -m pysr test main`.
Expand Down
8 changes: 2 additions & 6 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
# This builds a dockerfile containing a working copy of PySR
# with all pre-requisites installed.

ARG JLVERSION=1.10.4
ARG PYVERSION=3.12.2
ARG JLVERSION=1.11.1
ARG PYVERSION=3.12.6
ARG BASE_IMAGE=bullseye

FROM julia:${JLVERSION}-${BASE_IMAGE} AS jl
Expand All @@ -17,10 +17,6 @@ RUN pip install --no-cache-dir ipython matplotlib

WORKDIR /pysr

# Caches install (https://stackoverflow.com/questions/25305788/how-to-avoid-reinstalling-packages-when-building-docker-image-for-python-project)
ADD ./requirements.txt /pysr/requirements.txt
RUN pip3 install --no-cache-dir -r /pysr/requirements.txt

# Install PySR:
# We do a minimal copy so it doesn't need to rerun at every file change:
ADD ./pyproject.toml /pysr/pyproject.toml
Expand Down
20 changes: 10 additions & 10 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ https://github.com/MilesCranmer/PySR/assets/7593028/c8511a49-b408-488f-8f18-b174

| **Docs** | **Forums** | **Paper** | **colab demo** |
|:---:|:---:|:---:|:---:|
|[![Documentation](https://github.com/MilesCranmer/PySR/actions/workflows/docs.yml/badge.svg)](https://astroautomata.com/PySR/)|[![Discussions](https://img.shields.io/badge/discussions-github-informational)](https://github.com/MilesCranmer/PySR/discussions)|[![Paper](https://img.shields.io/badge/arXiv-2305.01582-b31b1b)](https://arxiv.org/abs/2305.01582)|[![Colab](https://img.shields.io/badge/colab-notebook-yellow)](https://colab.research.google.com/github/MilesCranmer/PySR/blob/master/examples/pysr_demo.ipynb)|
|[![Documentation](https://github.com/MilesCranmer/PySR/actions/workflows/docs.yml/badge.svg)](https://ai.damtp.cam.ac.uk/pysr/)|[![Discussions](https://img.shields.io/badge/discussions-github-informational)](https://github.com/MilesCranmer/PySR/discussions)|[![Paper](https://img.shields.io/badge/arXiv-2305.01582-b31b1b)](https://arxiv.org/abs/2305.01582)|[![Colab](https://img.shields.io/badge/colab-notebook-yellow)](https://colab.research.google.com/github/MilesCranmer/PySR/blob/master/examples/pysr_demo.ipynb)|

| **pip** | **conda** | **Stats** |
| :---: | :---: | :---: |
Expand All @@ -20,14 +20,14 @@ https://github.com/MilesCranmer/PySR/assets/7593028/c8511a49-b408-488f-8f18-b174
</div>

If you find PySR useful, please cite the paper [arXiv:2305.01582](https://arxiv.org/abs/2305.01582).
If you've finished a project with PySR, please submit a PR to showcase your work on the [research showcase page](https://astroautomata.com/PySR/papers)!
If you've finished a project with PySR, please submit a PR to showcase your work on the [research showcase page](https://ai.damtp.cam.ac.uk/pysr/papers)!

**Contents**:

- [Why PySR?](#why-pysr)
- [Installation](#installation)
- [Quickstart](#quickstart)
- [→ Documentation](https://astroautomata.com/PySR)
- [→ Documentation](https://ai.damtp.cam.ac.uk/PySR)
- [Contributors](#contributors-)

<div align="center">
Expand Down Expand Up @@ -178,6 +178,7 @@ PySR's main interface is in the style of scikit-learn:
from pysr import PySRRegressor

model = PySRRegressor(
maxsize=20,
niterations=40, # < Increase me for better results
binary_operators=["+", "*"],
unary_operators=[
Expand Down Expand Up @@ -254,22 +255,21 @@ model = PySRRegressor.from_file("hall_of_fame.2022-08-10_100832.281.pkl")

There are several other useful features such as denoising (e.g., `denoise=True`),
feature selection (e.g., `select_k_features=3`).
For examples of these and other features, see the [examples page](https://astroautomata.com/PySR/examples).
For a detailed look at more options, see the [options page](https://astroautomata.com/PySR/options).
You can also see the full API at [this page](https://astroautomata.com/PySR/api).
There are also tips for tuning PySR on [this page](https://astroautomata.com/PySR/tuning).
For examples of these and other features, see the [examples page](https://ai.damtp.cam.ac.uk/pysr/examples).
For a detailed look at more options, see the [options page](https://ai.damtp.cam.ac.uk/pysr/options).
You can also see the full API at [this page](https://ai.damtp.cam.ac.uk/pysr/api).
There are also tips for tuning PySR on [this page](https://ai.damtp.cam.ac.uk/pysr/tuning).

### Detailed Example

The following code makes use of as many PySR features as possible.
Note that is just a demonstration of features and you should not use this example as-is.
For details on what each parameter does, check out the [API page](https://astroautomata.com/PySR/api/).
For details on what each parameter does, check out the [API page](https://ai.damtp.cam.ac.uk/pysr/api/).

```python
model = PySRRegressor(
procs=4,
populations=8,
# ^ 2 populations per core, so one is always running.
# ^ Assuming we have 4 cores, this means 2 populations per core, so one is always running.
population_size=50,
# ^ Slightly larger populations, for greater diversity.
ncycles_per_iteration=500,
Expand Down
Loading

0 comments on commit ce07dc8

Please sign in to comment.