Skip to content

Commit

Permalink
Robust setup-reticulate 🔨
Browse files Browse the repository at this point in the history
* Added tryCatch for fallbacks
* Updated action version
  • Loading branch information
serkor1 committed Jan 6, 2025
1 parent 8e1c7b3 commit 5553a5c
Show file tree
Hide file tree
Showing 4 changed files with 40 additions and 88 deletions.
51 changes: 38 additions & 13 deletions .github/actions/setup-reticulate/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ runs:
sudo apt-get install -y python3-venv
- name: Setup Python
uses: actions/setup-python@v4
uses: actions/setup-python@v5
with:
python-version: ${{ inputs.python-version }}

Expand All @@ -32,21 +32,46 @@ runs:
PYTHON_VERSION: ${{ inputs.python-version }}
run: |
# 2) create virtual environment
# 1) create virtual environment
# with specified version
path_to_python <- reticulate::virtualenv_create(
envname = "r-reticulate",
python_version = Sys.getenv("PYTHON_VERSION"),
packages = c(
"numpy",
"scipy",
"torch",
"torchmetrics",
"scikit-learn",
"imblearn"
)
path_to_python <- tryCatch(
expr = {
reticulate::virtualenv_create(
envname = "r-reticulate",
python = Sys.which("python"),
packages = c(
"numpy",
"scipy",
"torch",
"torchmetrics",
"scikit-learn",
"imblearn"
)
)
},
error = function(cond) {
reticulate::virtualenv_create(
envname = "r-reticulate",
python_version = Sys.getenv("PYTHON_VERSION"),
packages = c(
"numpy",
"scipy",
"torch",
"torchmetrics",
"scikit-learn",
"imblearn"
)
)
}
)
# 2) write path to
# environment
writeLines(
sprintf("RETICULATE_PYTHON=%s", path_to_python),
Sys.getenv("GITHUB_ENV")
Expand Down
75 changes: 0 additions & 75 deletions .github/workflows/macos-check-gcc.yaml

This file was deleted.

1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ downloads](https://cranlogs.r-pkg.org/badges/last-month/SLmetrics?color=blue)](h
[![Lifecycle:
experimental](https://img.shields.io/badge/lifecycle-experimental-orange.svg)](https://lifecycle.r-lib.org/articles/stages.html#experimental)
[![R-CMD-check](https://github.com/serkor1/SLmetrics/actions/workflows/R-CMD-check.yaml/badge.svg)](https://github.com/serkor1/SLmetrics/actions/workflows/R-CMD-check.yaml)
[![macOS-clang](https://github.com/serkor1/SLmetrics/actions/workflows/macos-check-clang.yaml/badge.svg)](https://github.com/serkor1/SLmetrics/actions/workflows/macos-check-clang.yaml)
[![codecov](https://codecov.io/gh/serkor1/SLmetrics/branch/development/graph/badge.svg?token=X2osJDSRlN)](https://app.codecov.io/gh/serkor1/SLmetrics)
[![CodeFactor](https://www.codefactor.io/repository/github/serkor1/slmetrics/badge)](https://www.codefactor.io/repository/github/serkor1/slmetrics)
<!-- badges: end -->
Expand Down
1 change: 1 addition & 0 deletions README.qmd
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@ lattice::trellis.par.set(
[![CRAN RStudio mirror downloads](https://cranlogs.r-pkg.org/badges/last-month/SLmetrics?color=blue)](https://r-pkg.org/pkg/SLmetrics)
[![Lifecycle: experimental](https://img.shields.io/badge/lifecycle-experimental-orange.svg)](https://lifecycle.r-lib.org/articles/stages.html#experimental)
[![R-CMD-check](https://github.com/serkor1/SLmetrics/actions/workflows/R-CMD-check.yaml/badge.svg)](https://github.com/serkor1/SLmetrics/actions/workflows/R-CMD-check.yaml)
[![macOS-clang](https://github.com/serkor1/SLmetrics/actions/workflows/macos-check-clang.yaml/badge.svg)](https://github.com/serkor1/SLmetrics/actions/workflows/macos-check-clang.yaml)
[![codecov](https://codecov.io/gh/serkor1/SLmetrics/branch/development/graph/badge.svg?token=X2osJDSRlN)](https://app.codecov.io/gh/serkor1/SLmetrics)
[![CodeFactor](https://www.codefactor.io/repository/github/serkor1/slmetrics/badge)](https://www.codefactor.io/repository/github/serkor1/slmetrics)
<!-- badges: end -->
Expand Down

0 comments on commit 5553a5c

Please sign in to comment.