Skip to content

Commit d98d42f

Browse files
committed
third
1 parent 6acead0 commit d98d42f

4 files changed

Lines changed: 24 additions & 8 deletions

File tree

.github/workflows/test-coverage.yaml

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,13 @@ jobs:
5454
extra-packages: any::covr, any::xml2
5555
needs: coverage
5656

57+
- name: setup r-reticulate
58+
shell: Rscript {0}
59+
run: |
60+
python = Sys.which("python")
61+
writeLines(sprintf("RETICULATE_PYTHON=%s", python), Sys.getenv("GITHUB_ENV"))
62+
reticulate::py_config()
63+
5764
- name: Test coverage
5865
run: |
5966
cov <- covr::package_coverage(

R/ee_init.R

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -22,15 +22,20 @@ ee_Init <- function(drive=FALSE, ...) {
2222
}
2323

2424
#' @export
25-
ee_auth_ci <- function() {
25+
ee_auth_ci <- function(token = NULL) {
2626
ci_auth <- system.file("python/ci_auth.py", package = "rgee2")
2727
reticulate::source_python(ci_auth)
28-
auto_Initialize()
28+
29+
if (is.null(token)) {
30+
token = os.getenv("EARTHENGINE_TOKEN")
31+
}
32+
auto_Initialize(token)
33+
print("ee_auth_ci: Authentication successful!")
2934
}
3035

3136
#' @export
3237
use_backend <- function() {
33-
reticulate::py_require("earthengine-api", pip = TRUE)
38+
reticulate::py_require("earthengine-api")
3439
}
3540

3641
#' @export

inst/python/ci_auth.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,10 +5,10 @@
55
import google.oauth2.credentials
66

77

8-
def auto_Initialize():
8+
def auto_Initialize(token):
99
# with open("token.json", "r") as f:
1010
# stored = json.load(f)
11-
stored = json.loads(os.getenv("EARTHENGINE_TOKEN"))
11+
stored = json.loads(token)
1212

1313
credentials = google.oauth2.credentials.Credentials(
1414
None,

tests/testthat/test-auth.R

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,15 +5,19 @@ test_that("auth works", {
55
# ci_auth()
66
}
77

8+
# token <- paste(readLines("token.json", encoding = "UTF-8"), collapse = "")
9+
token <- Sys.getenv("EARTHENGINE_TOKEN")
10+
811
tryCatch({
912
python <- system("which python")
1013
print(python)
1114

12-
use_backend()
13-
# Sys.setenv(RETICULATE_PYTHON = python)
15+
# use_backend()
16+
Sys.setenv(RETICULATE_PYTHON = python)
17+
reticulate::py_config()
1418

1519
print(system("pip list earthengine-api | grep earthengine-api"))
16-
ee_auth_ci()
20+
ee_auth_ci(token)
1721
}, error = function(e) {
1822
message(sprintf("%s", e$message))
1923
})

0 commit comments

Comments
 (0)