Skip to content
This repository was archived by the owner on Oct 22, 2019. It is now read-only.

Commit 500b1c4

Browse files
authored
Merge pull request #2 from StuartWheater/master
Updated opal management functions and 'Azure Pipelines' files
2 parents 29c5144 + 1190a4f commit 500b1c4

File tree

8 files changed

+171
-47
lines changed

8 files changed

+171
-47
lines changed

DESCRIPTION

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,11 @@
11
Package: dsStatsClient
22
Maintainer: <[email protected]>
33
4-
Version: 4.1.1
4+
Version: 4.1.2
55
License: GPL-3
66
Title: DataSHIELD client site stattistical functions
77
Description: DataSHIELD client site stattistical functions
88
Depends:
99
opal,
1010
dsBaseClient
11+
RoxygenNote: 6.1.1

R/findLoginObjects.R

Lines changed: 31 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -2,32 +2,44 @@
22
#' @title searches for opal login object in the environment
33
#' @description This is an internal function required by a client function
44
#' @details if the user does not set the argument 'datasources', this function
5-
#' is called to searches for opal login objects in the environment. If more than one
6-
#' login object is found a prompt asks the user to choose one and if none is found
7-
#' the process stops.
5+
#' is called to searches for opal login objects in the environment.
6+
#' If only one opal object is found, it automatically becomes the default selection.
7+
#' If more than one is found but one is called 'default.opals' then that is selected.
8+
#' If more than one is found with none is called 'default.opals' the user is
9+
#' told that they can either specify a particular Opal using the 'datasources=' argument
10+
#' that exists in every relevant datashield client-side function or else they
11+
#' can use the 'ds.setDefaultOpals()' function to create a copy of a selected Opal objects
12+
#' which is called 'default.opals' and is then selected by default in future calls to findLoginObjects.
13+
#' If the default Opal object needs to be changed then 'ds.setDefaultOpals()' can be run again.
14+
#' A previous version of 'findLoginObjects()' asked the user to specify which Opal to choose
15+
#' if no default could be identified, but that did not work in all versions of R and so was removed.
816
#' @keywords internal
917
#' @return returns a list of opal login objects or stops the process
10-
#' @author Gaye, A.
18+
#' @author Amadou Gaye, Paul Burton (updated 15/10/18). THIS IS VERSION TO USE 8/2/19.
1119
#'
1220
findLoginObjects <- function(){
1321

1422
findLogin <- getOpals()
23+
24+
if (findLogin$flag == 0){
25+
stop(" Are you logged in to any server? Please provide a valid opal login object! ", call.=FALSE)
26+
}
27+
1528
if(findLogin$flag == 1){
1629
datasources <- findLogin$opals
17-
return (datasources)
18-
}else{
19-
if(findLogin$flag == 0){
20-
stop(" Are you logged in to any server? Please provide a valid opal login object! ", call.=FALSE)
21-
}else{
22-
message(paste0("More than one list of opal login object were found: '", paste(findLogin$opals,collapse="', '"), "'!"))
23-
userInput <- readline("Please enter the name of the login object you want to use: ")
24-
datasources <- eval(parse(text=userInput))
25-
if(class(datasources[[1]]) == 'opal'){
26-
return (datasources)
27-
}else{
28-
stop("End of process: you failed to enter a valid login object", call.=FALSE)
29-
}
30-
}
30+
return(datasources)
3131
}
3232

33-
}
33+
if(findLogin$flag > 1) {
34+
for(j in 1:findLogin$flag){
35+
if(findLogin$opals[[j]]=="default.opals"){
36+
datasources<-eval(parse(text=findLogin$opals[[j]]),envir=0)
37+
return(datasources)
38+
}
39+
}
40+
message(paste0(" More than one list of opal login objects was found with no default specified:\n '", paste(findLogin$opals.list,collapse="', '"), "'!!"))
41+
stop(" \n\n Please specify a default Opal object using the following call syntax:\n ds.setDefaultOpals(opal.name='name of opal in inverted commas')\n\n",call.=FALSE)
42+
}
43+
44+
}
45+
#findLoginObjects

R/getOpals.R

Lines changed: 13 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -6,9 +6,9 @@
66
#' This way no matter what the user calls his opal login object it will be captured.
77
#' @keywords internal
88
#' @return a list of opal object obtained after login into the servers
9-
#' @author Gaye,A.
10-
#'
9+
#' @author Amadou Gaye, Paul Burton (updated 15/10/18). THIS IS VERSION TO USE 8/2/19.
1110
getOpals <- function(){
11+
1212
# get the names of all the objects in the current work environment
1313
objs <- ls(name=.GlobalEnv)
1414

@@ -24,28 +24,31 @@ getOpals <- function(){
2424
list2check <- eval(parse(text=objs[i]))
2525
if(length(list2check) > 0){
2626
cl2 <- class(list2check[[1]])
27-
if(cl2 == 'opal'){
28-
cnt <- cnt + 1
29-
opalist[[cnt]] <- objs[i]
30-
flag <- 1
27+
for(s in 1:length(cl2)){
28+
if(cl2[s] == 'opal'){
29+
cnt <- cnt + 1
30+
opalist[[cnt]] <- objs[i]
31+
flag <- 1
32+
}
3133
}
3234
}
3335
}
3436
}
3537
if(flag == 1){
3638
if(length(opalist) > 1){
3739
flag <- 2
38-
return(list("flag"=flag, "opals"=unlist(opalist)))
40+
return(list("flag"=flag, "opals"=unlist(opalist), "opals.list"=unlist(opalist)))
3941
}else{
4042
pp <- opalist[[1]]
4143
opals <- eval(parse(text=pp))
42-
return(list("flag"=flag, "opals"=opals))
44+
return(list("flag"=flag, "opals"=opals, "opals.list"=unlist(opalist)))
4345
}
4446
}else{
45-
return(list("flag"=flag, "opals"=NULL))
47+
return(list("flag"=flag, "opals"=NULL, "opals.list"=NULL))
4648
}
4749
}else{
48-
return(list("flag"=flag, "opals"=NULL))
50+
return(list("flag"=flag, "opals"=NULL, "opals.list"=NULL))
4951
}
5052

