Skip to content

Commit

Permalink
Add R 🔁 Python cross compatibility tests (#740)
Browse files Browse the repository at this point in the history
* 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
juliasilge authored May 8, 2023
1 parent dad13d3 commit 4767bfe
Show file tree
Hide file tree
Showing 5 changed files with 73 additions and 0 deletions.
6 changes: 6 additions & 0 deletions .github/cross-compat/read-pins.R
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)
8 changes: 8 additions & 0 deletions .github/cross-compat/read-pins.py
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)
5 changes: 5 additions & 0 deletions .github/cross-compat/write-pins.R
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"))
7 changes: 7 additions & 0 deletions .github/cross-compat/write-pins.py
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")
47 changes: 47 additions & 0 deletions .github/workflows/cross-compat.yml
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

0 comments on commit 4767bfe

Please sign in to comment.