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

Commit

Permalink
Merge pull request #2 from StuartWheater/master
Browse files Browse the repository at this point in the history
Updated opal management functions and 'Azure Pipelines' files
  • Loading branch information
OllyButters authored Mar 9, 2019
2 parents 29c5144 + 1190a4f commit 500b1c4
Show file tree
Hide file tree
Showing 8 changed files with 171 additions and 47 deletions.
3 changes: 2 additions & 1 deletion DESCRIPTION
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
Package: dsStatsClient
Maintainer: <[email protected]>
Author: <[email protected]>
Version: 4.1.1
Version: 4.1.2
License: GPL-3
Title: DataSHIELD client site stattistical functions
Description: DataSHIELD client site stattistical functions
Depends:
opal,
dsBaseClient
RoxygenNote: 6.1.1
50 changes: 31 additions & 19 deletions R/findLoginObjects.R
Original file line number Diff line number Diff line change
Expand Up @@ -2,32 +2,44 @@
#' @title searches for opal login object in the environment
#' @description This is an internal function required by a client function
#' @details if the user does not set the argument 'datasources', this function
#' is called to searches for opal login objects in the environment. If more than one
#' login object is found a prompt asks the user to choose one and if none is found
#' the process stops.
#' is called to searches for opal login objects in the environment.
#' If only one opal object is found, it automatically becomes the default selection.
#' If more than one is found but one is called 'default.opals' then that is selected.
#' If more than one is found with none is called 'default.opals' the user is
#' told that they can either specify a particular Opal using the 'datasources=' argument
#' that exists in every relevant datashield client-side function or else they
#' can use the 'ds.setDefaultOpals()' function to create a copy of a selected Opal objects
#' which is called 'default.opals' and is then selected by default in future calls to findLoginObjects.
#' If the default Opal object needs to be changed then 'ds.setDefaultOpals()' can be run again.
#' A previous version of 'findLoginObjects()' asked the user to specify which Opal to choose
#' if no default could be identified, but that did not work in all versions of R and so was removed.
#' @keywords internal
#' @return returns a list of opal login objects or stops the process
#' @author Gaye, A.
#' @author Amadou Gaye, Paul Burton (updated 15/10/18). THIS IS VERSION TO USE 8/2/19.
#'
findLoginObjects <- function(){

findLogin <- getOpals()

if (findLogin$flag == 0){
stop(" Are you logged in to any server? Please provide a valid opal login object! ", call.=FALSE)
}

if(findLogin$flag == 1){
datasources <- findLogin$opals
return (datasources)
}else{
if(findLogin$flag == 0){
stop(" Are you logged in to any server? Please provide a valid opal login object! ", call.=FALSE)
}else{
message(paste0("More than one list of opal login object were found: '", paste(findLogin$opals,collapse="', '"), "'!"))
userInput <- readline("Please enter the name of the login object you want to use: ")
datasources <- eval(parse(text=userInput))
if(class(datasources[[1]]) == 'opal'){
return (datasources)
}else{
stop("End of process: you failed to enter a valid login object", call.=FALSE)
}
}
return(datasources)
}

}
if(findLogin$flag > 1) {
for(j in 1:findLogin$flag){
if(findLogin$opals[[j]]=="default.opals"){
datasources<-eval(parse(text=findLogin$opals[[j]]),envir=0)
return(datasources)
}
}
message(paste0(" More than one list of opal login objects was found with no default specified:\n '", paste(findLogin$opals.list,collapse="', '"), "'!!"))
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)
}

}
#findLoginObjects
23 changes: 13 additions & 10 deletions R/getOpals.R
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,9 @@
#' This way no matter what the user calls his opal login object it will be captured.
#' @keywords internal
#' @return a list of opal object obtained after login into the servers
#' @author Gaye,A.
#'
#' @author Amadou Gaye, Paul Burton (updated 15/10/18). THIS IS VERSION TO USE 8/2/19.
getOpals <- function(){

# get the names of all the objects in the current work environment
objs <- ls(name=.GlobalEnv)

Expand All @@ -24,28 +24,31 @@ getOpals <- function(){
list2check <- eval(parse(text=objs[i]))
if(length(list2check) > 0){
cl2 <- class(list2check[[1]])
if(cl2 == 'opal'){
cnt <- cnt + 1
opalist[[cnt]] <- objs[i]
flag <- 1
for(s in 1:length(cl2)){
if(cl2[s] == 'opal'){
cnt <- cnt + 1
opalist[[cnt]] <- objs[i]
flag <- 1
}
}
}
}
}
if(flag == 1){
if(length(opalist) > 1){
flag <- 2
return(list("flag"=flag, "opals"=unlist(opalist)))
return(list("flag"=flag, "opals"=unlist(opalist), "opals.list"=unlist(opalist)))
}else{
pp <- opalist[[1]]
opals <- eval(parse(text=pp))
return(list("flag"=flag, "opals"=opals))
return(list("flag"=flag, "opals"=opals, "opals.list"=unlist(opalist)))
}
}else{
return(list("flag"=flag, "opals"=NULL))
return(list("flag"=flag, "opals"=NULL, "opals.list"=NULL))
}
}else{
return(list("flag"=flag, "opals"=NULL))
return(list("flag"=flag, "opals"=NULL, "opals.list"=NULL))
}

}
#getOpals
56 changes: 56 additions & 0 deletions azure-pipelines.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
pool:
vmImage: 'Ubuntu 16.04'

