-
Notifications
You must be signed in to change notification settings - Fork 7
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Saving progress on charts / conda environment creation
- Loading branch information
Showing
15 changed files
with
223 additions
and
228 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,82 @@ | ||
# Copyright (c) 2024 Apex Resource Management Solution Ltd. (ApexRMS). All rights reserved. | ||
# MIT License | ||
#' @include AAAClassDefinitions.R | ||
NULL | ||
|
||
#' Create SyncroSim package conda environments | ||
#' | ||
#' Creates the conda environment for the specified SyncroSim package(s). | ||
#' | ||
#' @param pkgs character or list of characters. | ||
#' @param session \code{\link{Session}} object or character (i.e. filepath to a | ||
#' session). If \code{NULL}, \code{session()} will be used | ||
#' | ||
#' @return | ||
#' Invisibly returns \code{TRUE} upon success (i.e.successful creation of the | ||
#' conda environment(s)) or \code{FALSE} upon failure. | ||
#' | ||
#' @examples | ||
#' \dontrun{ | ||
#' # Set up a SyncroSim Session | ||
#' mySession <- session() | ||
#' | ||
#' # Create the conda environment for helloworldConda package | ||
#' condaFilepath(pkgs = "helloworldConda", mySession) | ||
#' } | ||
#' | ||
#' @export | ||
setGeneric("createCondaEnv", function(pkgs, session) standardGeneric("createCondaEnv")) | ||
|
||
#' @rdname createCondaEnv | ||
setMethod("createCondaEnv", signature(session = "character"), function(pkgs, session) { | ||
return(SyncroSimNotFound(session)) | ||
}) | ||
|
||
#' @rdname createCondaEnv | ||
setMethod("createCondaEnv", signature(session = "missingOrNULL"), function(pkgs, session) { | ||
session <- .session() | ||
return(createCondaEnv(session)) | ||
}) | ||
|
||
#' @rdname createCondaEnv | ||
setMethod("createCondaEnv", signature(session = "missingOrNULLOrChar"), function(pkgs, session=NULL){ | ||
|
||
if (is(session, "character")) { | ||
session <- .session(session) | ||
} else { | ||
session <- .session() | ||
} | ||
|
||
if (is(session, "character") && is(session, SyncroSimNotFound(warn = FALSE))) { | ||
return(SyncroSimNotFound()) | ||
} | ||
|
||
return(createCondaEnv(pkgs, session)) | ||
}) | ||
|
||
#' @rdname createCondaEnv | ||
setMethod("createCondaEnv", signature(session = "Session"), function(pkgs, session) { | ||
|
||
message("Creating Conda environments. Please wait...") | ||
|
||
# Check if environment needs to be created, create if doesn't exist yet | ||
for (package in pkgs) { | ||
tt <- command(list(conda = NULL, createenv = NULL, pkg = package), session) | ||
if (length(tt) > 1){ | ||
if (!grepl("Creating Conda environments", tt[1], fixed = TRUE)){ | ||
stop(tt[1]) | ||
} | ||
} else { | ||
if (grepl("No Conda installation found", tt, fixed = TRUE)) { | ||
errorMessage = "Conda must be installed to use Conda environments. See ?installConda for details." | ||
} else { | ||
errorMessage = tt | ||
} | ||
|
||
message(errorMessage) | ||
return(invisible(TRUE)) | ||
} | ||
} | ||
|
||
return(invisible(TRUE)) | ||
}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,64 @@ | ||
# Copyright (c) 2024 Apex Resource Management Solution Ltd. (ApexRMS). All rights reserved. | ||
# MIT License | ||
#' @include AAAClassDefinitions.R | ||
NULL | ||
|
||
#' Installs Miniconda | ||
#' | ||
#' This function installs Miniconda to the default installation path | ||
#' within the SyncroSim installation folder. If you already have Conda | ||
#' installed in the non-default location, you can point SyncroSim towards | ||
#' that installation using the \code{\link{condaFilepath}} function. | ||
#' | ||
#' @param session \code{\link{Session}} object. If \code{NULL} (default), | ||
#' \code{session()} will be used | ||
#' | ||
#' @return | ||
#' Invisibly returns \code{TRUE} upon success (i.e.successful | ||
#' install) and \code{FALSE} upon failure. | ||
#' | ||
#' @examples | ||
#' \dontrun{ | ||
#' # Install Conda for the default SyncroSim session | ||
#' installConda() | ||
#' } | ||
#' | ||
#' @export | ||
setGeneric("installConda", function(session) standardGeneric("installConda")) | ||
|
||
#' @rdname installConda | ||
setMethod("installConda", signature(session = "character"), function(session) { | ||
return(SyncroSimNotFound(session)) | ||
}) | ||
|
||
#' @rdname installConda | ||
setMethod("installConda", signature(session = "missingOrNULL"), function(session) { | ||
session <- .session() | ||
return(installConda(session)) | ||
}) | ||
|
||
#' @rdname installConda | ||
setMethod("installConda", signature(session = "Session"), function(session) { | ||
|
||
success <- FALSE | ||
message("Setting Conda filepath to the default installation.") | ||
args <- list(conda = NULL, install = NULL) | ||
|
||
message("Running Conda Installer. Please wait...") | ||
if (is.null(session)){ | ||
session <- .session() | ||
} | ||
tt <- command(args, session) | ||
|
||
if (tt[1] == "Conda already installed at that location"){ | ||
success <- FALSE | ||
tt <- "Conda already installed" | ||
} else if (tt[3] == "Saved") { | ||
success <- TRUE | ||
tt <- paste0("Miniconda successfully installed") | ||
} | ||
|
||
message(tt) | ||
|
||
return(invisible(success)) | ||
}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.