Skip to content

Commit

Permalink
Merge ade2ab0 into edab547
Browse files Browse the repository at this point in the history
  • Loading branch information
MilesCranmer committed Feb 7, 2024
2 parents edab547 + ade2ab0 commit 223f6a7
Show file tree
Hide file tree
Showing 30 changed files with 383 additions and 918 deletions.
26 changes: 12 additions & 14 deletions .github/workflows/CI.yml
Original file line number Diff line number Diff line change
Expand Up @@ -58,29 +58,28 @@ jobs:
- name: "Install PySR"
run: |
python -m pip install --upgrade pip
pip install -r requirements.txt
python setup.py install
python -m pysr install
pip install .
python -c 'import pysr'
- name: "Install Coverage tool"
run: pip install coverage coveralls
- name: "Run tests"
run: |
coverage run --source=pysr --omit='*/test/*,*/feynman_problems.py' -m pysr.test main
coverage run --append --source=pysr --omit='*/test/*,*/feynman_problems.py' -m pysr.test cli
coverage run --source=pysr --omit='*/test/*' -m pysr test main
coverage run --append --source=pysr --omit='*/test/*' -m pysr test cli
- name: "Install JAX"
run: pip install jax jaxlib # (optional import)
if: ${{ matrix.test-id == 'main' }}
- name: "Run JAX tests"
run: coverage run --append --source=pysr --omit='*/test/*,*/feynman_problems.py' -m pysr.test jax
run: coverage run --append --source=pysr --omit='*/test/*' -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 --source=pysr --omit='*/test/*,*/feynman_problems.py' -m pysr.test torch
run: coverage run --append --source=pysr --omit='*/test/*' -m pysr test torch
if: ${{ matrix.test-id == 'main' }}
- name: "Run custom env tests"
run: coverage run --append --source=pysr --omit='*/test/*,*/feynman_problems.py' -m pysr.test env
run: coverage run --append --source=pysr --omit='*/test/*' -m pysr test env
- name: "Coveralls"
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
Expand All @@ -95,7 +94,7 @@ jobs:
- name: "Build incremental install"
run: docker build -t pysr -f pysr/test/incremental_install_simulator.dockerfile .
- name: "Test incremental install"
run: docker run --rm pysr /bin/bash -l -c 'python3 -m pysr.test main && python3 -m pysr.test env'
run: docker run --rm pysr /bin/bash -l -c 'python3 -m pysr test main && python3 -m pysr test env'

conda_test:
runs-on: ${{ matrix.os }}
Expand Down Expand Up @@ -133,9 +132,9 @@ jobs:
- name: "Install PySR"
run: |
python3 -m pip install .
python3 -m pysr install
python3 -c 'import pysr'
- name: "Run tests"
run: cd /tmp && python -m pysr.test main
run: cd /tmp && python -m pysr test main

