-
Notifications
You must be signed in to change notification settings - Fork 64
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add R 🔁 Python cross compatibility tests (#740)
* Start by installing everything * Now write pins from both R and Python * Read Python pin from R * Read R pin from Python * Write with tags in R
- Loading branch information
1 parent
dad13d3
commit 4767bfe
Showing
5 changed files
with
73 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
library(pins) | ||
args <- commandArgs(trailingOnly = TRUE) | ||
|
||
board <- board_folder(args[1]) | ||
res <- board %>% pin_read("mtcars-py") | ||
testthat::expect_equal(res, datasets::mtcars, ignore_attr = TRUE) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
import sys | ||
|
||
from pins.data import mtcars | ||
from pins import board_folder | ||
|
||
board = board_folder(sys.argv[1]) | ||
res = board.pin_read("mtcars-r") | ||
assert res.equals(mtcars) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
library(pins) | ||
args <- commandArgs(trailingOnly = TRUE) | ||
|
||
board <- board_folder(args[1]) | ||
board %>% pin_write(mtcars, "mtcars-r", type = "csv", tags = c("cars", "fuel")) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
import sys | ||
|
||
from pins.data import mtcars | ||
from pins import board_folder | ||
|
||
board = board_folder(sys.argv[1]) | ||
board.pin_write(mtcars, "mtcars-py", type = "csv") |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
# Workflow derived from https://github.com/r-lib/actions/tree/master/examples | ||
# Need help debugging build failures? Start at https://github.com/r-lib/actions#where-to-find-help | ||
on: | ||
push: | ||
branches: [main, master] | ||
pull_request: | ||
branches: [main, master] | ||
|
||
name: cross-compat | ||
|
||
jobs: | ||
cross-compat: | ||
runs-on: ubuntu-latest | ||
env: | ||
GITHUB_PAT: ${{ secrets.GITHUB_TOKEN }} | ||
SHARED_BOARD: "tmp" | ||
|
||
steps: | ||
- uses: actions/checkout@v3 | ||
|
||
- uses: r-lib/actions/setup-r@v2 | ||
with: | ||
use-public-rspm: true | ||
|
||
- uses: actions/setup-python@v4 | ||
with: | ||
python-version: '3.10' | ||
|
||
- uses: r-lib/actions/setup-r-dependencies@v2 | ||
with: | ||
extra-packages: local::. | ||
|
||
- name: Install Python dependencies | ||
run: | | ||
python -m pip install --upgrade pip | ||
python -m pip install --upgrade git+https://github.com/rstudio/pins-python | ||
- name: Write pins | ||
run: | | ||
python .github/cross-compat/write-pins.py $SHARED_BOARD | ||
Rscript .github/cross-compat/write-pins.R $SHARED_BOARD | ||
- name: Read pins | ||
run: | | ||
Rscript .github/cross-compat/read-pins.R $SHARED_BOARD | ||
python .github/cross-compat/read-pins.py $SHARED_BOARD | ||