Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added CLI to run pysr.install() to install Julia dependencies #298

Merged
merged 33 commits into from
May 20, 2023
Merged
Show file tree
Hide file tree
Changes from 5 commits
Commits
Show all changes
33 commits
Select commit Hold shift + click to select a range
3876e75
Added click and install
WilliamBC-SL Apr 19, 2023
edc9d51
Added requirements.
WilliamBC-SL Apr 19, 2023
973fb98
Refactored to remove relative file reference
WilliamBC-SL Apr 19, 2023
40ac644
Refactored main to appropriate folder
WilliamBC-SL Apr 19, 2023
b111a3b
Updated instructions to install Julia dependencies
WilliamBC-SL Apr 19, 2023
6b2e2da
Added requirements.
w2ll2am Apr 20, 2023
f145620
Refactored to remove relative file reference
w2ll2am Apr 20, 2023
6c1caad
Refactored main to appropriate folder
w2ll2am Apr 20, 2023
9941a00
Updated instructions to install Julia dependencies
w2ll2am Apr 20, 2023
54a4632
Merge branch 'master' of https://github.com/w2ll2am/PySR
w2ll2am Apr 20, 2023
808a4c3
Implemented PR changes.
w2ll2am Apr 20, 2023
37a4ac2
Fixed missing variable pointer
w2ll2am Apr 20, 2023
7b970f3
Changed click version
w2ll2am Apr 22, 2023
b706235
Updated setup tools
w2ll2am Apr 22, 2023
b667140
Consistent formatting in `requirements.txt`
MilesCranmer Apr 25, 2023
0a7daf2
Tweak documentation
MilesCranmer Apr 25, 2023
01ec39f
Added more informative help message
w2ll2am Apr 25, 2023
58c93fa
Merge branch 'master' of https://github.com/w2ll2am/PySR
w2ll2am Apr 25, 2023
8e9aba4
Added tests to check help messages
w2ll2am Apr 28, 2023
df9e8e7
Removed extrenous imports
w2ll2am Apr 28, 2023
6fbdb36
Merge branch 'MilesCranmer:master' into master
WilliamBC-SL Apr 28, 2023
5509b10
Merge branch 'master' of https://github.com/w2ll2am/PySR
w2ll2am Apr 28, 2023
82f5f4d
Added some comments to explain tests
w2ll2am Apr 28, 2023
92ac433
Added tests to pipeline
w2ll2am May 11, 2023
1163194
Add CLI tests to CI
MilesCranmer May 15, 2023
cd0e3b6
Fix deleted coverage information
MilesCranmer May 15, 2023
c12c386
Merge tag 'v0.13.0' into pr/w2ll2am/298
MilesCranmer May 20, 2023
0cace0c
Bump version with new install method
MilesCranmer May 20, 2023
86ade53
Rename test_cli.py for consistency
MilesCranmer May 20, 2023
f8b274c
Leave old instructions until new method is stable
MilesCranmer May 20, 2023
d8d6e2b
Fix formatting
MilesCranmer May 20, 2023
a0fd52f
Simplify CLI test
MilesCranmer May 20, 2023
4726b4a
Refactor CLI unittest with `click.testing`
MilesCranmer May 20, 2023
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions .github/workflows/CI.yml
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ jobs:
python -m pip install --upgrade pip
pip install -r requirements.txt
python setup.py install
python -c 'import pysr; pysr.install()'
python -m pysr install
- name: "Install Coverage tool"
run: pip install coverage coveralls
- name: "Run tests"
Expand Down Expand Up @@ -112,7 +112,7 @@ jobs:
- name: "Install PySR"
run: |
python3 -m pip install .
python3 -c 'import pysr; pysr.install()'
python3 -m pysr install
- name: "Run tests"
run: cd /tmp && python -m pysr.test main

Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/CI_Windows.yml
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ jobs:
python -m pip install --upgrade pip
pip install -r requirements.txt
python setup.py install
python -c 'import pysr; pysr.install()'
python -m pysr install
- name: "Run tests"
run: python -m pysr.test main
- name: "Install Torch"
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/CI_large_nightly.yml
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ jobs:
python -m pip install --upgrade pip
pip install -r requirements.txt
python setup.py install
python -c 'import pysr; pysr.install()'
python -m pysr install
- name: "Run tests"
run: python -m pysr.test main
- name: "Run new env test"
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/CI_mac.yml
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ jobs:
python -m pip install --upgrade pip
pip install -r requirements.txt
python setup.py install
python -c 'import pysr; pysr.install()'
python -m pysr install
- name: "Run tests"
run: python -m pysr.test main
- name: "Install JAX"
Expand Down
2 changes: 1 addition & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ ADD ./pysr/ /pysr/pysr/
RUN pip3 install .

