This repository has been archived by the owner on Oct 12, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 51
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Added custom package script * Added feature custom download * Fixed typo * Fixed directory for installation * Fixed full folder directory * Add dependencies and fix pattern * Fix pattern not found * Added repo * Switching to devtools * Fixing devtools install with directory * Fix in for merger.R * Working cluster custom packages * Removed printed statements * Working on custom docs * Custom packages sample docs * Fixed typo in azure files typo * Fixed typos based on PR
- Loading branch information
Showing
12 changed files
with
194 additions
and
27 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
args <- commandArgs(trailingOnly = TRUE) | ||
|
||
sharedPackageDirectory <- file.path( | ||
Sys.getenv("AZ_BATCH_NODE_SHARED_DIR"), | ||
"R", | ||
"packages") | ||
|
||
tempDir <- file.path( | ||
Sys.getenv("AZ_BATCH_NODE_STARTUP_DIR"), | ||
"tmp") | ||
|
||
.libPaths(c(sharedPackageDirectory, .libPaths())) | ||
|
||
pattern <- NULL | ||
if (length(args) > 1) { | ||
if (!is.null(args[2])) { | ||
pattern <- args[2] | ||
} | ||
} | ||
|
||
devtoolsPackage <- "devtools" | ||
if (!require(devtoolsPackage, character.only = TRUE)) { | ||
install.packages(devtoolsPackage) | ||
require(devtoolsPackage, character.only = TRUE) | ||
} | ||
|
||
packageDirs <- list.files( | ||
path = tempDir, | ||
full.names = TRUE, | ||
recursive = FALSE) | ||
|
||
for (i in 1:length(packageDirs)) { | ||
print("Package Directories") | ||
print(packageDirs[i]) | ||
|
||
devtools::install(packageDirs[i], | ||
args = c( | ||
paste0( | ||
"--library=", | ||
"'", | ||
sharedPackageDirectory, | ||
"'"))) | ||
|
||
print("Package Directories Completed") | ||
} | ||
|
||
unlink( | ||
tempDir, | ||
recursive = 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
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
2 changes: 1 addition & 1 deletion
2
samples/package_management/bioconductor.r → ...ge_management/bioconductor/bioconductor.r
100755 → 100644
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
File renamed without changes.
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,32 @@ | ||
## Installing Custom Packages | ||
doAzureParallel supports custom package installation in the cluster. Custom packages are R packages that cannot be hosted on Github or be built on a docker image. The recommended approach for custom packages is building them from source and uploading them to an Azure File Share. | ||
|
||
Note: If the package requires a compilation such as apt-get installations, users will be required | ||
to build their own containers. | ||
|
||
### Building Package from Source in RStudio | ||
1. Open *RStudio* | ||
2. Go to *Build* on the navigation bar | ||
3. Go to *Build From Source* | ||
|
||
### Uploading Custom Package to Azure Files | ||
For detailed steps on uploading files to Azure Files in the Portal can be found | ||
[here](https://docs.microsoft.com/en-us/azure/storage/files/storage-how-to-use-files-portal) | ||
|
||
### Notes | ||
1) In order to build the custom packages' dependencies, we need to untar the R packages and build them within their directories. By default, we will build custom packages in the *$AZ_BATCH_NODE_SHARED_DIR/tmp* directory. | ||
2) By default, the custom package cluster configuration file will install any packages that are a *.tar.gz file in the file share. If users want to specify R packages, they must change this line in the cluster configuration file. | ||
|
||
Finds files that end with *.tar.gz in the current Azure File Share directory | ||
``` json | ||
{ | ||
... | ||
"commandLine": [ | ||
... | ||
"mkdir $AZ_BATCH_NODE_STARTUP_DIR/tmp | for i in `ls $AZ_BATCH_NODE_SHARED_DIR/data/*.tar.gz | awk '{print $NF}'`; do tar -xvf $i -C $AZ_BATCH_NODE_STARTUP_DIR/tmp; done", | ||
... | ||
] | ||
} | ||
``` | ||
3) For more information on using Azure Files on Batch, follow our other [sample](./azure_files/readme.md) of using Azure Files | ||
4) Replace your Storage Account name, endpoint and key in the cluster configuration file |
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,24 @@ | ||
#Please see documentation at docs/20-package-management.md for more details on package management. | ||
|
||
# import the doAzureParallel library and its dependencies | ||
library(doAzureParallel) | ||
|
||
# set your credentials | ||
doAzureParallel::setCredentials("credentials.json") | ||
|
||
# Create your cluster if not exist | ||
cluster <- doAzureParallel::makeCluster("custom_packages_cluster.json") | ||
|
||
# register your parallel backend | ||
doAzureParallel::registerDoAzureParallel(cluster) | ||
|
||
# check that your workers are up | ||
doAzureParallel::getDoParWorkers() | ||
|
||
summary <- foreach(i = 1:1, .packages = c("customR")) %dopar% { | ||
sessionInfo() | ||
# Method from customR | ||
hello() | ||
} | ||
|
||
summary |
27 changes: 27 additions & 0 deletions
27
samples/package_management/custom/custom_packages_cluster.json
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,27 @@ | ||
{ | ||
"name": "custom-package-pool", | ||
"vmSize": "Standard_D2_v2", | ||
"maxTasksPerNode": 1, | ||
"poolSize": { | ||
"dedicatedNodes": { | ||
"min": 2, | ||
"max": 2 | ||
}, | ||
"lowPriorityNodes": { | ||
"min": 0, | ||
"max": 0 | ||
}, | ||
"autoscaleFormula": "QUEUE" | ||
}, | ||
"rPackages": { | ||
"cran": [], | ||
"github": [], | ||
"bioconductor": [] | ||
}, | ||
"commandLine": [ | ||
"mkdir /mnt/batch/tasks/shared/data", | ||
"mount -t cifs //<Account Name>.file.core.windows.net/<File Share> /mnt/batch/tasks/shared/data -o vers=3.0,username=<Account Name>,password=<Account Key>,dir_mode=0777,file_mode=0777,sec=ntlmssp", | ||
"mkdir $AZ_BATCH_NODE_STARTUP_DIR/tmp | for i in `ls $AZ_BATCH_NODE_SHARED_DIR/data/*.tar.gz | awk '{print $NF}'`; do tar -xvf $i -C $AZ_BATCH_NODE_STARTUP_DIR/tmp; done", | ||
"docker run --rm -v $AZ_BATCH_NODE_ROOT_DIR:$AZ_BATCH_NODE_ROOT_DIR -e AZ_BATCH_NODE_SHARED_DIR=$AZ_BATCH_NODE_SHARED_DIR -e AZ_BATCH_NODE_ROOT_DIR=$AZ_BATCH_NODE_ROOT_DIR -e AZ_BATCH_NODE_STARTUP_DIR=$AZ_BATCH_NODE_STARTUP_DIR rocker/tidyverse:latest Rscript --no-save --no-environ --no-restore --no-site-file --verbose $AZ_BATCH_NODE_STARTUP_DIR/wd/install_custom.R /mnt/batch/tasks/shared/data" | ||
] | ||
} |