├── .gitignore ├── .travis.yml ├── LICENSE ├── MAINTAINING.md ├── README.md ├── domino ├── DESCRIPTION ├── LICENSE ├── NAMESPACE ├── R │ ├── domino-package.R │ ├── domino.R │ ├── domino.create.R │ ├── domino.debug.R │ ├── domino.diff.R │ ├── domino.download.R │ ├── domino.dump.R │ ├── domino.get.R │ ├── domino.init.R │ ├── domino.login.R │ ├── domino.reset.R │ ├── domino.run.R │ ├── domino.runCommand.R │ ├── domino.snapshot.R │ ├── domino.status.R │ ├── domino.sync.R │ └── domino.upload.R ├── man │ ├── domino-package.Rd │ ├── domino.create.Rd │ ├── domino.debug.Rd │ ├── domino.diff.Rd │ ├── domino.download.Rd │ ├── domino.dump.Rd │ ├── domino.get.Rd │ ├── domino.init.Rd │ ├── domino.login.Rd │ ├── domino.reset.Rd │ ├── domino.run.Rd │ ├── domino.runCommand.Rd │ ├── domino.snapshot.Rd │ ├── domino.status.Rd │ ├── domino.sync.Rd │ └── domino.upload.Rd └── tests │ ├── testthat.R │ └── testthat │ └── test-login.R └── man └── domino-manual-0.3.1.pdf /.gitignore: -------------------------------------------------------------------------------- 1 | domino.log 2 | -------------------------------------------------------------------------------- /.travis.yml: -------------------------------------------------------------------------------- 1 | language: r 2 | warnings_are_errors: false 3 | r_packages: 4 | - testthat 5 | before_install: 6 | - cd domino 7 | - curl -L https://app.dominodatalab.com/download/client/unix > /tmp/domino_cli.sh 8 | - echo -e '\n\n' | /bin/bash /tmp/domino_cli.sh 9 | notifications: 10 | email: false 11 | env: 12 | - secure: "Y4dMYUJXzF51+9BCa4YD1vvmp2883pXgM/JoDEESbYZHs0uYIX41Ih8+0xHpD0nf+h3rKzFPv+wXodX08kDHsun3IBNEnPc0jacNC5CMB56+Ss+FTRZoyQkDVQHlTRuSCXeoQyEC3pn0J4ZlBs8K6Kl83svz7YhfqCTLl7tVoFEoZcZgoaep2YdM5lHbIkSzsWZp8XKMNMZbTLEFjtbvLOKd3t+NeFAjG4yoHbMyAkNQFeMeg3cgUKrIWH3eMlp1g1XbW8vazMQilIRZZYUo5dNQEejQrRziKjvwuuJdJemMDverd2lN8gINRfLsKfzaE26WPrIHFeF4b5TiUEQj2BSyqcbuSAiyGzB9UybP+pvzHxaHrDnJfRpZ57hLUhV3lDOLIMXCon0l1KnxHu8N+fCIk7l+KI23fWs72/uIwK1vMf+0MlgU9bRvw1Z+Oj/lhuqgLTOpSlboP8SjbJN7WAzSBqy5hCnAzVkxN3hvIVMjaGWvnMQu68JLFf54Tntd+o3rRTHkbuL1aGOXqENJJh/2NOm+hoDIfn2Ntr+s4A6Xz2Y9p4NPPAfT5B6F7ZVzwFtBUXlMNM7ODvstjfGhkK3/M6nZaFYB8DZiZUxTGWMGClsHt9E1PY+nszvqQ0ugdID3vQB4CFln4aachaaAxmBIS0DhROH6FMHxK2QCfq4=" 13 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | The MIT License (MIT) 2 | Copyright (c) 2016 Domino Data Lab 3 | 4 | Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: 5 | 6 | The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. 7 | 8 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 9 | -------------------------------------------------------------------------------- /MAINTAINING.md: -------------------------------------------------------------------------------- 1 | 2 | ## Bumping Version number 3 | 4 | Bump the version number in ./domino/DESCRIPTION and ./domino/man/domino-package.Rd 5 | 6 | ## Checking package for CRAN 7 | 8 | Call ```R CMD check domino --as-cran``` 9 | 10 | ## Building package 11 | 12 | Call `R CMD build domino/` 13 | 14 | ## Build documentation 15 | 16 | ``` 17 | R CMD Rd2pdf domino/man/domino-package.Rd 18 | ``` 19 | 20 | ## Useful CRAN links 21 | 22 | - http://cran.r-project.org/web/packages/policies.html 23 | - http://cran.r-project.org/ 24 | - http://cran.r-project.org/doc/manuals/R-exts.html 25 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # Domino R package 2 | 3 | This package provides bindings to interact with the Domino CLI from R. You must have a recent version 4 | of the Domino CLI to use this package. You can find more information on setting up the Domino 5 | CLI in [this support article](http://support.dominodatalab.com/hc/en-us/articles/204856475-Installing-the-Domino-Client-CLI-). 6 | 7 | ## Installation 8 | 9 | The Domino R package can be installed from CRAN directly using the `install.packages` command: 10 | 11 | ```R 12 | install.packages("domino") 13 | ``` 14 | 15 | You can likewise manually obtain a tarball of the package from CRAN and install it directly: 16 | 17 | ``` 18 | R CMD install domino_X.Y.tar.gz 19 | ``` 20 | 21 | ## Usage 22 | 23 | ```R 24 | library(domino) 25 | 26 | # Login with your username and password, specifying whether or not to permit usage reports and the 27 | # hostname of your Domino install. For example: 28 | domino.login("jglodek", "secret_password", FALSE, "https://trial.dominodatalab.com") 29 | 30 | # Get the my-magic-project project from your Domino install 31 | domino.get("my-magic-project") 32 | 33 | # Trigger a run with some parameters 34 | domino.run("main.r", "--secret-arg") 35 | 36 | # Download changes from the domino server. 37 | domino.download() 38 | ``` 39 | 40 | Full documentation and usage information is available in the manuals for various releases: 41 | 42 | * [Release 0.3.0](https://github.com/dominodatalab/r-package/blob/master/man/domino-manual-0.3.0.pdf) 43 | 44 | ## Known Bugs 45 | 46 | If you're getting these warning messages: 47 | 48 | ``` 49 | 1: Setting LC_TIME failed, using "C" 50 | 2: Setting LC_MESSAGES failed, using "C" 51 | 3: Setting LC_MONETARY failed, using "C" 52 | ``` 53 | 54 | check your shell locales with ```locale``` 55 | set locales with ```export LC_ALL=en_US.UTF-8``` in the shell 56 | 57 | ## License 58 | 59 | This library is made available under the MIT License. This is an open-source project of 60 | [Domino Data Lab](https://www.dominodatalab.com). 61 | -------------------------------------------------------------------------------- /domino/DESCRIPTION: -------------------------------------------------------------------------------- 1 | Package: domino 2 | Version: 0.3.1 3 | Type: Package 4 | Title: R Console Bindings for the 'Domino Command-Line Client' 5 | Date: 2017-11-22 6 | Author: Jacek Glodek 7 | Maintainer: Nick Elprin 8 | Copyright: Domino Data Lab Inc. 9 | Description: A wrapper on top of the 'Domino Command-Line Client'. It lets you 10 | run 'Domino' commands (e.g., "run", "upload", "download") directly from your 11 | R environment. Under the hood, it uses R's system function to run the 'Domino' 12 | executable, which must be installed as a prerequisite. 'Domino' is a service 13 | that makes it easy to run your code on scalable hardware, with integrated 14 | version control and collaboration features designed for analytical workflows 15 | (see for more information). 16 | License: MIT + file LICENSE 17 | SystemRequirements: domino (~>1.7.1) 18 | URL: http://www.dominodatalab.com 19 | RoxygenNote: 5.0.1 20 | Suggests: testthat 21 | Imports: utils, grDevices 22 | -------------------------------------------------------------------------------- /domino/LICENSE: -------------------------------------------------------------------------------- 1 | YEAR: 2016 2 | COPYRIGHT HOLDER: Domino Data Lab, Inc 3 | -------------------------------------------------------------------------------- /domino/NAMESPACE: -------------------------------------------------------------------------------- 1 | # Generated by roxygen2: do not edit by hand 2 | 3 | export(domino.create) 4 | export(domino.debug) 5 | export(domino.diff) 6 | export(domino.download) 7 | export(domino.dump) 8 | export(domino.get) 9 | export(domino.init) 10 | export(domino.login) 11 | export(domino.reset) 12 | export(domino.run) 13 | export(domino.runCommand) 14 | export(domino.snapshot) 15 | export(domino.status) 16 | export(domino.sync) 17 | export(domino.upload) 18 | import(grDevices) 19 | import(utils) 20 | -------------------------------------------------------------------------------- /domino/R/domino-package.R: -------------------------------------------------------------------------------- 1 | #' Package: domino \cr 2 | #' Type: Package \cr 3 | #' Version: 0.3-1 \cr 4 | #' Date: 2017-11-22 \cr 5 | #' License: MIT \cr 6 | #' Author: Jacek Glodek jacek@theiterators.com \cr 7 | #' Maintainer: Nick Elprin nick@dominoup.com 8 | #' 9 | #' @title Domino Data Lab R console bindings 10 | #' @name domino-package 11 | #' 12 | #' @description The Domino R package is a wrapper on top of the 13 | #' Domino command-line client. It lets you run Domino commands 14 | #' (e.g., "run", "upload", "download") 15 | #' directly from your R environment. 16 | #' Under the hood, it uses R's system function to run the Domino executable, 17 | #' which must be installed as a prerequisite. 18 | #' 19 | #' @name domino 20 | #' @docType package 21 | #' 22 | #' @keywords domino, package, dominoup 23 | #' @references Domino Data Lab support webpage - http://help.dominodatalab.com/ 24 | #' 25 | #' 26 | #' @examples 27 | #' \dontrun{ 28 | #' ## logins as a given user to the Domino server 29 | #' ## and approves sending error reports to Domino. 30 | #' domino.login("jglodek", "MySecretPassword", TRUE) 31 | #' 32 | #' ## creates new project. 33 | #' domino.create("my-new-project") 34 | #' 35 | #' ## gets existing project from the server. 36 | #' domino.get("jglodek/my-old-project") 37 | #' 38 | #' ## gets existing project from the server. 39 | #' domino.get("my-old-project") 40 | #' 41 | #' ## initializes new domino project in current working directory with a given name. 42 | #' domino.init("other-name") 43 | #' 44 | #' ## downloads run results from Domino server. 45 | #' domino.download() 46 | #' 47 | #' ## uploads project files to Domino server. 48 | #' domino.upload() 49 | #' 50 | #' ## runs main.r in the cloud with given arguments. 51 | #' domino.run("main.r", "other", "console", "arguments") 52 | #' 53 | #' ## shows difference between current version and last uploaded version. 54 | #' domino.diff() 55 | #' 56 | #' ## displays current run's status in the console. 57 | #' domino.status() 58 | #' 59 | #' ## shows debug information 60 | #' domino.debug() 61 | #' 62 | #' ## resets project defined in by current working directory 63 | #' domino.reset() 64 | #' 65 | #' ## runs any of domino client command with given arguments 66 | #' domino.runCommand("run my-file.r", successCallback, "failure message!") 67 | #' 68 | #' } 69 | NULL 70 | -------------------------------------------------------------------------------- /domino/R/domino.R: -------------------------------------------------------------------------------- 1 | 2 | # Environment(package global) variable holding infomation about domino client 3 | # If this gets assigned with true, the commands will be tried to run from default installation path 4 | domino <- new.env() 5 | 6 | #Calls a program with or without stdin 7 | domino.call <- function(cmd, stdInput=FALSE) { 8 | if(domino.notFalse(stdInput)){ 9 | return(system(cmd, input=stdInput)) 10 | } else { 11 | return(system(cmd)) 12 | } 13 | } 14 | 15 | domino.handleCommandNotFound = function(failureMessage){ 16 | stop(paste("Couldn't find domino client in the PATH or in default locations. 17 | Add domino client directory path to PATH environment variable. 18 | If you don't have domino client installed follow instructions on 'http://help.dominodatalab.com/client'. 19 | If you use R-Studio Domino on GNU/Linux through a desktop launcher, add domino path to the .desktop file. 20 | 21 | If you need more help, email support@dominodatalab.com or visit http://help.dominodatalab.com/troubleshooting 22 | 23 | - ", failureMessage), call.=FALSE) 24 | } 25 | 26 | domino.osSpecificPrefixOfDominoCommand <- function() { 27 | os = Sys.info()["sysname"] 28 | if(os == "Darwin") {return("/Applications/domino/")} 29 | else if (os =="Linux") {return("~/domino/")} 30 | else if (os == "Windows") {return("c:\\program files (x86)\\domino\\")} 31 | else { print("Your operating system is not supported by domino R package.")} 32 | } 33 | 34 | domino.notFalse <- function(arg) { 35 | if (arg == FALSE){FALSE} else { TRUE} 36 | } 37 | 38 | domino.OK <- function(){return(0)} 39 | 40 | domino.projectNameWithoutUser <- function(projectName) { 41 | rev(unlist(strsplit(projectName, "/")))[1] 42 | } 43 | 44 | domino.jumpToProjectsWorkingDirectory <- function(projectName) { 45 | setwd(paste("./",domino.projectNameWithoutUser(projectName), sep="")) 46 | print("Changed working directory to new project's directory.") 47 | } 48 | 49 | .is.domino.in.path <- function() { 50 | nzchar(Sys.which("domino")) 51 | } 52 | 53 | .open.rStudio.login.prompt <- function(message){ 54 | if(Sys.getenv("RSTUDIO") != "1"){ 55 | stop("The system is not running in RStudio") 56 | } 57 | 58 | if(!("tools:rstudio" %in% search())){ 59 | stop("Cannot locate RStudio tools") 60 | } 61 | 62 | toolsEnv <- as.environment("tools:rstudio") 63 | rStudioLoginPrompt <- get(".rs.askForPassword", envir=toolsEnv) 64 | 65 | rStudioLoginPrompt(message) 66 | } 67 | 68 | .domino.login.prompt <- function(){ 69 | passwordPromptMessage <- "Enter your Domino password: " 70 | 71 | # if not in rstudio env or the prompt function is not found, 72 | # the function will fail => fallback to readLine 73 | password <- try(.open.rStudio.login.prompt(passwordPromptMessage), silent=T) 74 | 75 | if(inherits(password, "try-error")){ 76 | password <- readline("Enter your Domino password: ") 77 | } 78 | 79 | if(password == ""){ 80 | password <- NULL 81 | } 82 | 83 | password 84 | } 85 | 86 | .onAttach <- function(libname, pkgname) { 87 | domino$command_is_in_the_path <- .is.domino.in.path() 88 | } 89 | -------------------------------------------------------------------------------- /domino/R/domino.create.R: -------------------------------------------------------------------------------- 1 | #' @title domino.create 2 | #' @name domino.create 3 | #' @description Creates Domino project. Changes working directory to new 4 | #' project's one. 5 | #' 6 | #' @param projectName String that will be the name of the new project. 7 | #' 8 | #' @usage domino.create(projectName) 9 | #' 10 | #' @examples 11 | #' \dontrun{ 12 | #' # in directory ./ 13 | #' domino.create("my-new-project") 14 | #' # current working directory is now switched to ./my-new-project and new 15 | #' project is initialized. 16 | #' } 17 | #' @keywords create 18 | #' @export 19 | 20 | domino.create <- function(projectName) { 21 | if(missing(projectName)) { 22 | stop("Missing parameters for create command. Proper usage:domino.create(projectName)", call.=FALSE) 23 | } 24 | cmd = paste("create", projectName) 25 | goToProjectCallback = function(){ 26 | domino.jumpToProjectsWorkingDirectory(projectName) 27 | } 28 | domino.runCommand(cmd, goToProjectCallback, "Creating project failed") 29 | } 30 | -------------------------------------------------------------------------------- /domino/R/domino.debug.R: -------------------------------------------------------------------------------- 1 | #' @title domino.debug 2 | #' @name domino.debug 3 | #' 4 | #' @description Shows Domino debug information. 5 | #' @usage domino.debug() 6 | #' 7 | #' @keywords debug 8 | #' @export 9 | 10 | domino.debug <- function() { 11 | domino.runCommand("--debug") 12 | } 13 | -------------------------------------------------------------------------------- /domino/R/domino.diff.R: -------------------------------------------------------------------------------- 1 | #' @title domino.diff 2 | #' @name domino.diff 3 | #' @description Shows changes between your local version of project's data, 4 | #' and the version uploaded to the Domino servers. 5 | #' 6 | #' @usage domino.diff() 7 | #' @keywords diff 8 | #' 9 | #' @export 10 | 11 | domino.diff <- function() { 12 | domino.runCommand("diff") 13 | } 14 | -------------------------------------------------------------------------------- /domino/R/domino.download.R: -------------------------------------------------------------------------------- 1 | #' @title domino.download 2 | #' @name domino.download 3 | #' 4 | #' @description Downloads the latest Domino run results to the project's folder. 5 | #' 6 | #' @usage domino.download() 7 | #' @keywords download 8 | #' 9 | #' @export 10 | 11 | domino.download <- function() { 12 | domino.runCommand("download", domino.OK, "Downloading project data failed.") 13 | } 14 | -------------------------------------------------------------------------------- /domino/R/domino.dump.R: -------------------------------------------------------------------------------- 1 | #' @title domino.dump 2 | #' @name domino.dump 3 | #' 4 | #' @description run dump command 5 | #' 6 | #' @export 7 | 8 | domino.dump <- function() { 9 | domino.runCommand("dump") 10 | } 11 | -------------------------------------------------------------------------------- /domino/R/domino.get.R: -------------------------------------------------------------------------------- 1 | #' @title domino.get 2 | #' @name domino.get 3 | #' 4 | #' @description Downloads given project data from Domino. 5 | #' Changes working directory to the project's directory. 6 | #' 7 | #' @usage # Usage without username 8 | #' domino.get("projectName") 9 | #' 10 | #' @param projectName String containing project name. It can be prefixed by 11 | #' username and slash. Ex. \code{"jglodek/quick-start"}. 12 | #' 13 | #' @keywords get 14 | #' 15 | #' @examples 16 | #' \dontrun{ 17 | #' # in directory ./ 18 | #' domino.get("my-project-in-the-cloud") 19 | #' # current working directory is now switched to ./my-project-in-the-cloud 20 | #' and the directory 21 | #' # is filled with files from Domino server. 22 | #' 23 | #' # The name of the project is prepended with username 24 | #' domino.get("jglodek/my-project-in-the-cloud") 25 | #' } 26 | #' @export 27 | 28 | 29 | domino.get <- function(projectName) { 30 | if(missing(projectName)) { 31 | stop("Missing parameters for get command. Proper usage:domino.get(projectName)", call.=FALSE) 32 | } 33 | cmd = paste("get", projectName) 34 | goToProjectCallback = function(){ 35 | domino.jumpToProjectsWorkingDirectory(projectName) 36 | } 37 | domino.runCommand(cmd, goToProjectCallback, "Downloading project data failed") 38 | } 39 | -------------------------------------------------------------------------------- /domino/R/domino.init.R: -------------------------------------------------------------------------------- 1 | #' @title domino.init 2 | #' @name domino.init 3 | #' 4 | #' @description Initializes new domino project in current directory. 5 | #' It can also set arbitrary name to the project, 6 | #' even if different from current directory name. 7 | #' 8 | #' @usage 9 | #' # inits a project inside current directory, with given name. 10 | #' # ex. if run in ~/my_project, with "my_name" as a param, 11 | #' # it will create a Domino project called my-param inside ~/my_project directory. 12 | #' domino.init("projectName") 13 | #' 14 | #' @param projectName Project name for the project that will be created in 15 | #' current working directory. 16 | #' 17 | #' @keywords init 18 | #' 19 | #' @examples 20 | #' \dontrun{ 21 | #' # in directory ./ 22 | #' domino.init("my-new-project") 23 | #' # new project with name "my-new-project" is initialized inside current directory. 24 | #' } 25 | #' 26 | #' @export 27 | 28 | 29 | domino.init <- function(projectName) { 30 | if(missing(projectName)) { 31 | stop("Missing parameters for init command. Proper usage:domino.init(projectName)", call.=FALSE) 32 | } 33 | cmd = paste("init", projectName) 34 | domino.runCommand(cmd, domino.OK, "Initializing the project failed") 35 | } 36 | 37 | -------------------------------------------------------------------------------- /domino/R/domino.login.R: -------------------------------------------------------------------------------- 1 | #' @title domino.login 2 | #' @name domino.login 3 | #' 4 | #' @description Logins to Domino server. 5 | #' 6 | #' @usage domino.login(usernameOrEmail, password, 7 | #' approvalForSendingErrorReports=FALSE, host) 8 | #' 9 | #' @param usernameOrEmail Login or e-mail address used when registering for 10 | #' Domino Data Lab account. Ex. \code{"jglodek"} 11 | #' @param password Secret password that was set for authenticating in Domino 12 | #' Data Lab server. If the password is not provided,a password prompt will be 13 | #' shown for interactive sessions. For non-interactive sessions, this arguments 14 | #' is required. Ex. \code{"my-secret-password"} 15 | #' @param approvalForSendingErrorReports Approval for the Domino client to send 16 | #' error reports to Domino in order to improve the product 17 | #' (these will NEVER include any of your data or source code). 18 | #' This defaults to FALSE. Ex. \code{ FALSE } 19 | #' @param host The location of the domino server (this argument is optional) 20 | #' Ex. \code{"https://app.dominodatalab.com"} 21 | #' 22 | #' 23 | #' @keywords login 24 | #' 25 | #' @examples 26 | #' \dontrun{ 27 | #' domino.login("jglodek", TRUE) 28 | #' domino.login("jglodek","my-super-secret-password", TRUE) 29 | #' domino.login("jglodek","my-super-secret-password", TRUE, "https://app.dominodatalab.com") 30 | #' } 31 | #' 32 | #' @export 33 | 34 | domino.login <- function(usernameOrEmail, password, approvalForSendingErrorReports=FALSE, host) { 35 | # If the user did not enter a password open the login prompt 36 | if(missing(password) && !interactive()){ 37 | stop("Missing parameters for login command. Proper usage: domino.login(usernameOrEmail, password, approvalForSendingErrorReports)") 38 | } 39 | 40 | if(missing(usernameOrEmail)) { 41 | if(interactive()){ 42 | stop("Missing parameters for login command. Proper usage: domino.login(usernameOrEmail, approvalForSendingErrorReports, host)") 43 | } else { 44 | stop("Missing parameters for login command. Proper usage: domino.login(usernameOrEmail, password, approvalForSendingErrorReports, host)") 45 | } 46 | } 47 | 48 | if(missing(password)){ 49 | password <- .domino.login.prompt() 50 | } 51 | 52 | if(is.null(password)){ 53 | stop("Missing parameters for login command. Password is required.") 54 | } 55 | 56 | if(approvalForSendingErrorReports){ 57 | approvalChar = "Y" 58 | } else { 59 | approvalChar = "N" 60 | } 61 | 62 | theinput = paste(usernameOrEmail, '\n', password, '\n', approvalChar, sep="") 63 | 64 | loginCommand <- "login" 65 | 66 | if(missing(host)) { 67 | warning("You did not provide a host. Starting in June 2016, the CLI will not automatically determine the host for you.") 68 | } 69 | 70 | if(!missing(host)){ 71 | loginCommand <- paste(loginCommand, host, sep=" ") 72 | } 73 | 74 | domino.runCommand(loginCommand, domino.OK, "Login failed", theinput) 75 | } 76 | -------------------------------------------------------------------------------- /domino/R/domino.reset.R: -------------------------------------------------------------------------------- 1 | #' @title domino.reset 2 | #' @name domino.reset 3 | #' 4 | #' @description Resets Domino project. 5 | #' 6 | #' @usage domino.reset() 7 | #' @keywords reset 8 | #' @export 9 | 10 | domino.reset <- function() { 11 | domino.runCommand("reset") 12 | } 13 | -------------------------------------------------------------------------------- /domino/R/domino.run.R: -------------------------------------------------------------------------------- 1 | #' @title domino.run 2 | #' @name domino.run 3 | #' 4 | #' @description Runs your project on Domino servers with given parameters. 5 | #' 6 | #' @usage domino.run(..., publishApiEndpoint=FALSE) 7 | #' 8 | #' @param ... All the run arguments will be joined together using space character. 9 | #' Ex. \code{domino.run("main.py", "-xvz", "my-file1.csv")} 10 | #' 11 | #' 12 | #' @param publishApiEndpoint Whether or not to republish the project's API endpoint at the end of the run. 13 | #' 14 | #' @examples 15 | #' \dontrun{ 16 | #' my_data <- 4 17 | #' domino.run("main.R","1","my-file1.csv", my_data) 18 | #' #=> Runs "domino main.R 1 my-file1.csv 4" 19 | #' } 20 | #' @export 21 | 22 | domino.run <- function(..., publishApiEndpoint=FALSE) { 23 | if(missing(...)) { 24 | stop("Missing parameters for run command. Example usage:domino.run('main.R', param1, param2, param3, ...)", call.=FALSE) 25 | } 26 | 27 | cmd = "run" 28 | 29 | if(domino.notFalse(publishApiEndpoint)){ 30 | cmd = paste(cmd, "--publish-api-endpoint") 31 | } 32 | 33 | cmd = paste(cmd, ...) 34 | 35 | domino.runCommand(cmd, domino.OK, paste("Running the \"", cmd,"\" command failed", sep="")) 36 | } 37 | -------------------------------------------------------------------------------- /domino/R/domino.runCommand.R: -------------------------------------------------------------------------------- 1 | #' @title domino.runCommand 2 | #' @name domino.runCommand 3 | #' 4 | #' @description Runs domino client command and runs success callback or shows 5 | #' failure message 6 | #' 7 | #' @usage domino.runCommand(commandAndArgs, successCallback = domino.OK, 8 | #' failureMessage = "Executing the command failed", stdInput = FALSE) 9 | #' 10 | #' @param commandAndArgs The \code{commandAndArgs} argument is a string that 11 | #' matches standard domino client's syntax,ex. \code{"get quick-start"} or 12 | #' \code{"download"}. 13 | #' @param successCallback A function that will be called when domino command 14 | #' executes successfuly. Defaults to noop function. 15 | #' @param failureMessage A string representing failure message that should be printed when command fails. Has default value. 16 | #' @param stdInput Internal string data that is pushed to domino client's stdio 17 | #' streams. Default is no stdio stream input. 18 | #' 19 | #' @examples 20 | #' \dontrun{ 21 | #' success <- function() { 22 | #' print("Success!") 23 | #' } 24 | #' domino.runCommand("run main.R 1 2 3",success, "failed to succeed") 25 | #' # Runs command "run main.R 1 2 3" and 26 | #' # calls 'success' function if domino command ends successfuly. 27 | #' # Prints error message - "failed to succeed" if domino command fails. 28 | #' } 29 | #' 30 | #' @keywords command 31 | #' @export 32 | 33 | domino.runCommand <- function(commandAndArgs, successCallback=domino.OK, failureMessage="Executing the command failed", stdInput=FALSE) { 34 | if(domino$command_is_in_the_path) { 35 | cmd = paste("domino --source R", commandAndArgs) 36 | result = domino.call(cmd, stdInput) 37 | 38 | if (result == 0) { 39 | successCallback() 40 | } else { 41 | stop(failureMessage, call.=FALSE) 42 | } 43 | } else { 44 | # Call domino client directly from default path if we know that it's not in the PATH 45 | domino.runCommandFromDefaultPath(commandAndArgs, successCallback, failureMessage, stdInput) 46 | } 47 | } 48 | 49 | 50 | # Runs Domino client command from default installer path 51 | # calls successCallback if command execution succedded 52 | # prints failure message if command execution failed 53 | # prints domino.handleCommandNotFound message when there was no domino client found in default location. 54 | domino.runCommandFromDefaultPath <- function(commandAndArgs, successCallback=domino.OK, failureMessage="Executing the command failed", stdInput=FALSE) { 55 | # handling of command not found 56 | prefix = domino.osSpecificPrefixOfDominoCommand() 57 | # join without spaces, as prefix and domino must stick together and commandAndArgs is already a string with spaces 58 | fixedCmd = paste(prefix, "domino --source R ", commandAndArgs, sep="") 59 | fixedResult = domino.call(fixedCmd, stdInput) 60 | if (fixedResult == 0) { 61 | return(successCallback()) 62 | } 63 | else if (fixedResult == 127) { 64 | domino.handleCommandNotFound(failureMessage) 65 | } 66 | else { 67 | stop(failureMessage, call.=FALSE) 68 | } 69 | } -------------------------------------------------------------------------------- /domino/R/domino.snapshot.R: -------------------------------------------------------------------------------- 1 | #' @title domino.snapshot 2 | #' @name domino.snapshot 3 | #' 4 | #' @description take a snapshot of your command history and workspace. 5 | #' 6 | #' @param commitMessage A committ message to record with you snapshot 7 | #' 8 | #' @import grDevices 9 | #' @import utils 10 | #' 11 | #' @export 12 | 13 | 14 | domino.snapshot <- function(commitMessage) { 15 | if(missing(commitMessage)) { 16 | stop("Please provide a commit message to record with your snapshot", call.=FALSE) 17 | } 18 | savehistory(file="snapshot_command_history.txt") 19 | save.image(file="snapshot_workspace.RData") 20 | 21 | # save a plot 22 | plot_file = "snapshot_plot.png" 23 | if (file.exists(plot_file)) { 24 | file.remove(plot_file) 25 | } 26 | # 1 is the NULL device 27 | if (dev.cur() != 1) { 28 | new_device = dev.copy(png, filename="plot_snapshot.png") 29 | dev.set(new_device) 30 | dev.off() 31 | } 32 | 33 | 34 | domino.upload(commitMessage) 35 | } 36 | -------------------------------------------------------------------------------- /domino/R/domino.status.R: -------------------------------------------------------------------------------- 1 | #' @title domino.status 2 | #' @name domino.status 3 | #' 4 | #' @description Shows status of current Domino project. 5 | #' @usage domino.status(...) 6 | #' 7 | #' @param ... Arguments normally passed to the domino status command. 8 | #' 9 | #' @keywords status 10 | #' @export 11 | 12 | domino.status <- function(...) { 13 | cmd = paste("status", ...) 14 | domino.runCommand(cmd, domino.OK) 15 | } 16 | -------------------------------------------------------------------------------- /domino/R/domino.sync.R: -------------------------------------------------------------------------------- 1 | #' @title domino.sync 2 | #' @name domino.sync 3 | #' 4 | #' @description Synchronizes the local project copy with the server project 5 | #' copy, by running 'download' followed by 'upload'. 6 | #' 7 | #' @usage domino.sync() 8 | #' @keywords sync 9 | #' 10 | #' @export 11 | 12 | domino.sync <- function() { 13 | domino.runCommand("sync", domino.OK, "Synchronizing project data failed.") 14 | } 15 | 16 | -------------------------------------------------------------------------------- /domino/R/domino.upload.R: -------------------------------------------------------------------------------- 1 | #' @title domino.upload 2 | #' @name domino.upload 3 | #' 4 | #' @description Uploads local version of Domino project files to the server. 5 | #' 6 | #' @usage domino.upload(commitMessage) 7 | #' 8 | #' @param commitMessage Commit message for Domino client, explaining changes you 9 | #' did to the project code in recent update. Ex. \code{"updated project files"} 10 | #' 11 | #' @keywords upload 12 | #' @export 13 | 14 | domino.upload <- function(commitMessage) { 15 | if(missing(commitMessage)) { 16 | domino.runCommand("upload", domino.OK, "Uploading project data failed.") 17 | } else { 18 | cmd = paste("upload -m \"", commitMessage, "\"", sep=""); 19 | domino.runCommand(cmd, domino.OK, "Uploading project data failed.") 20 | } 21 | } 22 | 23 | -------------------------------------------------------------------------------- /domino/man/domino-package.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/domino-package.R 3 | \docType{package} 4 | \name{domino-package} 5 | \alias{domino-package} 6 | \title{Domino Data Lab R console bindings} 7 | \description{ 8 | The Domino R package is a wrapper on top of the 9 | Domino command-line client. It lets you run Domino commands 10 | (e.g., "run", "upload", "download") 11 | directly from your R environment. 12 | Under the hood, it uses R's system function to run the Domino executable, 13 | which must be installed as a prerequisite. 14 | } 15 | \details{ 16 | Package: domino \cr 17 | Type: Package \cr 18 | Version: 0.2-7 \cr 19 | Date: 2015-05-27 \cr 20 | License: MIT \cr 21 | Author: Jacek Glodek jacek@theiterators.com \cr 22 | Maintainer: Nick Elprin nick@dominoup.com 23 | } 24 | \examples{ 25 | \dontrun{ 26 | ## logins as a given user to the Domino server 27 | ## and approves sending error reports to Domino. 28 | domino.login("jglodek", "MySecretPassword", TRUE) 29 | 30 | ## creates new project. 31 | domino.create("my-new-project") 32 | 33 | ## gets existing project from the server. 34 | domino.get("jglodek/my-old-project") 35 | 36 | ## gets existing project from the server. 37 | domino.get("my-old-project") 38 | 39 | ## initializes new domino project in current working directory with a given name. 40 | domino.init("other-name") 41 | 42 | ## downloads run results from Domino server. 43 | domino.download() 44 | 45 | ## uploads project files to Domino server. 46 | domino.upload() 47 | 48 | ## runs main.r in the cloud with given arguments. 49 | domino.run("main.r", "other", "console", "arguments") 50 | 51 | ## shows difference between current version and last uploaded version. 52 | domino.diff() 53 | 54 | ## displays current run's status in the console. 55 | domino.status() 56 | 57 | ## shows debug information 58 | domino.debug() 59 | 60 | ## resets project defined in by current working directory 61 | domino.reset() 62 | 63 | ## runs any of domino client command with given arguments 64 | domino.runCommand("run my-file.r", successCallback, "failure message!") 65 | 66 | } 67 | } 68 | \references{ 69 | Domino Data Lab support webpage - http://help.dominodatalab.com/ 70 | } 71 | \keyword{domino,} 72 | \keyword{dominoup} 73 | \keyword{package,} 74 | 75 | -------------------------------------------------------------------------------- /domino/man/domino.create.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/domino.create.R 3 | \name{domino.create} 4 | \alias{domino.create} 5 | \title{domino.create} 6 | \usage{ 7 | domino.create(projectName) 8 | } 9 | \arguments{ 10 | \item{projectName}{String that will be the name of the new project.} 11 | } 12 | \description{ 13 | Creates Domino project. Changes working directory to new 14 | project's one. 15 | } 16 | \examples{ 17 | \dontrun{ 18 | # in directory ./ 19 | domino.create("my-new-project") 20 | # current working directory is now switched to ./my-new-project and new 21 | project is initialized. 22 | } 23 | } 24 | \keyword{create} 25 | 26 | -------------------------------------------------------------------------------- /domino/man/domino.debug.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/domino.debug.R 3 | \name{domino.debug} 4 | \alias{domino.debug} 5 | \title{domino.debug} 6 | \usage{ 7 | domino.debug() 8 | } 9 | \description{ 10 | Shows Domino debug information. 11 | } 12 | \keyword{debug} 13 | 14 | -------------------------------------------------------------------------------- /domino/man/domino.diff.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/domino.diff.R 3 | \name{domino.diff} 4 | \alias{domino.diff} 5 | \title{domino.diff} 6 | \usage{ 7 | domino.diff() 8 | } 9 | \description{ 10 | Shows changes between your local version of project's data, 11 | and the version uploaded to the Domino servers. 12 | } 13 | \keyword{diff} 14 | 15 | -------------------------------------------------------------------------------- /domino/man/domino.download.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/domino.download.R 3 | \name{domino.download} 4 | \alias{domino.download} 5 | \title{domino.download} 6 | \usage{ 7 | domino.download() 8 | } 9 | \description{ 10 | Downloads the latest Domino run results to the project's folder. 11 | } 12 | \keyword{download} 13 | 14 | -------------------------------------------------------------------------------- /domino/man/domino.dump.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/domino.dump.R 3 | \name{domino.dump} 4 | \alias{domino.dump} 5 | \title{domino.dump} 6 | \usage{ 7 | domino.dump() 8 | } 9 | \description{ 10 | run dump command 11 | } 12 | 13 | -------------------------------------------------------------------------------- /domino/man/domino.get.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/domino.get.R 3 | \name{domino.get} 4 | \alias{domino.get} 5 | \title{domino.get} 6 | \usage{ 7 | # Usage without username 8 | domino.get("projectName") 9 | } 10 | \arguments{ 11 | \item{projectName}{String containing project name. It can be prefixed by 12 | username and slash. Ex. \code{"jglodek/quick-start"}.} 13 | } 14 | \description{ 15 | Downloads given project data from Domino. 16 | Changes working directory to the project's directory. 17 | } 18 | \examples{ 19 | \dontrun{ 20 | # in directory ./ 21 | domino.get("my-project-in-the-cloud") 22 | # current working directory is now switched to ./my-project-in-the-cloud 23 | and the directory 24 | # is filled with files from Domino server. 25 | 26 | # The name of the project is prepended with username 27 | domino.get("jglodek/my-project-in-the-cloud") 28 | } 29 | } 30 | \keyword{get} 31 | 32 | -------------------------------------------------------------------------------- /domino/man/domino.init.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/domino.init.R 3 | \name{domino.init} 4 | \alias{domino.init} 5 | \title{domino.init} 6 | \usage{ 7 | # inits a project inside current directory, with given name. 8 | # ex. if run in ~/my_project, with "my_name" as a param, 9 | # it will create a Domino project called my-param inside ~/my_project directory. 10 | domino.init("projectName") 11 | } 12 | \arguments{ 13 | \item{projectName}{Project name for the project that will be created in 14 | current working directory.} 15 | } 16 | \description{ 17 | Initializes new domino project in current directory. 18 | It can also set arbitrary name to the project, 19 | even if different from current directory name. 20 | } 21 | \examples{ 22 | \dontrun{ 23 | # in directory ./ 24 | domino.init("my-new-project") 25 | # new project with name "my-new-project" is initialized inside current directory. 26 | } 27 | 28 | } 29 | \keyword{init} 30 | 31 | -------------------------------------------------------------------------------- /domino/man/domino.login.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/domino.login.R 3 | \name{domino.login} 4 | \alias{domino.login} 5 | \title{domino.login} 6 | \usage{ 7 | domino.login(usernameOrEmail, password, 8 | approvalForSendingErrorReports=FALSE, host) 9 | } 10 | \arguments{ 11 | \item{usernameOrEmail}{Login or e-mail address used when registering for 12 | Domino Data Lab account. Ex. \code{"jglodek"}} 13 | 14 | \item{password}{Secret password that was set for authenticating in Domino 15 | Data Lab server. If the password is not provided,a password prompt will be 16 | shown for interactive sessions. For non-interactive sessions, this arguments 17 | is required. Ex. \code{"my-secret-password"}} 18 | 19 | \item{approvalForSendingErrorReports}{Approval for the Domino client to send 20 | error reports to Domino in order to improve the product 21 | (these will NEVER include any of your data or source code). 22 | This defaults to FALSE. Ex. \code{ FALSE }} 23 | 24 | \item{host}{The location of the domino server (this argument is optional) 25 | Ex. \code{"https://app.dominodatalab.com"}} 26 | } 27 | \description{ 28 | Logins to Domino server. 29 | } 30 | \examples{ 31 | \dontrun{ 32 | domino.login("jglodek", TRUE) 33 | domino.login("jglodek","my-super-secret-password", TRUE) 34 | domino.login("jglodek","my-super-secret-password", TRUE, "https://app.dominodatalab.com") 35 | } 36 | 37 | } 38 | \keyword{login} 39 | 40 | -------------------------------------------------------------------------------- /domino/man/domino.reset.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/domino.reset.R 3 | \name{domino.reset} 4 | \alias{domino.reset} 5 | \title{domino.reset} 6 | \usage{ 7 | domino.reset() 8 | } 9 | \description{ 10 | Resets Domino project. 11 | } 12 | \keyword{reset} 13 | 14 | -------------------------------------------------------------------------------- /domino/man/domino.run.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/domino.run.R 3 | \name{domino.run} 4 | \alias{domino.run} 5 | \title{domino.run} 6 | \usage{ 7 | domino.run(..., publishApiEndpoint=FALSE) 8 | } 9 | \arguments{ 10 | \item{...}{All the run arguments will be joined together using space character. 11 | Ex. \code{domino.run("main.py", "-xvz", "my-file1.csv")}} 12 | 13 | \item{publishApiEndpoint}{Whether or not to republish the project's API endpoint at the end of the run.} 14 | } 15 | \description{ 16 | Runs your project on Domino servers with given parameters. 17 | } 18 | \examples{ 19 | \dontrun{ 20 | my_data <- 4 21 | domino.run("main.R","1","my-file1.csv", my_data) 22 | #=> Runs "domino main.R 1 my-file1.csv 4" 23 | } 24 | } 25 | 26 | -------------------------------------------------------------------------------- /domino/man/domino.runCommand.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/domino.runCommand.R 3 | \name{domino.runCommand} 4 | \alias{domino.runCommand} 5 | \title{domino.runCommand} 6 | \usage{ 7 | domino.runCommand(commandAndArgs, successCallback = domino.OK, 8 | failureMessage = "Executing the command failed", stdInput = FALSE) 9 | } 10 | \arguments{ 11 | \item{commandAndArgs}{The \code{commandAndArgs} argument is a string that 12 | matches standard domino client's syntax,ex. \code{"get quick-start"} or 13 | \code{"download"}.} 14 | 15 | \item{successCallback}{A function that will be called when domino command 16 | executes successfuly. Defaults to noop function.} 17 | 18 | \item{failureMessage}{A string representing failure message that should be printed when command fails. Has default value.} 19 | 20 | \item{stdInput}{Internal string data that is pushed to domino client's stdio 21 | streams. Default is no stdio stream input.} 22 | } 23 | \description{ 24 | Runs domino client command and runs success callback or shows 25 | failure message 26 | } 27 | \examples{ 28 | \dontrun{ 29 | success <- function() { 30 | print("Success!") 31 | } 32 | domino.runCommand("run main.R 1 2 3",success, "failed to succeed") 33 | # Runs command "run main.R 1 2 3" and 34 | # calls 'success' function if domino command ends successfuly. 35 | # Prints error message - "failed to succeed" if domino command fails. 36 | } 37 | 38 | } 39 | \keyword{command} 40 | 41 | -------------------------------------------------------------------------------- /domino/man/domino.snapshot.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/domino.snapshot.R 3 | \name{domino.snapshot} 4 | \alias{domino.snapshot} 5 | \title{domino.snapshot} 6 | \usage{ 7 | domino.snapshot(commitMessage) 8 | } 9 | \arguments{ 10 | \item{commitMessage}{A committ message to record with you snapshot} 11 | } 12 | \description{ 13 | take a snapshot of your command history and workspace. 14 | } 15 | 16 | -------------------------------------------------------------------------------- /domino/man/domino.status.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/domino.status.R 3 | \name{domino.status} 4 | \alias{domino.status} 5 | \title{domino.status} 6 | \usage{ 7 | domino.status(...) 8 | } 9 | \arguments{ 10 | \item{...}{Arguments normally passed to the domino status command.} 11 | } 12 | \description{ 13 | Shows status of current Domino project. 14 | } 15 | \keyword{status} 16 | 17 | -------------------------------------------------------------------------------- /domino/man/domino.sync.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/domino.sync.R 3 | \name{domino.sync} 4 | \alias{domino.sync} 5 | \title{domino.sync} 6 | \usage{ 7 | domino.sync() 8 | } 9 | \description{ 10 | Synchronizes the local project copy with the server project 11 | copy, by running 'download' followed by 'upload'. 12 | } 13 | \keyword{sync} 14 | 15 | -------------------------------------------------------------------------------- /domino/man/domino.upload.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/domino.upload.R 3 | \name{domino.upload} 4 | \alias{domino.upload} 5 | \title{domino.upload} 6 | \usage{ 7 | domino.upload(commitMessage) 8 | } 9 | \arguments{ 10 | \item{commitMessage}{Commit message for Domino client, explaining changes you 11 | did to the project code in recent update. Ex. \code{"updated project files"}} 12 | } 13 | \description{ 14 | Uploads local version of Domino project files to the server. 15 | } 16 | \keyword{upload} 17 | 18 | -------------------------------------------------------------------------------- /domino/tests/testthat.R: -------------------------------------------------------------------------------- 1 | library(testthat) 2 | library(domino) 3 | 4 | if (nchar(Sys.getenv("TESTUSER")) > 0 && nchar(Sys.getenv("TESTUSERPASS")) > 0) { 5 | test_check("domino") 6 | } 7 | -------------------------------------------------------------------------------- /domino/tests/testthat/test-login.R: -------------------------------------------------------------------------------- 1 | library(domino) 2 | context("domino login") 3 | 4 | test_that("The login command works", { 5 | loginResult <- domino.login(Sys.getenv("TESTUSER"), Sys.getenv("TESTUSERPASS"), FALSE, "https://app.dominodatalab.com") 6 | 7 | expect_equal(loginResult, 0) 8 | }) 9 | -------------------------------------------------------------------------------- /man/domino-manual-0.3.1.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/dominodatalab/r-package/d0e7a0498467512e2391a175a9a5b952537dd05a/man/domino-manual-0.3.1.pdf --------------------------------------------------------------------------------