5153
}
54+
#getOpals

azure-pipelines.yml

Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,56 @@
1+
pool:
2+
vmImage: 'Ubuntu 16.04'
3+
4+
steps:
5+
- bash: |
6+
sudo service mysql stop
7+
sudo apt-get update
8+
sudo apt-get remove --purge mysql-client mysql-server mysql-common -y
9+
sudo apt-get purge mysql-client mysql-server mysql-common -y
10+
sudo apt-get autoremove -y
11+
sudo apt-get autoclean -y
12+
sudo rm -rf /var/lib/mysql/
13+
14+
wget -nv https://apt.puppetlabs.com/puppet5-release-xenial.deb
15+
sudo dpkg -i puppet5-release-xenial.deb
16+
sudo apt-get install -qq -f
17+
sudo apt-get update
18+
sudo rm -f puppet5-release-xenial.deb
19+
20+
sudo apt-get install puppet-agent -y
21+
22+
sudo apt-get clean all
23+
sudo apt-get update
24+
sudo apt-get autoremove -y
25+
sudo apt-get clean all
26+
27+
sudo /opt/puppetlabs/puppet/bin/gem install r10k
28+
29+
echo -n "Puppet version: "
30+
/opt/puppetlabs/bin/puppet --version
31+
/opt/puppetlabs/puppet/bin/r10k version
32+
33+
git clone -b ubuntu16 https://github.com/datashield/datashield-infrastructure.git ../datashield-infrastructure
34+
pushd ../datashield-infrastructure/puppet/environments/datashield_azurepipelines && sudo /opt/puppetlabs/puppet/bin/r10k puppetfile install && popd
35+
sudo /opt/puppetlabs/bin/puppet apply azure-pipelines_site.pp --environment datashield_azurepipelines --environmentpath ../datashield-infrastructure/puppet/environments
36+
displayName: 'Install DataSHIELD server'
37+
38+
- bash: |
39+
sudo apt-key adv --keyserver keyserver.ubuntu.com --recv-keys E298A3A825C0D65DFD57CBB651716619E084DAB9
40+
sudo add-apt-repository 'deb [arch=amd64,i386] https://cran.rstudio.com/bin/linux/ubuntu xenial/'
41+
sudo apt-get update
42+
sudo apt-get install -qq libxml2-dev libcurl4-openssl-dev libssl-dev -y
43+
sudo apt-get install -qq r-base -y
44+
sudo R -e "install.packages('devtools', dependencies=TRUE)"
45+
displayName: 'Install R client'
46+
47+
- bash: |
48+
R -e "library('devtools'); devtools::check(args = c('--no-examples'))" | tee azure-pipelines_check.Rout
49+
grep --quiet "0 error" azure-pipelines_check.Rout
50+
displayName: 'Devtools checks'
51+
condition: always()
52+
53+
- bash: |
54+
./checkDocumentationUpdated.sh
55+
displayName: 'Check documents'
56+
condition: always()

azure-pipelines_site.pp

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
# Datashield for Azure Pipelines testing.
2+
#
3+
# Install mysql and mongodb, include test data but don't install the firewall.
4+
# This is an example please change to meet the needs of your install. Consider changing any passwords in this file!
5+
#
6+
7+
class { ::datashield:
8+
test_data => true, # Install the test data
9+
firewall => false, # Do not install the firewall
10+
mysql => true, # Install mysql server
11+
mongodb => true, # Install mongodb server
12+
remote_mongodb => false, # There is not a remote mongodb server
13+
remote_mysql => false, # There is not a remote mysql server
14+
15+
dsbase_githubusername => 'datashield',
16+
dsbase_ref => 'master',
17+
dsstats_githubusername => 'datashield',
18+
dsstats_ref => 'master',
19+
dsgraphics_githubusername => 'datashield',
20+
dsgraphics_ref => 'master',
21+
dsmodelling_githubusername => 'datashield',
22+
dsmodelling_ref => 'master'
23+
}

checkDocumentationUpdated.sh

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
#!/usr/bin/env bash
2+
# Check if the documentation in the man directory matches what should be in it
3+
# based on what is in the headers of the R scripts.
4+
echo "Starting documentation check."
5+
6+
# Concatenate all the files in the man dir into one long string and md5sum it.
7+
orig_sum=$(find man -type f | sort -u | xargs cat | md5sum)
8+
9+
# Rebuild the documentation.
10+
R -e "devtools::document()"
11+
12+
# Concatenate all the files in the man dir into one long string and md5sum it.
13+
new_sum=$(find man -type f | sort -u | xargs cat | md5sum)
14+
15+
# echo $orig_sum
16+
# echo $new_sum
17+
18+
if [ "$orig_sum" != "$new_sum" ]; then
19+
echo "Your committed manual files (man/*.Rd) are out of sync with the documentation in the R files."
20+
echo "Run roxygenise() locally then commit again."
21+
exit 1
22+
else
23+
echo "Documentation up to date."
24+
exit 0
25+
fi

man/findLoginObjects.Rd

Lines changed: 15 additions & 9 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

man/getOpals.Rd

Lines changed: 6 additions & 8 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)