From bcd6dd30e840b9845bf2980de24bdbe669f2cd7e Mon Sep 17 00:00:00 2001 From: odow Date: Sat, 19 Oct 2024 10:40:50 +1300 Subject: [PATCH 01/10] Install torch in GitHub actions --- .github/workflows/documentation.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/workflows/documentation.yml b/.github/workflows/documentation.yml index bf050c5..d056480 100644 --- a/.github/workflows/documentation.yml +++ b/.github/workflows/documentation.yml @@ -15,6 +15,7 @@ jobs: env: GKSwstype: nul DATADEPS_ALWAYS_ACCEPT: true + JULIA_CONDAPKG_BACKEND: Null steps: - uses: actions/checkout@v4 # Install pytorch From d8ac7d02087d479015587ea984d6d918d135b831 Mon Sep 17 00:00:00 2001 From: odow Date: Sat, 19 Oct 2024 13:22:48 +1300 Subject: [PATCH 02/10] Update --- .github/workflows/ci.yml | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 0414e87..165eb89 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -22,8 +22,19 @@ jobs: - version: '1' os: ubuntu-latest arch: x64 + env: + JULIA_CONDAPKG_BACKEND: Null 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 + # Install Julia - uses: julia-actions/setup-julia@v2 with: version: ${{ matrix.version }} From e4beadaa57fdee7c27a55c5b3ab33be75d0cd18b Mon Sep 17 00:00:00 2001 From: odow Date: Sat, 19 Oct 2024 16:39:04 +1300 Subject: [PATCH 03/10] Update --- test/test_PythonCall.jl | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/test/test_PythonCall.jl b/test/test_PythonCall.jl index baaa873..cc2ef18 100644 --- a/test/test_PythonCall.jl +++ b/test/test_PythonCall.jl @@ -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)() From 5d15a32a529076bf07ef2d5e1c1fa6d7b6978e9b Mon Sep 17 00:00:00 2001 From: odow Date: Sat, 19 Oct 2024 16:46:16 +1300 Subject: [PATCH 04/10] Update --- test/Project.toml | 1 - 1 file changed, 1 deletion(-) diff --git a/test/Project.toml b/test/Project.toml index d851cbd..d292d27 100644 --- a/test/Project.toml +++ b/test/Project.toml @@ -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" From 744448fed5d82a49d46e73fffe945d3f1099ca30 Mon Sep 17 00:00:00 2001 From: odow Date: Sat, 19 Oct 2024 16:47:38 +1300 Subject: [PATCH 05/10] Update --- .github/workflows/ci.yml | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 165eb89..0b95fca 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -23,7 +23,8 @@ jobs: os: ubuntu-latest arch: x64 env: - JULIA_CONDAPKG_BACKEND: Null + JULIA_CONDAPKG_BACKEND: "Null" + JULIA_PYTHONCALL_EXE: "python3" steps: - uses: actions/checkout@v4 # Install pytorch From 4dc741a11b90fb6d6e47f509f91fa92564812349 Mon Sep 17 00:00:00 2001 From: odow Date: Sat, 19 Oct 2024 17:03:43 +1300 Subject: [PATCH 06/10] Update --- .github/workflows/ci.yml | 3 +++ 1 file changed, 3 insertions(+) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 0b95fca..5a0ecdc 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -35,6 +35,9 @@ jobs: - name: Install pytorch run: | pip3 install torch --index-url https://download.pytorch.org/whl/cpu + python3 -c 'import torch' + which python + which python3 # Install Julia - uses: julia-actions/setup-julia@v2 with: From 521c821818d441092cc5945e42aec689cc4babcb Mon Sep 17 00:00:00 2001 From: odow Date: Sat, 19 Oct 2024 17:04:37 +1300 Subject: [PATCH 07/10] Update --- test/test_PythonCall.jl | 2 ++ 1 file changed, 2 insertions(+) diff --git a/test/test_PythonCall.jl b/test/test_PythonCall.jl index cc2ef18..dbf61f2 100644 --- a/test/test_PythonCall.jl +++ b/test/test_PythonCall.jl @@ -17,6 +17,8 @@ import PythonCall is_test(x) = startswith(string(x), "test_") function runtests() + @show ENV["JULIA_CONDAPKG_BACKEND"] + @show ENV["JULIA_PYTHONCALL_EXE"] # If we're running the tests locally, allow skipping Python tests if get(ENV, "CI", "false") == "false" try From f80db46297793815cafe4f320e2aa794960bac47 Mon Sep 17 00:00:00 2001 From: odow Date: Sat, 19 Oct 2024 17:47:50 +1300 Subject: [PATCH 08/10] Update --- .github/workflows/ci.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 5a0ecdc..79c84e0 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -35,6 +35,7 @@ jobs: - name: Install pytorch run: | pip3 install torch --index-url https://download.pytorch.org/whl/cpu + pip3 install numpy python3 -c 'import torch' which python which python3 From 11b285da183ec79783191c0aae277d0cbfb2dd22 Mon Sep 17 00:00:00 2001 From: odow Date: Sat, 19 Oct 2024 18:37:01 +1300 Subject: [PATCH 09/10] Upate --- .github/workflows/ci.yml | 3 --- .github/workflows/documentation.yml | 6 ++++-- docs/make.jl | 7 ++----- 3 files changed, 6 insertions(+), 10 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 79c84e0..95fc321 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -36,9 +36,6 @@ jobs: run: | pip3 install torch --index-url https://download.pytorch.org/whl/cpu pip3 install numpy - python3 -c 'import torch' - which python - which python3 # Install Julia - uses: julia-actions/setup-julia@v2 with: diff --git a/.github/workflows/documentation.yml b/.github/workflows/documentation.yml index d056480..6052a76 100644 --- a/.github/workflows/documentation.yml +++ b/.github/workflows/documentation.yml @@ -15,7 +15,8 @@ jobs: env: GKSwstype: nul DATADEPS_ALWAYS_ACCEPT: true - JULIA_CONDAPKG_BACKEND: Null + JULIA_CONDAPKG_BACKEND: "Null" + JULIA_PYTHONCALL_EXE: "python3" steps: - uses: actions/checkout@v4 # Install pytorch @@ -25,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: diff --git a/docs/make.jl b/docs/make.jl index bd6f4ca..b4309f5 100644 --- a/docs/make.jl +++ b/docs/make.jl @@ -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 @@ -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"], From b55d25eb14458fe2453dbbfdfb61fb4f24405189 Mon Sep 17 00:00:00 2001 From: odow Date: Sat, 19 Oct 2024 18:54:57 +1300 Subject: [PATCH 10/10] Update --- docs/src/tutorials/pytorch.jl | 17 +++++++++++++---- test/test_PythonCall.jl | 2 -- 2 files changed, 13 insertions(+), 6 deletions(-) diff --git a/docs/src/tutorials/pytorch.jl b/docs/src/tutorials/pytorch.jl index 3c772a7..daf0f40 100644 --- a/docs/src/tutorials/pytorch.jl +++ b/docs/src/tutorials/pytorch.jl @@ -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 diff --git a/test/test_PythonCall.jl b/test/test_PythonCall.jl index dbf61f2..cc2ef18 100644 --- a/test/test_PythonCall.jl +++ b/test/test_PythonCall.jl @@ -17,8 +17,6 @@ import PythonCall is_test(x) = startswith(string(x), "test_") function runtests() - @show ENV["JULIA_CONDAPKG_BACKEND"] - @show ENV["JULIA_PYTHONCALL_EXE"] # If we're running the tests locally, allow skipping Python tests if get(ENV, "CI", "false") == "false" try