coveralls:
name: Indicate completion to coveralls.io
Expand Down Expand Up @@ -177,9 +176,8 @@ jobs:
- name: "Install PySR and all dependencies"
run: |
python -m pip install --upgrade pip
python -m pip install -r requirements.txt
python -m pip install mypy
python -m pip install .
pip install .
pip install mypy
- name: "Install additional dependencies"
run: python -m pip install jax jaxlib torch
if: ${{ matrix.python-version != '3.7' }}
Expand Down
13 changes: 6 additions & 7 deletions .github/workflows/CI_Windows.yml
Original file line number Diff line number Diff line change
Expand Up @@ -52,16 +52,15 @@ jobs:
- name: "Install PySR"
run: |
python -m pip install --upgrade pip
pip install -r requirements.txt
python setup.py install
python -m pysr install
pip install .
python -c 'import pysr'
- name: "Run tests"
run: |
python -m pysr.test main
python -m pysr.test cli
python -m pysr test main
python -m pysr test cli
- name: "Install Torch"
run: pip install torch # (optional import)
- name: "Run Torch tests"
run: python -m pysr.test torch
run: python -m pysr test torch
- name: "Run custom env tests"
run: python -m pysr.test env
run: python -m pysr test env
2 changes: 1 addition & 1 deletion .github/workflows/CI_conda_forge.yml
Original file line number Diff line number Diff line change
Expand Up @@ -40,4 +40,4 @@ jobs:
run: conda activate pysr-test && conda install pysr
if: ${{ !matrix.use-mamba }}
- name: "Run tests"
run: python -m pysr.test main
run: python -m pysr test main
2 changes: 1 addition & 1 deletion .github/workflows/CI_docker.yml
Original file line number Diff line number Diff line change
Expand Up @@ -37,4 +37,4 @@ jobs:
- name: Build docker
run: docker build --platform=${{ matrix.arch }} -t pysr .
- name: Test docker
run: docker run --platform=${{ matrix.arch }} --rm pysr /bin/bash -c 'python3 -m pysr.test main && python3 -m pysr.test cli && python3 -m pysr.test env'
run: docker run --platform=${{ matrix.arch }} --rm pysr /bin/bash -c 'python3 -m pysr test main && python3 -m pysr test cli && python3 -m pysr test env'
2 changes: 1 addition & 1 deletion .github/workflows/CI_docker_large_nightly.yml
Original file line number Diff line number Diff line change
Expand Up @@ -33,4 +33,4 @@ jobs:
- name: Build docker
run: docker build --platform=${{ matrix.arch }} -t pysr --build-arg JLVERSION=${{ matrix.julia-version }} --build-arg PYVERSION=${{ matrix.python-version }} .
- name: Test docker
run: docker run --platform=${{ matrix.arch }} --rm pysr /bin/bash -c 'python3 -m pysr.test main && python3 -m pysr.test cli && python3 -m pysr.test env'
run: docker run --platform=${{ matrix.arch }} --rm pysr /bin/bash -c 'python3 -m pysr test main && python3 -m pysr test cli && python3 -m pysr test env'
11 changes: 5 additions & 6 deletions .github/workflows/CI_large_nightly.yml
Original file line number Diff line number Diff line change
Expand Up @@ -40,13 +40,12 @@ jobs:
- name: "Install PySR"
run: |
python -m pip install --upgrade pip
pip install -r requirements.txt
python setup.py install
python -m pysr install
pip install .
python -c 'import pysr'
- name: "Run tests"
run: |
python -m pysr.test main
python -m pysr.test cli
python -m pysr test main
python -m pysr test cli
- name: "Run new env test"
run: python -m pysr.test env
run: python -m pysr test env
if: ${{ !(matrix.os == 'windows-latest' && matrix.python-version == '3.7') }}
15 changes: 7 additions & 8 deletions .github/workflows/CI_mac.yml
Original file line number Diff line number Diff line change
Expand Up @@ -52,20 +52,19 @@ jobs:
- name: "Install PySR"
run: |
python -m pip install --upgrade pip
pip install -r requirements.txt
python setup.py install
python -m pysr install
pip install .
python -c 'import pysr'
- name: "Run tests"
run: |
python -m pysr.test main
python -m pysr.test cli
python -m pysr test main
python -m pysr test cli
- name: "Install JAX"
run: pip install jax jaxlib # (optional import)
- name: "Run JAX tests"
run: python -m pysr.test jax
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
run: python -m pysr test torch
- name: "Run custom env tests"
run: python -m pysr.test env
run: python -m pysr test env
2 changes: 1 addition & 1 deletion CONTRIBUTORS.md
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ Scan through our [existing issues](https://github.com/MilesCranmer/PySR/issues)
check out the [guide](https://astroautomata.com/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`.
4. You can install your local version of PySR with `python setup.py install`, and run tests with `python -m pysr test main`.

### Commit your update

Expand Down
11 changes: 6 additions & 5 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -13,22 +13,23 @@ COPY --from=jl /usr/local/julia /usr/local/julia
ENV PATH="/usr/local/julia/bin:${PATH}"

# Install IPython and other useful libraries:
RUN pip install ipython matplotlib
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 -r /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
ADD ./setup.py /pysr/setup.py
ADD ./pysr/ /pysr/pysr/
RUN pip3 install .
ADD ./pysr /pysr/pysr
RUN pip3 install --no-cache-dir -e .

# Install Julia pre-requisites:
RUN python3 -m pysr install
RUN python3 -c 'import pysr'

# metainformation
LABEL org.opencontainers.image.authors = "Miles Cranmer"
Expand Down
46 changes: 10 additions & 36 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -27,10 +27,6 @@ If you've finished a project with PySR, please submit a PR to showcase your work
- [Contributors](#contributors-)
- [Why PySR?](#why-pysr)
- [Installation](#installation)
- [pip](#pip)
- [conda](#conda)
- [docker](#docker-build)
- [Troubleshooting](#troubleshooting)
- [Quickstart](#quickstart)
- [→ Documentation](https://astroautomata.com/PySR)

Expand Down Expand Up @@ -129,48 +125,31 @@ an explicit and powerful way to interpret deep neural networks.

## Installation

| [pip](#pip) | [conda](#conda) | [docker](#docker-build) |
|:---:|:---:|:---:|
| Everywhere (recommended) | Linux and Intel-based macOS | Everywhere (if all else fails) |
### Pip

---

### pip
You can install PySR with pip:

1. [Install Julia](https://julialang.org/downloads/)
- Alternatively, my personal preference is to use [juliaup](https://github.com/JuliaLang/juliaup#installation), which performs this automatically.
2. Then, run:
```bash
pip3 install -U pysr
pip install pysr
```
3. Finally, to install Julia dependencies:
```bash
python3 -m pysr install
```
> (Alternatively, from within Python, you can call `import pysr; pysr.install()`)

---
Julia dependencies will be installed at first import.

### conda
### Conda

The PySR build in conda includes all required dependencies, so you can install it by simply running:
Similarly, with conda:

```bash
conda install -c conda-forge pysr
```

from within your target conda environment.

However, note that the conda install does not support precompilation of Julia libraries, so the
start time may be slightly slower as the JIT-compilation will be running.
(Once the compilation finishes, there will not be a performance difference though.)

---
### Docker

### docker build
You can also use the `Dockerfile` to install PySR in a docker container

1. Clone this repo.
2. In the repo, run the build command with:
2. Within the repo's directory, build the docker container:
```bash
docker build -t pysr .
```
Expand All @@ -185,11 +164,7 @@ For more details, see the [docker section](#docker).

### Troubleshooting

Common issues tend to be related to Python not finding Julia.
To debug this, try running `python3 -c 'import os; print(os.environ["PATH"])'`.
If none of these folders contain your Julia binary, then you need to add Julia's `bin` folder to your `PATH` environment variable.

Another issue you might run into can result in a hard crash at import with
One issue you might run into can result in a hard crash at import with
a message like "`GLIBCXX_...` not found". This is due to another one of the Python dependencies
loading an incorrect `libstdc++` library. To fix this, you should modify your
`LD_LIBRARY_PATH` variable to reference the Julia libraries. For example, if the Julia
Expand All @@ -202,7 +177,6 @@ export LD_LIBRARY_PATH=$HOME/.julia/juliaup/julia-1.10.0+0.x64.linux.gnu/lib/jul

to your `.bashrc` or `.zshrc` file.

**Running PySR on macOS with an M1 processor:** you should use the pip version, and make sure to get the Julia binary for ARM/M-series processors.

## Quickstart

Expand Down

0 comments on commit 223f6a7

Please sign in to comment.