Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

added copy export, to fix #171 #190

Open
wants to merge 29 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 25 commits
Commits
Show all changes
29 commits
Select commit Hold shift + click to select a range
5ab8f59
added copy export, to fix #171
muschellij2 Oct 8, 2021
6c1891b
addedthe ability to pass in instructions on dockerfile creation
muschellij2 Oct 8, 2021
db58b01
fixing bugs for make_unit (deprecated), and expression parsing (bioc.…
muschellij2 Oct 11, 2021
0d19711
fixing warning in LabelelSchema, added potential fix for BioC
muschellij2 Oct 11, 2021
f245b98
exporting Workdir similar to Copy
muschellij2 Oct 11, 2021
8386bbc
fixing units package again for test_package_script
muschellij2 Oct 11, 2021
a8042f0
added ability to run docker commands for check by adding GitHub Actions
muschellij2 Oct 11, 2021
d6f4691
updated te readme !! microbadger isnt a thing anymore
muschellij2 Oct 11, 2021
81680d5
fixing typo
muschellij2 Oct 13, 2021
4a12c25
fixing issue if platform is null with sysreqs api
muschellij2 Oct 13, 2021
c28e12b
added session_info capabilities
muschellij2 Oct 14, 2021
2b48c0c
added the platform argument to be able to pass through
muschellij2 Oct 14, 2021
3573184
bug/typo
muschellij2 Oct 14, 2021
31cf167
adding docker to gh actions
muschellij2 Oct 14, 2021
86255b4
fixing actions
muschellij2 Oct 14, 2021
2af23e3
trying agian
muschellij2 Oct 14, 2021
ba4daa6
trying agian
muschellij2 Oct 14, 2021
a76cdd3
added the skip for coxrobust
muschellij2 Oct 14, 2021
235f09f
allowing ubuntu in there because sysreqs supports it
muschellij2 Oct 14, 2021
8527cb5
trying to fix #193
muschellij2 Nov 19, 2021
21ff490
removed hash
muschellij2 Nov 19, 2021
8822aff
jsonlite can take care of the hash
muschellij2 Nov 19, 2021
0f7aaf4
addedd Arg and Env arguments
muschellij2 Nov 30, 2021
31175cf
fixing some of the tests
muschellij2 Nov 30, 2021
ab2e804
added in syntax
muschellij2 Dec 2, 2021
e27a175
Fix doc comment
nuest Dec 17, 2021
5bd7c4f
Added CMD_Rexpr
muschellij2 Feb 8, 2022
e5c11df
Merge branch 'master' of github.com:muschellij2/containerit
muschellij2 Feb 8, 2022
04731e9
allowed Cmd to be NULL
muschellij2 Feb 17, 2022
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions .Rbuildignore
Original file line number Diff line number Diff line change
Expand Up @@ -14,3 +14,5 @@ docs
^paper\.bib$
^paper\.md$
^codemeta\.json$
^CONTRIBUTING\.md$
^\.github$
1 change: 1 addition & 0 deletions .github/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
*.html
62 changes: 62 additions & 0 deletions .github/workflows/R-CMD-check.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
# 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: R-CMD-check

jobs:
R-CMD-check:
runs-on: ${{ matrix.config.os }}

name: ${{ matrix.config.os }} (${{ matrix.config.r }})

strategy:
fail-fast: false
matrix:
config:
- {os: macOS-latest, r: 'release'}
- {os: windows-latest, r: 'release'}
- {os: ubuntu-latest, r: 'devel', http-user-agent: 'release'}
- {os: ubuntu-latest, r: 'release'}
- {os: ubuntu-latest, r: 'oldrel-1'}

env:
GITHUB_PAT: ${{ secrets.GITHUB_TOKEN }}
R_KEEP_PKG_SOURCE: yes

steps:
- uses: actions/checkout@v2

- uses: r-lib/actions/setup-pandoc@v1

- uses: r-lib/actions/setup-r@v1
with:
r-version: ${{ matrix.config.r }}
http-user-agent: ${{ matrix.config.http-user-agent }}
use-public-rspm: true

- uses: r-lib/actions/setup-r-dependencies@v1
with:
extra-packages: rcmdcheck

- uses: docker-practice/actions-setup-docker@master

- run: docker version

- uses: r-lib/actions/check-r-package@v1

- name: Show testthat output
if: always()
run: find check -name 'testthat.Rout*' -exec cat '{}' \; || true
shell: bash

- name: Upload check results
if: failure()
uses: actions/upload-artifact@main
with:
name: ${{ runner.os }}-r${{ matrix.config.r }}-results
path: check
6 changes: 4 additions & 2 deletions DESCRIPTION
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,7 @@ Imports:
versions
Suggests:
BiocGenerics,
units (>= 0.7.0),
codetools,
covr,
coxrobust,
Expand All @@ -90,14 +91,15 @@ Suggests:
sessioninfo,
sf,
sp,
testthat
testthat,
httr
VignetteBuilder:
knitr
Remotes:
github::r-hub/sysreqs
Encoding: UTF-8
LazyData: TRUE
RoxygenNote: 7.1.1
RoxygenNote: 7.1.2.9000
Collate:
'Class-Instruction.R'
'Class-Add.R'
Expand Down
4 changes: 4 additions & 0 deletions NAMESPACE
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,14 @@
S3method(docker_build,Dockerfile)
S3method(docker_build,character)
export("addInstruction<-")
export(Arg)
export(CMD_Render)
export(CMD_Rscript)
export(Cmd)
export(Comment)
export(Copy)
export(Entrypoint)
export(Env)
export(Expose)
export(Label)
export(LabelSchemaFactory)
Expand All @@ -16,6 +19,7 @@ export(Label_SessionInfo)
export(Run)
export(Run_shell)
export(Shell)
export(Workdir)
export(clean_session)
export(docker_build)
export(dockerfile)
Expand Down
40 changes: 29 additions & 11 deletions R/Class-Arg.R
Original file line number Diff line number Diff line change
Expand Up @@ -8,23 +8,41 @@
#' @return object
#' @family instruction classes
#' @examples
#' #no example yet
setClass("Arg", contains = "Instruction")
#' x = Arg("myarg")
#' print(x)
setClass(
"Arg",
slots = list(argument = "character"),
contains = "Instruction",
validity = function(object) {
if (length(object@argument) == 1) TRUE else "argument must be length 1"
}
)

#' Arg constructor yet to be implemented
#' create objects of class Arg
#'
#' @param ... fields yet to be implemented
#'
#' @return the object
#' @examples
#' #no example yet
Arg <- function(...) {
stop("Constructor not yet implemented for this class.")
#' @param argument the argument name
#' @export
#' @return Arg-object
Arg <- function(argument) {
return(new("Arg", argument = argument))
}

setMethod(
"docker_key",
signature = signature(obj = "Arg"),
definition =
function(obj) {
return("ARG")
}
)


setMethod("docker_arguments",
signature(obj = "Arg"),
function(obj) {
stop("The generic function docker_arguments is not implemented for class ",
class(obj))
argument <- methods::slot(obj, "argument")
return(argument)
})

2 changes: 1 addition & 1 deletion R/Class-Cmd.R
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
#'
#' See official documentation at \url{https://docs.docker.com/engine/reference/builder/#cmd}.
#'
#' @slot exec exectuable, character
#' @slot exec executable, character
#' @slot params parameters, character (vector)
#' @slot form the form to use for output (exec or shell)
#'
Expand Down
2 changes: 2 additions & 0 deletions R/Class-Copy.R
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
#' @family instruction classes
#' @examples
#' #no example yet
#' Copy("here", "/here")
setClass("Copy",
slots = list(src = "character", dest = "character"),
contains = "Instruction")
Expand All @@ -26,6 +27,7 @@ setClass("Copy",
#' @param addTrailingSlashes (boolean) add trailing slashes to the given paths if the source is an existing directory
#'
#' @return the object
#' @export
#' @importFrom fs dir_exists
#' @importFrom stringr str_detect
Copy <- function(src, dest, addTrailingSlashes = TRUE) {
Expand Down
23 changes: 18 additions & 5 deletions R/Class-Dockerfile.R
Original file line number Diff line number Diff line change
Expand Up @@ -15,23 +15,36 @@
#' @slot instructions an ordered list of instructions in the Dockerfile (list of character)
#' @slot entrypoint the entrypoint instruction applied to the container
#' @slot cmd the default cmd instruction applied to the container
#' @slot syntax the syntax given for the header of the container
#'
#' @details The entrypoint and cmd are provided outside of instructions, as only one of them takes effect.
#' If Cmd or Entrypoint instructions are provided as part of the regular instructions, they appear in the Dockerfile but have no effect.
#'
#' @return an object of class \code{Dockerfile}
#' @export
Dockerfile <- setClass("Dockerfile",
slots = list(image = "From",
maintainer = "NullOrLabelOrMaintainer",
instructions = "list",
entrypoint = "NullOrEntrypoint",
cmd = "Cmd")
slots = list(
image = "From",
maintainer = "NullOrLabelOrMaintainer",
instructions = "list",
entrypoint = "NullOrEntrypoint",
cmd = "Cmd",
syntax = "NullOrCharacter")
)

toString.Dockerfile <- function(x, ...) {
#initialize dockerfile with from
output <- c()
syntax <- methods::slot(x, "syntax")
if (!is.null(syntax)) {
syntax = trimws(syntax)
syntax = sub("^#*", "", syntax)
syntax = trimws(syntax)
syntax = sub("syntax=", "", syntax)
syntax = trimws(syntax)
syntax = paste0("# syntax=", syntax)
output <- append(output, syntax)
}
from <- toString(methods::slot(x, "image"))
output <- append(output, from)
maintainer <- methods::slot(x, "maintainer")
Expand Down
58 changes: 45 additions & 13 deletions R/Class-Env.R
Original file line number Diff line number Diff line change
@@ -1,30 +1,62 @@
# Copyright 2018 Opening Reproducible Research (https://o2r.info)

#' Env class yet to be implemented
#' Env-instruction class yet to be implemented
#' @include Class-Instruction.R
#'
#' See official documentation at \url{https://docs.docker.com/engine/reference/builder/#env}.
#'
#' @return the object
#' @return object
#' @family instruction classes
#' @examples
#' #no example yet
setClass("Env", contains = "Instruction")
#' x = Env("myarg", "default value")
#' print(x)
#' x = Env("myarg")
#' print(x)
setClass(
"Env",
slots = list(argument = "character",
value = "NullOrCharacter"),
contains = "Instruction",
validity = function(object) {
if (length(object@argument) == 1 && length(object@value) <= 1) {
TRUE
} else {
"argument must be length 1 and value must be max length 1"
}
}
)

#' Constructor for Env yet to be implemented
#' create objects of class Env
#'
#' @param ... fields yet to be implemented
#'
#' @return the object
#' @examples
#' #no example yet
Env <- function(...) {
stop("Constructor not yet implemented for this class.")
#' @param argument the argument name
#' @param value the value to be set to the argument
#' @export
#' @return Env-object
Env <- function(argument, value = NULL) {
return(new("Env", argument = argument, value = value))
}


setMethod(
"docker_key",
signature = signature(obj = "Env"),
definition =
function(obj) {
return("ENV")
}
)

setMethod("docker_arguments",
signature(obj = "Env"),
function(obj) {
stop("The generic function docker_arguments is not implemented for class ",
class(obj))
argument <- methods::slot(obj, "argument")
value <- methods::slot(obj, "value")
if (is.null(value)) {
value = ""
} else {
value = paste0('"', value, '"')
}
return(paste0(argument, "=", value))
})

3 changes: 3 additions & 0 deletions R/Class-Instruction.R
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
# Copyright 2018 Opening Reproducible Research (https://o2r.info)

# put this here because used in many others
setClassUnion("NullOrCharacter", c("NULL", "character"))

#' The Docker Instruction - Class
#'
#' See official documentation at \url{https://docs.docker.com/engine/reference/builder/#format}.
Expand Down
3 changes: 2 additions & 1 deletion R/Class-Label.R
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,8 @@ Label_SessionInfo <-
function(session = sessionInfo(),
as_json = FALSE) {
if (as_json) {
session_string <- rjson::toJSON(session)
# session_string <- rjson::toJSON(session)
session_string <- jsonlite::toJSON(session)
} else{
session_string <- utils::capture.output(session)
session_string <- paste(session_string, collapse = "\n")
Expand Down
3 changes: 2 additions & 1 deletion R/Class-Workdir.R
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,10 @@ setClass("Workdir",
#' @param path The path of the working directory
#'
#' @return the object
#' @export
#'
#' @examples
#' instruction <- containerit:::Workdir("~/myDir/subdir/")
#' instruction <- containerit::Workdir("~/myDir/subdir/")
#' toString(instruction)
Workdir <- function(path) {
methods::new("Workdir",
Expand Down
5 changes: 3 additions & 2 deletions R/LabelSchemaFactory.R
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,8 @@ LabelSchemaFactory <- function() {
}
formals(factory) <- namesArgs

futile.logger::flog.info("According to Label Schema Convention %s you can use the following arguments for constructing metadata labels:",
schema_version, paste(names, collapse = ", "))
futile.logger::flog.info(
"According to Label Schema Convention %s you can use the following arguments for constructing metadata labels: %s",
schema_version, paste(names, collapse = ", "))
return(factory)
}
2 changes: 1 addition & 1 deletion R/defaults.R
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@

.debian_platform <- "linux-x86_64-debian-gcc"
.ubuntu_platform <- "linux-x86_64-ubuntu-gcc"
.supported_platforms <- .debian_platform
.supported_platforms <- c(.debian_platform, .ubuntu_platform)

.init_config_file <- function() {
tryCatch(
Expand Down
Loading