steps:
- bash: |
sudo service mysql stop
sudo apt-get update
sudo apt-get remove --purge mysql-client mysql-server mysql-common -y
sudo apt-get purge mysql-client mysql-server mysql-common -y
sudo apt-get autoremove -y
sudo apt-get autoclean -y
sudo rm -rf /var/lib/mysql/
wget -nv https://apt.puppetlabs.com/puppet5-release-xenial.deb
sudo dpkg -i puppet5-release-xenial.deb
sudo apt-get install -qq -f
sudo apt-get update
sudo rm -f puppet5-release-xenial.deb
sudo apt-get install puppet-agent -y
sudo apt-get clean all
sudo apt-get update
sudo apt-get autoremove -y
sudo apt-get clean all
sudo /opt/puppetlabs/puppet/bin/gem install r10k
echo -n "Puppet version: "
/opt/puppetlabs/bin/puppet --version
/opt/puppetlabs/puppet/bin/r10k version
git clone -b ubuntu16 https://github.com/datashield/datashield-infrastructure.git ../datashield-infrastructure
pushd ../datashield-infrastructure/puppet/environments/datashield_azurepipelines && sudo /opt/puppetlabs/puppet/bin/r10k puppetfile install && popd
sudo /opt/puppetlabs/bin/puppet apply azure-pipelines_site.pp --environment datashield_azurepipelines --environmentpath ../datashield-infrastructure/puppet/environments
displayName: 'Install DataSHIELD server'

- bash: |
sudo apt-key adv --keyserver keyserver.ubuntu.com --recv-keys E298A3A825C0D65DFD57CBB651716619E084DAB9
sudo add-apt-repository 'deb [arch=amd64,i386] https://cran.rstudio.com/bin/linux/ubuntu xenial/'
sudo apt-get update
sudo apt-get install -qq libxml2-dev libcurl4-openssl-dev libssl-dev -y
sudo apt-get install -qq r-base -y
sudo R -e "install.packages('devtools', dependencies=TRUE)"
displayName: 'Install R client'

- bash: |
R -e "library('devtools'); devtools::check(args = c('--no-examples'))" | tee azure-pipelines_check.Rout
grep --quiet "0 error" azure-pipelines_check.Rout
displayName: 'Devtools checks'
condition: always()

- bash: |
./checkDocumentationUpdated.sh
displayName: 'Check documents'
condition: always()
23 changes: 23 additions & 0 deletions azure-pipelines_site.pp
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
# Datashield for Azure Pipelines testing.
#
# Install mysql and mongodb, include test data but don't install the firewall.
# This is an example please change to meet the needs of your install. Consider changing any passwords in this file!
#

class { ::datashield:
test_data => true, # Install the test data
firewall => false, # Do not install the firewall
mysql => true, # Install mysql server
mongodb => true, # Install mongodb server
remote_mongodb => false, # There is not a remote mongodb server
remote_mysql => false, # There is not a remote mysql server

dsbase_githubusername => 'datashield',
dsbase_ref => 'master',
dsstats_githubusername => 'datashield',
dsstats_ref => 'master',
dsgraphics_githubusername => 'datashield',
dsgraphics_ref => 'master',
dsmodelling_githubusername => 'datashield',
dsmodelling_ref => 'master'
}
25 changes: 25 additions & 0 deletions checkDocumentationUpdated.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
#!/usr/bin/env bash
# Check if the documentation in the man directory matches what should be in it
# based on what is in the headers of the R scripts.
echo "Starting documentation check."

# Concatenate all the files in the man dir into one long string and md5sum it.
orig_sum=$(find man -type f | sort -u | xargs cat | md5sum)

# Rebuild the documentation.
R -e "devtools::document()"

# Concatenate all the files in the man dir into one long string and md5sum it.
new_sum=$(find man -type f | sort -u | xargs cat | md5sum)

# echo $orig_sum
# echo $new_sum

if [ "$orig_sum" != "$new_sum" ]; then
echo "Your committed manual files (man/*.Rd) are out of sync with the documentation in the R files."
echo "Run roxygenise() locally then commit again."
exit 1
else
echo "Documentation up to date."
exit 0
fi
24 changes: 15 additions & 9 deletions man/findLoginObjects.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

14 changes: 6 additions & 8 deletions man/getOpals.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit 500b1c4

Please sign in to comment.