# Install Julia pre-requisites:
RUN python3 -c 'import pysr; pysr.install()'
RUN python3 -m pysr install

# metainformation
LABEL org.opencontainers.image.authors = "Miles Cranmer"
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ pip install -U pysr
```
3. Finally, to install Julia dependencies:
```bash
python3 -c 'import pysr; pysr.install()'
python3 -m pysr install
```

---
Expand Down
3 changes: 2 additions & 1 deletion environment.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,4 +9,5 @@ dependencies:
- setuptools
- pyjulia
- openlibm
- openspecfun
- openspecfun
- click
4 changes: 4 additions & 0 deletions pysr/__main__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
from pysr._cli.main import cli as _cli

if __name__ == '__main__':
_cli(prog_name="cli")
Empty file added pysr/_cli/__init__.py
Empty file.
16 changes: 16 additions & 0 deletions pysr/_cli/main.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
import click
from ..julia_helpers import install


@click.group("cli")
@click.pass_context
def cli(context):
ctx = context


@cli.command("install", help="Install required Julia dependencies")
w2ll2am marked this conversation as resolved.
Show resolved Hide resolved
@click.option("--julia_project", default=None)
MilesCranmer marked this conversation as resolved.
Show resolved Hide resolved
w2ll2am marked this conversation as resolved.
Show resolved Hide resolved
@click.option("--quiet", default=False)
w2ll2am marked this conversation as resolved.
Show resolved Hide resolved
@click.option("--precompile", default=None)
w2ll2am marked this conversation as resolved.
Show resolved Hide resolved
def _install(julia_project, quiet, precompile):
install(julia_project, quiet, precompile)
10 changes: 4 additions & 6 deletions pysr/julia_helpers.py
Original file line number Diff line number Diff line change
Expand Up @@ -110,10 +110,8 @@ def install(julia_project=None, quiet=False, precompile=None): # pragma: no cov

def _import_error():
return """
Required dependencies are not installed or built. Run the following code in the Python REPL:

>>> import pysr
>>> pysr.install()
Required dependencies are not installed or built. Run the following command:
python -m pysr install
"""


Expand Down Expand Up @@ -286,14 +284,14 @@ def _backend_version_assertion(Main):
f"does not match expected version {expected_backend_version}. "
"Things may break. "
"Please update your PySR installation with "
"`python -c 'import pysr; pysr.install()'`."
"`python -m pysr install`."
)
except JuliaError: # pragma: no cover
warnings.warn(
"You seem to have an outdated version of SymbolicRegression.jl. "
"Things may break. "
"Please update your PySR installation with "
"`python -c 'import pysr; pysr.install()'`."
"`python -m pysr install`."
)


Expand Down
2 changes: 2 additions & 0 deletions requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -3,3 +3,5 @@ pandas
numpy
scikit_learn >= 1.0.0
julia >= 0.6.0
click>=8.0.4
w2ll2am marked this conversation as resolved.
Show resolved Hide resolved
setuptools>=66.0.0
w2ll2am marked this conversation as resolved.
Show resolved Hide resolved