From 9ce10450f34ffa0e9dec74004960dcc58add6406 Mon Sep 17 00:00:00 2001 From: Miles Cranmer Date: Sun, 2 Jul 2023 13:35:13 -0400 Subject: [PATCH 01/13] Better help message for PyCall errors --- pysr/julia_helpers.py | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/pysr/julia_helpers.py b/pysr/julia_helpers.py index 5a61a1af..2126646e 100644 --- a/pysr/julia_helpers.py +++ b/pysr/julia_helpers.py @@ -81,7 +81,17 @@ def install(julia_project=None, quiet=False, precompile=None): # pragma: no cov if precompile == False: os.environ["JULIA_PKG_PRECOMPILE_AUTO"] = "0" - julia.install(quiet=quiet) + try: + julia.install(quiet=quiet) + except julia.tools.PyCallInstallError: + raise RuntimeError( + "Installing PyCall.jl failed. " + "Please delete the folder `~/.julia/packages/PyCall` folder, " + "and re-try installation. For further assistance, " + "please see the issue " + "https://github.com/MilesCranmer/PySR/issues/257." + ) + Main, init_log = init_julia(julia_project, quiet=quiet, return_aux=True) io_arg = _get_io_arg(quiet) From 49567da70374516fcdca97df567e6f00dd226c57 Mon Sep 17 00:00:00 2001 From: Miles Cranmer Date: Sun, 2 Jul 2023 13:37:41 -0400 Subject: [PATCH 02/13] Fix grammar in log message --- pysr/julia_helpers.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pysr/julia_helpers.py b/pysr/julia_helpers.py index 2126646e..5027dbe7 100644 --- a/pysr/julia_helpers.py +++ b/pysr/julia_helpers.py @@ -86,7 +86,7 @@ def install(julia_project=None, quiet=False, precompile=None): # pragma: no cov except julia.tools.PyCallInstallError: raise RuntimeError( "Installing PyCall.jl failed. " - "Please delete the folder `~/.julia/packages/PyCall` folder, " + "Please delete the folder `~/.julia/packages/PyCall`, " "and re-try installation. For further assistance, " "please see the issue " "https://github.com/MilesCranmer/PySR/issues/257." From c04aabc642876e186059b2f5234123fa1cb9c299 Mon Sep 17 00:00:00 2001 From: MilesCranmer Date: Sun, 2 Jul 2023 19:33:24 -0400 Subject: [PATCH 03/13] Try to install second time with PyCall --- pysr/julia_helpers.py | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/pysr/julia_helpers.py b/pysr/julia_helpers.py index 5027dbe7..3f21aa4b 100644 --- a/pysr/julia_helpers.py +++ b/pysr/julia_helpers.py @@ -84,13 +84,13 @@ def install(julia_project=None, quiet=False, precompile=None): # pragma: no cov try: julia.install(quiet=quiet) except julia.tools.PyCallInstallError: - raise RuntimeError( - "Installing PyCall.jl failed. " - "Please delete the folder `~/.julia/packages/PyCall`, " - "and re-try installation. For further assistance, " - "please see the issue " - "https://github.com/MilesCranmer/PySR/issues/257." + # Attempt to reset PyCall.jl's build: + subprocess.run( + ["julia", "-e", f'ENV["PYTHON"] = "{sys.executable}"; import Pkg; Pkg.build("PyCall")'], ) + # Try installing again: + julia.install(quiet=quiet) + Main, init_log = init_julia(julia_project, quiet=quiet, return_aux=True) io_arg = _get_io_arg(quiet) From 3fea07f685882c86bd8a3c9304e72d300a46f107 Mon Sep 17 00:00:00 2001 From: MilesCranmer Date: Sun, 2 Jul 2023 19:34:23 -0400 Subject: [PATCH 04/13] Add dockerfile for debugging pycall --- pycall_debug.dockerfile | 41 +++++++++++++++++++++++++++++++++++++++++ 1 file changed, 41 insertions(+) create mode 100644 pycall_debug.dockerfile diff --git a/pycall_debug.dockerfile b/pycall_debug.dockerfile new file mode 100644 index 00000000..247a363a --- /dev/null +++ b/pycall_debug.dockerfile @@ -0,0 +1,41 @@ +FROM debian:bullseye-slim + +ENV DEBIAN_FRONTEND=noninteractive + +# Install juliaup and pyenv: +RUN apt-get update && apt-get install -y curl + +# Install juliaup: +RUN curl -fsSL https://install.julialang.org | sh -s -- -y + +RUN apt-get install -y git build-essential libssl-dev zlib1g-dev libbz2-dev \ + libreadline-dev libsqlite3-dev libncurses5-dev libncursesw5-dev \ + xz-utils libffi-dev liblzma-dev + +# Install pyenv: +RUN curl -fsSL curl https://pyenv.run | sh && \ + echo 'export PATH="/root/.pyenv/bin:$PATH"' >> ~/.bashrc && \ + echo 'export PYENV_ROOT="$HOME/.pyenv"' >> ~/.bashrc && \ + echo 'eval "$(pyenv init -)"' >> ~/.bashrc && \ + echo 'eval "$(pyenv virtualenv-init -)"' >> ~/.bashrc + +# Default to using bash -l: +SHELL ["/bin/bash", "-l", "-c"] + +RUN juliaup add 1.8 && juliaup default 1.8 +RUN pyenv install 3.9.2 && pyenv global 3.9.2 +RUN python3 -m pip install --upgrade pip + +# Try to install pysr: +RUN python3 -m pip install pysr==0.14.2 +RUN python3 -m pysr install + +# Change Python version: +RUN pyenv install 3.10 && pyenv global 3.10 && pyenv uninstall -f 3.9.2 +RUN python3 -m pip install --upgrade pip + +# Try to use PySR: +RUN python3 -m pip install pysr==0.14.2 +RUN rm -r ~/.julia/environments/pysr-0.14.2 +# RUN julia -e 'using Pkg; Pkg.add("PyCall"); Pkg.build("PyCall")' +# RUN python3 -m pysr install From 6c7c86f46698e943fe716bd071596eb7931e66bc Mon Sep 17 00:00:00 2001 From: MilesCranmer Date: Sun, 2 Jul 2023 19:45:32 -0400 Subject: [PATCH 05/13] Make PyCall debug dockerfile test local version of PySR --- pycall_debug.dockerfile | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/pycall_debug.dockerfile b/pycall_debug.dockerfile index 247a363a..0a0ec83f 100644 --- a/pycall_debug.dockerfile +++ b/pycall_debug.dockerfile @@ -27,7 +27,14 @@ RUN pyenv install 3.9.2 && pyenv global 3.9.2 RUN python3 -m pip install --upgrade pip # Try to install pysr: -RUN python3 -m pip install pysr==0.14.2 +WORKDIR /pysr +ADD ./requirements.txt /pysr/requirements.txt +RUN python3 -m pip install -r /pysr/requirements.txt + +ADD ./setup.py /pysr/setup.py +ADD ./pysr/ /pysr/pysr/ +RUN python3 -m pip install . + RUN python3 -m pysr install # Change Python version: @@ -35,7 +42,6 @@ RUN pyenv install 3.10 && pyenv global 3.10 && pyenv uninstall -f 3.9.2 RUN python3 -m pip install --upgrade pip # Try to use PySR: -RUN python3 -m pip install pysr==0.14.2 +RUN python3 -m pip install . RUN rm -r ~/.julia/environments/pysr-0.14.2 -# RUN julia -e 'using Pkg; Pkg.add("PyCall"); Pkg.build("PyCall")' -# RUN python3 -m pysr install +RUN python3 -m pysr install From 0028a881b35acefd68ecb4502f810ba61faf2ac4 Mon Sep 17 00:00:00 2001 From: MilesCranmer Date: Sun, 2 Jul 2023 19:46:46 -0400 Subject: [PATCH 06/13] Move install simulator to test folder --- .../test/incremental_install_simulator.dockerfile | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename pycall_debug.dockerfile => pysr/test/incremental_install_simulator.dockerfile (100%) diff --git a/pycall_debug.dockerfile b/pysr/test/incremental_install_simulator.dockerfile similarity index 100% rename from pycall_debug.dockerfile rename to pysr/test/incremental_install_simulator.dockerfile From 51eb2dde25daea3cca93d6fc2860b4efee94b3f9 Mon Sep 17 00:00:00 2001 From: MilesCranmer Date: Sun, 2 Jul 2023 19:54:23 -0400 Subject: [PATCH 07/13] Add test for incremental install --- .github/workflows/CI.yml | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/.github/workflows/CI.yml b/.github/workflows/CI.yml index 3124d4b8..c7525e4d 100644 --- a/.github/workflows/CI.yml +++ b/.github/workflows/CI.yml @@ -78,6 +78,15 @@ jobs: COVERALLS_PARALLEL: true run: coveralls --service=github + incremental_install: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v2 + - 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 -c 'python3 -m pysr.test main && python3 -m pysr.test env' + conda_test: runs-on: ${{ matrix.os }} defaults: From 5d83b3a31460edf9da092d5cf55e039171e58340 Mon Sep 17 00:00:00 2001 From: "deepsource-autofix[bot]" <62050782+deepsource-autofix[bot]@users.noreply.github.com> Date: Sun, 2 Jul 2023 23:54:40 +0000 Subject: [PATCH 08/13] style: Format code with black --- pysr/julia_helpers.py | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/pysr/julia_helpers.py b/pysr/julia_helpers.py index 3f21aa4b..9b57fff7 100644 --- a/pysr/julia_helpers.py +++ b/pysr/julia_helpers.py @@ -86,12 +86,15 @@ def install(julia_project=None, quiet=False, precompile=None): # pragma: no cov except julia.tools.PyCallInstallError: # Attempt to reset PyCall.jl's build: subprocess.run( - ["julia", "-e", f'ENV["PYTHON"] = "{sys.executable}"; import Pkg; Pkg.build("PyCall")'], + [ + "julia", + "-e", + f'ENV["PYTHON"] = "{sys.executable}"; import Pkg; Pkg.build("PyCall")', + ], ) # Try installing again: julia.install(quiet=quiet) - Main, init_log = init_julia(julia_project, quiet=quiet, return_aux=True) io_arg = _get_io_arg(quiet) From b6fd52e2d293dad81f7dd04ab66ca498338b25b2 Mon Sep 17 00:00:00 2001 From: MilesCranmer Date: Sun, 2 Jul 2023 19:57:12 -0400 Subject: [PATCH 09/13] Improve readability of incremental install simulator --- .../incremental_install_simulator.dockerfile | 17 +++++++++-------- 1 file changed, 9 insertions(+), 8 deletions(-) diff --git a/pysr/test/incremental_install_simulator.dockerfile b/pysr/test/incremental_install_simulator.dockerfile index 0a0ec83f..1454ced1 100644 --- a/pysr/test/incremental_install_simulator.dockerfile +++ b/pysr/test/incremental_install_simulator.dockerfile @@ -3,15 +3,15 @@ FROM debian:bullseye-slim ENV DEBIAN_FRONTEND=noninteractive # Install juliaup and pyenv: -RUN apt-get update && apt-get install -y curl +RUN apt-get update && apt-get install -y curl git build-essential \ + libssl-dev zlib1g-dev libbz2-dev libreadline-dev libsqlite3-dev \ + libncurses5-dev libncursesw5-dev xz-utils libffi-dev liblzma-dev && \ + apt-get clean && \ + rm -rf /var/lib/apt/lists/* # Install juliaup: RUN curl -fsSL https://install.julialang.org | sh -s -- -y -RUN apt-get install -y git build-essential libssl-dev zlib1g-dev libbz2-dev \ - libreadline-dev libsqlite3-dev libncurses5-dev libncursesw5-dev \ - xz-utils libffi-dev liblzma-dev - # Install pyenv: RUN curl -fsSL curl https://pyenv.run | sh && \ echo 'export PATH="/root/.pyenv/bin:$PATH"' >> ~/.bashrc && \ @@ -26,22 +26,23 @@ RUN juliaup add 1.8 && juliaup default 1.8 RUN pyenv install 3.9.2 && pyenv global 3.9.2 RUN python3 -m pip install --upgrade pip -# Try to install pysr: +# Get PySR source: WORKDIR /pysr ADD ./requirements.txt /pysr/requirements.txt RUN python3 -m pip install -r /pysr/requirements.txt ADD ./setup.py /pysr/setup.py ADD ./pysr/ /pysr/pysr/ -RUN python3 -m pip install . +# First install of PySR: +RUN python3 -m pip install . RUN python3 -m pysr install # Change Python version: RUN pyenv install 3.10 && pyenv global 3.10 && pyenv uninstall -f 3.9.2 RUN python3 -m pip install --upgrade pip -# Try to use PySR: +# Second install of PySR: RUN python3 -m pip install . RUN rm -r ~/.julia/environments/pysr-0.14.2 RUN python3 -m pysr install From 73c59a677ef37d8ade4c5d5338b59b42bad1b322 Mon Sep 17 00:00:00 2001 From: MilesCranmer Date: Sun, 2 Jul 2023 20:08:35 -0400 Subject: [PATCH 10/13] Fix missing -l in docker command --- .github/workflows/CI.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/CI.yml b/.github/workflows/CI.yml index c7525e4d..cd56769b 100644 --- a/.github/workflows/CI.yml +++ b/.github/workflows/CI.yml @@ -85,7 +85,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 -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 }} From 7ef8428477b7df88cf24bd10927c2dfee02989f1 Mon Sep 17 00:00:00 2001 From: MilesCranmer Date: Sun, 2 Jul 2023 20:14:27 -0400 Subject: [PATCH 11/13] Document dockerfile --- pysr/test/incremental_install_simulator.dockerfile | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/pysr/test/incremental_install_simulator.dockerfile b/pysr/test/incremental_install_simulator.dockerfile index 1454ced1..b9e57f20 100644 --- a/pysr/test/incremental_install_simulator.dockerfile +++ b/pysr/test/incremental_install_simulator.dockerfile @@ -1,3 +1,7 @@ +# This dockerfile simulates a user installation that first +# builds PySR for Python 3.9, and then upgrades to Python 3.10. +# Normally this would cause an error when installing PyCall, so we want to +# ensure that PySR can automatically patch things. FROM debian:bullseye-slim ENV DEBIAN_FRONTEND=noninteractive From 6cedbd3582aede7d8d23083ba7722c421497d9ca Mon Sep 17 00:00:00 2001 From: MilesCranmer Date: Tue, 4 Jul 2023 08:42:53 -0400 Subject: [PATCH 12/13] Automatically reference latest PySR version --- pysr/test/incremental_install_simulator.dockerfile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pysr/test/incremental_install_simulator.dockerfile b/pysr/test/incremental_install_simulator.dockerfile index b9e57f20..62811e8c 100644 --- a/pysr/test/incremental_install_simulator.dockerfile +++ b/pysr/test/incremental_install_simulator.dockerfile @@ -48,5 +48,5 @@ RUN python3 -m pip install --upgrade pip # Second install of PySR: RUN python3 -m pip install . -RUN rm -r ~/.julia/environments/pysr-0.14.2 +RUN rm -r ~/.julia/environments/pysr-* RUN python3 -m pysr install From 61ddc76299bc071699408464fe1bba16b9c73376 Mon Sep 17 00:00:00 2001 From: MilesCranmer Date: Tue, 4 Jul 2023 08:43:16 -0400 Subject: [PATCH 13/13] Bump PySR version with automatic error recovery --- pysr/version.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pysr/version.py b/pysr/version.py index 5be325be..33a21003 100644 --- a/pysr/version.py +++ b/pysr/version.py @@ -1,2 +1,2 @@ -__version__ = "0.14.2" +__version__ = "0.14.3" __symbolic_regression_jl_version__ = "0.19.1"