From 7bb4f053933673df05f29c80f8ec5c87b8810e01 Mon Sep 17 00:00:00 2001 From: Alexandru Mahmoud Date: Fri, 10 Jan 2025 15:46:17 -0500 Subject: [PATCH] Remove user package out of admin repo --- BiocHubsIngestR/.Rbuildignore | 5 -- BiocHubsIngestR/.gitignore | 5 -- BiocHubsIngestR/DESCRIPTION | 20 ------- BiocHubsIngestR/NAMESPACE | 4 -- BiocHubsIngestR/R/credentials.R | 30 ---------- BiocHubsIngestR/R/upload.R | 54 ------------------ BiocHubsIngestR/README.md | 57 ------------------- BiocHubsIngestR/man/auth.Rd | 26 --------- BiocHubsIngestR/man/upload.Rd | 24 -------- BiocHubsIngestR/tests/testthat.R | 4 -- .../tests/testthat/test-credentials.R | 22 ------- BiocHubsIngestR/vignettes/BiocHubsIngestR.Rmd | 56 ------------------ 12 files changed, 307 deletions(-) delete mode 100644 BiocHubsIngestR/.Rbuildignore delete mode 100644 BiocHubsIngestR/.gitignore delete mode 100644 BiocHubsIngestR/DESCRIPTION delete mode 100644 BiocHubsIngestR/NAMESPACE delete mode 100644 BiocHubsIngestR/R/credentials.R delete mode 100644 BiocHubsIngestR/R/upload.R delete mode 100644 BiocHubsIngestR/README.md delete mode 100644 BiocHubsIngestR/man/auth.Rd delete mode 100644 BiocHubsIngestR/man/upload.Rd delete mode 100644 BiocHubsIngestR/tests/testthat.R delete mode 100644 BiocHubsIngestR/tests/testthat/test-credentials.R delete mode 100644 BiocHubsIngestR/vignettes/BiocHubsIngestR.Rmd diff --git a/BiocHubsIngestR/.Rbuildignore b/BiocHubsIngestR/.Rbuildignore deleted file mode 100644 index 33cc41e..0000000 --- a/BiocHubsIngestR/.Rbuildignore +++ /dev/null @@ -1,5 +0,0 @@ -^.*\.Rproj$ -^\.Rproj\.user$ -^_pkgdown\.yml$ -^docs$ -^pkgdown$ diff --git a/BiocHubsIngestR/.gitignore b/BiocHubsIngestR/.gitignore deleted file mode 100644 index 234f028..0000000 --- a/BiocHubsIngestR/.gitignore +++ /dev/null @@ -1,5 +0,0 @@ -.Rproj.user -.Rhistory -.RData -.Ruserdata -docs diff --git a/BiocHubsIngestR/DESCRIPTION b/BiocHubsIngestR/DESCRIPTION deleted file mode 100644 index 54e717c..0000000 --- a/BiocHubsIngestR/DESCRIPTION +++ /dev/null @@ -1,20 +0,0 @@ -Package: BiocHubsIngestR -Title: Upload Data to Bioconductor Hubs Ingest Endpoints -Version: 0.99.0 -Authors@R: - person("Alexandru", "Mahmoud", email = "alex.mahmoud@roswellpark.org", role = c("aut", "cre")) -Description: Facilitates uploading data to temporary S3 endpoints created by the Bioconductor Hubs Ingest stack. - Uses the paws SDK to configure credentials and upload local data directories to S3-compatible storage. -License: Artistic-2.0 -Encoding: UTF-8 -Roxygen: list(markdown = TRUE) -RoxygenNote: 7.3.2 -Imports: - paws -Suggests: - testthat (>= 3.0.0), - knitr, - rmarkdown -Config/testthat/edition: 3 -biocViews: Infrastructure -VignetteBuilder: knitr diff --git a/BiocHubsIngestR/NAMESPACE b/BiocHubsIngestR/NAMESPACE deleted file mode 100644 index 01edb3e..0000000 --- a/BiocHubsIngestR/NAMESPACE +++ /dev/null @@ -1,4 +0,0 @@ -# Generated by roxygen2: do not edit by hand - -export(auth) -export(upload) diff --git a/BiocHubsIngestR/R/credentials.R b/BiocHubsIngestR/R/credentials.R deleted file mode 100644 index f2d1e63..0000000 --- a/BiocHubsIngestR/R/credentials.R +++ /dev/null @@ -1,30 +0,0 @@ -#' Set AWS credentials for Bioconductor Hubs Ingest endpoint -#' -#' @param username Character string of the username provided by administrator -#' @param password Character string of the password/key provided by administrator -#' @param endpoint Optional custom endpoint URL. If NULL, constructs from username -#' -#' @return Invisible NULL, sets environment variables as side effect -#' @export -#' -#' @examples -#' \dontrun{ -#' BiocHubsIngestR::auth("myusername", "mypassword") -#' } -auth <- function(username, password, endpoint = NULL) { - if (!is.character(username) || !is.character(password)) - stop("Username and password must be character strings") - - if (is.null(endpoint)) { - endpoint <- sprintf("https://%s.hubsingest.bioconductor.org", username) - } - - Sys.setenv( - AWS_ACCESS_KEY_ID = username, - AWS_SECRET_ACCESS_KEY = password, - AWS_DEFAULT_REGION = "us-east-1", - AWS_S3_ENDPOINT = endpoint - ) - - invisible(NULL) -} diff --git a/BiocHubsIngestR/R/upload.R b/BiocHubsIngestR/R/upload.R deleted file mode 100644 index 5c2d356..0000000 --- a/BiocHubsIngestR/R/upload.R +++ /dev/null @@ -1,54 +0,0 @@ -#' Upload local directory to Bioconductor Hubs Ingest S3 endpoint -#' -#' Uses paws S3 client to upload files to the configured endpoint. Requires prior -#' authentication using the auth() function to set up the correct endpoint and -#' credentials. -#' -#' @param path Character string path to local directory or file to upload -#' @param bucket Character string of bucket name, defaults to "userdata" -#' -#' @return Invisible list of uploaded files -#' @export -#' -#' @examples -#' \dontrun{ -#' BiocHubsIngestR::upload("path/to/data") -#' } -upload <- function(path, bucket = "userdata") { - if (!file.exists(path)) - stop("Path does not exist: ", path) - - s3_client <- paws::s3(region = "", endpoint = Sys.getenv("AWS_S3_ENDPOINT")) - - # Check if bucket exists - tryCatch({ - s3_client$head_bucket(Bucket = bucket) - }, error = function(e) { - message("Creating bucket: ", bucket) - s3_client$create_bucket(Bucket = bucket) - }) - - if (file.info(path)$isdir) { - files <- list.files(path, recursive = TRUE, full.names = TRUE) - } else { - files <- path - } - - uploaded <- lapply(files, function(f) { - rel_path <- if(file.info(path)$isdir) { - sub(paste0("^", path, "/?"), "", f) - } else { - basename(f) - } - message("Uploading: ", rel_path) - - s3_client$put_object( - Body = readBin(f, "raw", file.info(f)$size), - Bucket = bucket, - Key = rel_path - ) - return(rel_path) - }) - - invisible(uploaded) -} diff --git a/BiocHubsIngestR/README.md b/BiocHubsIngestR/README.md deleted file mode 100644 index 929eafc..0000000 --- a/BiocHubsIngestR/README.md +++ /dev/null @@ -1,57 +0,0 @@ -# BiocHubsIngestR - -R package for uploading data to Bioconductor Hubs Ingest endpoints. - -## Description - -BiocHubsIngestR provides tools for uploading data to temporary S3 endpoints created by the Bioconductor Hubs Ingest stack. It uses the paws SDK for R to handle S3 operations and provides a simple interface for authentication and file uploads. - -## Prerequisites - -Before using this package, you must: -1. Have an S3 ingestion endpoint generated by a Bioconductor admin -2. Receive access credentials (username and password) from the admin - -## Installation - -```r -if (!require("BiocManager", quietly = TRUE)) - install.packages("BiocManager") - -BiocManager::install("Bioconductor/BiocHubsIngestR") -``` - -## Usage - -### Authentication - -```r -# Set up credentials (provided by Bioconductor admin) -BiocHubsIngestR::auth(username = "your_username", password = "your_password") -``` - -### Uploading Data - -```r -# Upload a single file -BiocHubsIngestR::upload("path/to/your/file.txt") - -# Upload an entire directory -BiocHubsIngestR::upload("path/to/your/data/directory") -``` - -## Important Notes - -1. After completing your data upload, notify the Bioconductor admin you are coordinating with -2. Once you inform the admin that the upload is complete, the endpoint will be locked for processing -3. No further uploads will be possible after the endpoint is locked - -## Support - -For questions or issues: -- Open an issue on the [GitHub repository](https://github.com/Bioconductor/BiocHubsIngestR/issues) -- Contact the Bioconductor team - -## License - -Artistic-2.0 diff --git a/BiocHubsIngestR/man/auth.Rd b/BiocHubsIngestR/man/auth.Rd deleted file mode 100644 index c8123a1..0000000 --- a/BiocHubsIngestR/man/auth.Rd +++ /dev/null @@ -1,26 +0,0 @@ -% Generated by roxygen2: do not edit by hand -% Please edit documentation in R/credentials.R -\name{auth} -\alias{auth} -\title{Set AWS credentials for Bioconductor Hubs Ingest endpoint} -\usage{ -auth(username, password, endpoint = NULL) -} -\arguments{ -\item{username}{Character string of the username provided by administrator} - -\item{password}{Character string of the password/key provided by administrator} - -\item{endpoint}{Optional custom endpoint URL. If NULL, constructs from username} -} -\value{ -Invisible NULL, sets environment variables as side effect -} -\description{ -Set AWS credentials for Bioconductor Hubs Ingest endpoint -} -\examples{ -\dontrun{ -BiocHubsIngestR::auth("myusername", "mypassword") -} -} diff --git a/BiocHubsIngestR/man/upload.Rd b/BiocHubsIngestR/man/upload.Rd deleted file mode 100644 index dac9d77..0000000 --- a/BiocHubsIngestR/man/upload.Rd +++ /dev/null @@ -1,24 +0,0 @@ -% Generated by roxygen2: do not edit by hand -% Please edit documentation in R/upload.R -\name{upload} -\alias{upload} -\title{Upload local directory to Bioconductor Hubs Ingest S3 endpoint} -\usage{ -upload(path, bucket = "userdata") -} -\arguments{ -\item{path}{Character string path to local directory or file to upload} - -\item{bucket}{Character string of bucket name, defaults to "userdata"} -} -\value{ -Invisible list of uploaded files -} -\description{ -Upload local directory to Bioconductor Hubs Ingest S3 endpoint -} -\examples{ -\dontrun{ -BiocHubsIngestR::upload("path/to/data") -} -} diff --git a/BiocHubsIngestR/tests/testthat.R b/BiocHubsIngestR/tests/testthat.R deleted file mode 100644 index 529aac7..0000000 --- a/BiocHubsIngestR/tests/testthat.R +++ /dev/null @@ -1,4 +0,0 @@ -library(testthat) -library(BiocHubsIngestR) - -test_check("BiocHubsIngestR") diff --git a/BiocHubsIngestR/tests/testthat/test-credentials.R b/BiocHubsIngestR/tests/testthat/test-credentials.R deleted file mode 100644 index 146dc90..0000000 --- a/BiocHubsIngestR/tests/testthat/test-credentials.R +++ /dev/null @@ -1,22 +0,0 @@ -test_that("auth sets environment variables correctly", { - old_env <- Sys.getenv(c("AWS_ACCESS_KEY_ID", "AWS_SECRET_ACCESS_KEY", - "AWS_DEFAULT_REGION", "AWS_S3_ENDPOINT")) - on.exit(do.call(Sys.setenv, as.list(old_env))) - - username <- "testuser" - password <- "testpass" - auth(username, password) - - expect_equal(Sys.getenv("AWS_ACCESS_KEY_ID"), username) - expect_equal(Sys.getenv("AWS_SECRET_ACCESS_KEY"), password) - expect_equal(Sys.getenv("AWS_DEFAULT_REGION"), "") - expect_equal( - Sys.getenv("AWS_S3_ENDPOINT"), - "https://testuser.hubsingest.bioconductor.org" - ) -}) - -test_that("auth validates inputs", { - expect_error(auth(123, "pass")) - expect_error(auth("user", 123)) -}) diff --git a/BiocHubsIngestR/vignettes/BiocHubsIngestR.Rmd b/BiocHubsIngestR/vignettes/BiocHubsIngestR.Rmd deleted file mode 100644 index 3a2cbeb..0000000 --- a/BiocHubsIngestR/vignettes/BiocHubsIngestR.Rmd +++ /dev/null @@ -1,56 +0,0 @@ ---- -title: "Using BiocHubsIngestR" -author: "Alexandru Mahmoud" -date: "`r Sys.Date()`" -output: rmarkdown::html_vignette -vignette: > - %\VignetteIndexEntry{Using BiocHubsIngestR} - %\VignetteEngine{knitr::rmarkdown} - %\VignetteEncoding{UTF-8} ---- - -```{r setup, include=FALSE} -knitr::opts_chunk$set(echo = TRUE) -``` - -## Introduction - -The `BiocHubsIngestR` package provides functionality for uploading data to temporary S3 endpoints created by the Bioconductor Hubs Ingest stack using the AWS SDK for R (`paws`). Before proceeding with data upload, you must: - -1. Have an S3 ingestion endpoint generated by a Bioconductor admin -2. Receive access credentials (username and password) from the admin - -## Authentication - -First, set up your credentials using the `auth()` function. This will configure the necessary AWS credentials and endpoint for the S3 client: - -```{r eval=FALSE} -# Replace with your actual credentials provided by the admin -BiocHubsIngestR::auth(username = "your_username", password = "your_password") -``` - -## Uploading Data - -Once authenticated, you can upload either individual files or entire directories: - -```{r eval=FALSE} -# Upload a single file -BiocHubsIngestR::upload("path/to/your/file.txt") - -# Upload an entire directory -BiocHubsIngestR::upload("path/to/your/data/directory") -``` - -The `upload()` function will create a bucket if it doesn't exist and handle the transfer of files to the S3 endpoint. Progress messages will be displayed during the upload process. - -## Implementation Details - -The package uses the `paws` SDK to interact with S3-compatible storage. The endpoint configuration is handled automatically when you authenticate with your credentials. All uploads are performed using the S3 client configured specifically for your assigned endpoint. - -## Important Notes - -1. After completing your data upload, notify the Bioconductor admin you are coordinating with. -2. Once you inform the admin that the upload is complete, the endpoint will be locked for processing and no further uploads will be possible. -3. Make sure all your data is uploaded completely before notifying the admin. - -For questions or issues, please contact the Bioconductor team or open an issue on the package's GitHub repository.