1
- # ' Creates a credentials file for rAzureBatch package authentication
2
- # '
3
- # ' @param fileName Credentials file name
4
- # ' @param ... Further named parameters
5
- # ' \itemize{
6
- # ' \item{"batchAccount"}: {Batch account name for Batch Service authentication.}
7
- # ' \item{"batchKey"}: {Batch account key for signing REST signatures.}
8
- # ' \item{"batchUrl"}: {Batch service url for account.}
9
- # ' \item{"storageAccount"}: {Storage account for storing output results.}
10
- # ' \item{"storageKey"}: {Storage account key for storage service authentication.}
11
- # '}
12
- # ' @return The request to the Batch service was successful.
13
- # ' @examples {
14
- # ' generateCredentialsConfig("test_config.json")
15
- # ' generateCredentialsConfig("test_config.json", batchAccount = "testbatchaccount",
16
- # ' batchKey = "test_batch_account_key", batchUrl = "http://testbatchaccount.azure.com",
17
- # ' storageAccount = "teststorageaccount", storageKey = "test_storage_account_key")
18
- # ' }
19
- # ' @export
20
- generateCredentialsConfig <- function (fileName , ... ) {
21
- args <- list (... )
22
-
23
- batchAccount <-
24
- ifelse(is.null(args $ batchAccount ),
25
- " batch_account_name" ,
26
- args $ batchAccount )
27
- batchKey <-
28
- ifelse(is.null(args $ batchKey ), " batch_account_key" , args $ batchKey )
29
- batchUrl <-
30
- ifelse(is.null(args $ batchUrl ), " batch_account_url" , args $ batchUrl )
31
-
32
- storageName <-
33
- ifelse(is.null(args $ storageAccount ),
34
- " storage_account_name" ,
35
- args $ storageAccount )
36
- storageKey <-
37
- ifelse(is.null(args $ storageKey ),
38
- " storage_account_key" ,
39
- args $ storageKey )
40
-
41
- if (! file.exists(paste0(getwd(), " /" , fileName ))) {
42
- config <- list (
43
- batchAccount = list (
44
- name = batchAccount ,
45
- key = batchKey ,
46
- url = batchUrl
47
- ),
48
- storageAccount = list (name = storageName ,
49
- key = storageKey )
50
- )
51
-
52
- configJson <-
53
- jsonlite :: toJSON(config , auto_unbox = TRUE , pretty = TRUE )
54
- write(configJson , file = paste0(getwd(), " /" , fileName ))
55
-
56
- print(
57
- sprintf(
58
- " A config file has been generated %s. Please enter your Batch credentials." ,
59
- paste0(getwd(), " /" , fileName )
60
- )
61
- )
62
- }
63
- }
64
-
65
1
# ' Creates a configuration file for the user's cluster setup.
66
2
# '
67
3
# ' @param fileName Cluster settings file name
@@ -90,8 +26,7 @@ generateClusterConfig <- function(fileName) {
90
26
rPackages = list (
91
27
cran = vector(),
92
28
github = vector(),
93
- bioconductor = vector(),
94
- githubAuthenticationToken = " "
29
+ bioconductor = vector()
95
30
),
96
31
commandLine = vector()
97
32
)
@@ -114,7 +49,7 @@ generateClusterConfig <- function(fileName) {
114
49
115
50
# ' Creates an Azure cloud-enabled cluster.
116
51
# '
117
- # ' @param clusterSetting Cluster configuration's file name
52
+ # ' @param clusterSetting Cluster configuration object or file name
118
53
# ' @param fullName A boolean flag for checking the file full name
119
54
# ' @param wait A boolean flag to wait for all nodes to boot up
120
55
# ' @param resourceFiles A list of files that Batch will download to the compute node before running the command line
@@ -130,12 +65,21 @@ makeCluster <-
130
65
fullName = FALSE ,
131
66
wait = TRUE ,
132
67
resourceFiles = list ()) {
133
- if (fullName ) {
134
- poolConfig <- rjson :: fromJSON(file = paste0(clusterSetting ))
135
- }
136
- else {
137
- poolConfig <-
138
- rjson :: fromJSON(file = paste0(getwd(), " /" , clusterSetting ))
68
+ if (class(clusterSetting ) == " character" ) {
69
+ if (fullName ) {
70
+ poolConfig <- rjson :: fromJSON(file = paste0(clusterSetting ))
71
+ }
72
+ else {
73
+ poolConfig <-
74
+ rjson :: fromJSON(file = paste0(getwd(), " /" , clusterSetting ))
75
+ }
76
+ } else if (class(clusterSetting ) == " list" ) {
77
+ poolConfig <- clusterSetting
78
+ } else {
79
+ stop(sprintf(
80
+ " cluster setting type is not supported: %s\n " ,
81
+ class(clusterSetting )
82
+ ))
139
83
}
140
84
141
85
config <- getOption(" az_config" )
@@ -199,11 +143,13 @@ makeCluster <-
199
143
containerInstallCommand <- c(
200
144
paste0(
201
145
" wget https://raw.githubusercontent.com/Azure/doAzureParallel/" ,
202
- " master/inst/startup/cluster_setup.sh" ),
146
+ " master/inst/startup/cluster_setup.sh"
147
+ ),
203
148
" chmod u+x cluster_setup.sh" ,
204
149
paste0(
205
150
" wget https://raw.githubusercontent.com/Azure/doAzureParallel/" ,
206
- " master/inst/startup/install_bioconductor.R" ),
151
+ " master/inst/startup/install_bioconductor.R"
152
+ ),
207
153
" chmod u+x install_bioconductor.R" ,
208
154
installAndStartContainerCommand
209
155
)
@@ -220,14 +166,13 @@ makeCluster <-
220
166
}
221
167
222
168
environmentSettings <- NULL
223
- if (! is.null(poolConfig $ rPackages ) &&
224
- ! is.null(poolConfig $ rPackages $ githubAuthenticationToken ) &&
225
- poolConfig $ rPackages $ githubAuthenticationToken != " " ) {
169
+ if (! is.null(config $ githubAuthenticationToken ) &&
170
+ config $ githubAuthenticationToken != " " ) {
226
171
environmentSettings <-
227
172
list (
228
173
list (
229
174
name = " GITHUB_PAT" ,
230
- value = poolConfig $ rPackages $ githubAuthenticationToken
175
+ value = config $ githubAuthenticationToken
231
176
)
232
177
)
233
178
}
@@ -375,24 +320,7 @@ makeCluster <-
375
320
stopCluster <- function (cluster ) {
376
321
rAzureBatch :: deletePool(cluster $ poolId )
377
322
378
- print(sprintf(" Your %s cluster has been destroyed." , cluster $ poolId ))
379
- }
380
-
381
- # ' Set azure credentials to R session.
382
- # '
383
- # ' @param fileName The cluster configuration that was created in \code{makeCluster}
384
- # '
385
- # ' @export
386
- setCredentials <- function (fileName = " az_config.json" ) {
387
- if (file.exists(fileName )) {
388
- config <- rjson :: fromJSON(file = paste0(fileName ))
389
- }
390
- else {
391
- config <- rjson :: fromJSON(file = paste0(getwd(), " /" , fileName ))
392
- }
393
-
394
- options(" az_config" = config )
395
- print(" Your azure credentials have been set." )
323
+ print(sprintf(" Your %s cluster is being deleted." , cluster $ poolId ))
396
324
}
397
325
398
326
getPoolWorkers <- function (poolId , ... ) {
0 commit comments