Skip to content

Commit c97b2a4

Browse files
authored
Merge pull request #110 from machow/chore-r-read-compat
Chore r read compat
2 parents 84c76da + 8006734 commit c97b2a4

File tree

8 files changed

+129
-0
lines changed

8 files changed

+129
-0
lines changed

.github/workflows/ci.yml

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -72,6 +72,41 @@ jobs:
7272
run: |
7373
pytest pins -m 'fs_rsc and not skip_on_github'
7474
75+
check-cross-compatibility:
76+
name: "Check cross lib compatibility"
77+
runs-on: ubuntu-latest
78+
steps:
79+
- uses: actions/checkout@v2
80+
81+
- name: Install libcurl on Linux
82+
run: sudo apt-get update -y && sudo apt-get install -y libcurl4-openssl-dev
83+
84+
# r ---
85+
86+
- uses: r-lib/actions/setup-r@v2
87+
with:
88+
use-public-rspm: true
89+
90+
- name: Install R dependencies
91+
run: "install.packages('pins')"
92+
shell: Rscript {0}
93+
94+
# python ---
95+
96+
- uses: actions/setup-python@v2
97+
with:
98+
python-version: 3.8
99+
- name: Install py dependencies
100+
run: |
101+
python -m pip install --upgrade pip
102+
python -m pip install -r requirements/dev.txt
103+
python -m pip install -e .
104+
105+
# write and test ---
106+
107+
- name: Run script/ci-compat-check
108+
run: make ci-compat-check
109+
75110
build-docs:
76111
name: "Build Docs"
77112
runs-on: ubuntu-latest

Makefile

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,3 +36,7 @@ requirements/dev.txt: setup.cfg
3636

3737
binder/requirements.txt: requirements/dev.txt
3838
cp $< $@
39+
40+
ci-compat-check:
41+
# TODO: mark as dummy
42+
$(MAKE) -C script/$@

script/ci-compat-check/.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
tmp

script/ci-compat-check/Makefile

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
BOARD_BASE_DIR=tmp
2+
BOARD_PY=$(BOARD_BASE_DIR)/board-py
3+
BOARD_R=$(BOARD_BASE_DIR)/board-r
4+
5+
all: validate
6+
7+
clean:
8+
rm -r $(BOARD_PY) $(BOARD_R)
9+
10+
validate: $(BOARD_PY) $(BOARD_R)
11+
@echo "\n\nRUNNING R PINS ---\n"
12+
Rscript validate_py_to_r.R $(BOARD_PY) $(BOARD_R)
13+
@echo "\n\nRUNNING PYTHON PINS ---\n"
14+
python validate_r_to_py.py $(BOARD_PY) $(BOARD_R)
15+
16+
$(BOARD_PY): dump_py_pins.py
17+
python dump_py_pins.py $@
18+
19+
$(BOARD_R): dump_r_pins.R
20+
Rscript dump_r_pins.R $@
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
import sys
2+
3+
from pins.data import mtcars
4+
from pins import board_folder
5+
6+
if len(sys.argv) < 2:
7+
raise ValueError("must pass board location as command-line argument")
8+
else:
9+
BOARD_PATH = sys.argv[1]
10+
11+
board = board_folder(BOARD_PATH)
12+
board.pin_write(mtcars, "mtcars", type="csv")
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
library(pins)
2+
args <- commandArgs(trailingOnly=TRUE)
3+
4+
board <- board_folder(args[1])
5+
board %>% pin_write(mtcars, "mtcars", type="csv")
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
library(pins)
2+
3+
args <- commandArgs(trailingOnly=TRUE)
4+
5+
6+
# create board ----
7+
8+
board_py <- board_folder(args[1])
9+
board_r <- board_folder(args[2])
10+
11+
12+
# check pins ----
13+
14+
cat("Checking mtcars pin\n")
15+
16+
res_mtcars <- board_py %>% pin_read("mtcars")
17+
stopifnot(all.equal(res_mtcars, datasets::mtcars, check.attributes=FALSE))
18+
19+
meta_mtcars_py <- board_py %>% pin_meta("mtcars")
20+
cat("\nPython meta:\n\n")
21+
print(meta_mtcars_py)
22+
23+
meta_mtcars_r <- board_r %>% pin_meta("mtcars")
24+
cat("\nR meta:\n\n")
25+
print(meta_mtcars_r)
Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
import sys
2+
3+
from pins import board_folder
4+
from pins import data
5+
6+
path_py, path_r = sys.argv[1], sys.argv[2]
7+
8+
# create board ----
9+
10+
board_py = board_folder(path_py)
11+
board_r = board_folder(path_r)
12+
13+
14+
# check pins ----
15+
16+
print("Checking mtcars pin")
17+
18+
res_mtcars = board_r.pin_read("mtcars")
19+
assert res_mtcars.equals(data.mtcars)
20+
21+
meta_mtcars_py = board_py.pin_meta("mtcars")
22+
print("\nPython meta:\n")
23+
print(meta_mtcars_py)
24+
25+
meta_mtcars_r = board_r.pin_meta("mtcars")
26+
print("\nR meta:\n")
27+
print(meta_mtcars_r)

0 commit comments

Comments
 (0)