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

Install torch in GitHub actions #136

Merged
merged 10 commits into from
Oct 19, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
13 changes: 13 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,21 @@ jobs:
- version: '1'
os: ubuntu-latest
arch: x64
env:
JULIA_CONDAPKG_BACKEND: "Null"
JULIA_PYTHONCALL_EXE: "python3"
steps:
- uses: actions/checkout@v4
# Install pytorch
- name: Set up Python
uses: actions/setup-python@v2
with:
python-version: '3.10'
- name: Install pytorch
run: |
pip3 install torch --index-url https://download.pytorch.org/whl/cpu
pip3 install numpy
# Install Julia
- uses: julia-actions/setup-julia@v2
with:
version: ${{ matrix.version }}
Expand Down
5 changes: 4 additions & 1 deletion .github/workflows/documentation.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@ jobs:
env:
GKSwstype: nul
DATADEPS_ALWAYS_ACCEPT: true
JULIA_CONDAPKG_BACKEND: "Null"
JULIA_PYTHONCALL_EXE: "python3"
steps:
- uses: actions/checkout@v4
# Install pytorch
Expand All @@ -24,7 +26,8 @@ jobs:
python-version: '3.10'
- name: Install pytorch
run: |
pip3 install torch --index-url https://download.pytorch.org/whl/cpu
pip3 install torch --index-url https://download.pytorch.org/whl/cpu
pip3 install numpy
# Install Julia
- uses: julia-actions/setup-julia@latest
with:
Expand Down
7 changes: 2 additions & 5 deletions docs/make.jl
Original file line number Diff line number Diff line change
Expand Up @@ -37,9 +37,6 @@ function _literate_directory(dir)
rm(filename)
end
for filename in _file_list(dir, dir, ".jl")
if endswith(filename, "pytorch.jl")
continue # Skip for now
end
# `include` the file to test it before `#src` lines are removed. It is
# in a testset to isolate local variables between files.
Test.@testset "$(filename)" begin
Expand Down Expand Up @@ -80,14 +77,14 @@ Documenter.makedocs(;
"manual/Flux.md",
"manual/GLM.md",
"manual/Lux.md",
# "manual/PyTorch.md",
"manual/PyTorch.md",
],
"Tutorials" => [
"tutorials/student_enrollment.md",
"tutorials/decision_trees.md",
"tutorials/mnist.md",
"tutorials/mnist_lux.md",
# "tutorials/pytorch.md",
"tutorials/pytorch.md",
"tutorials/gaussian.md",
],
"Developers" => ["developers/design_principles.md"],
Expand Down
17 changes: 13 additions & 4 deletions docs/src/tutorials/pytorch.jl
Original file line number Diff line number Diff line change
Expand Up @@ -18,15 +18,24 @@
# over how to link Julia to an existing Python environment. For example, if you
# have an existing Python installation (with PyTorch installed), and it is
# available in the current conda environment, set:

ENV["JULIA_CONDAPKG_BACKEND"] = "Current"

#
# ```julia
# ENV["JULIA_CONDAPKG_BACKEND"] = "Current"
# ```
#
# before importing PythonCall.jl. If the Python installation can be found on
# the path and it is not in a conda environment, set:

#
# ```julia
# ENV["JULIA_CONDAPKG_BACKEND"] = "Null"
# ```
#
# If `python` is not on your path, you may additionally need to set
# `JULIA_PYTHONCALL_EXE`, for example, to:
#
# ```julia
# ENV["JULIA_PYTHONCALL_EXE"] = "python3"
# ```

# ## Required packages

Expand Down
1 change: 0 additions & 1 deletion test/Project.toml
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
[deps]
AbstractGPs = "99985d1d-32ba-4be9-9821-2ec096f28918"
CSV = "336ed68f-0bac-5ca0-87d4-7b16caf5d00b"
CondaPkg = "992eb4ea-22a4-4c89-a5bb-47a3300528ab"
DataFrames = "a93c6f00-e57d-5684-b7b6-d8193f3e46c0"
DecisionTree = "7806a523-6efd-50cb-b5f6-3fa6f1930dbb"
Distributions = "31c24e10-a181-5473-b8eb-7969acd0382f"
Expand Down
13 changes: 8 additions & 5 deletions test/test_PythonCall.jl
Original file line number Diff line number Diff line change
Expand Up @@ -17,11 +17,14 @@ import PythonCall
is_test(x) = startswith(string(x), "test_")

function runtests()
try
PythonCall.pyimport("torch")
catch
@warn("Skipping PythonCall tests because we cannot import PyTorch.")
return
# If we're running the tests locally, allow skipping Python tests
if get(ENV, "CI", "false") == "false"
try
PythonCall.pyimport("torch")
catch
@warn("Skipping PythonCall tests because we cannot import PyTorch.")
return
end
end
@testset "$name" for name in filter(is_test, names(@__MODULE__; all = true))
getfield(@__MODULE__, name)()
Expand Down
Loading