diff --git a/DESCRIPTION b/DESCRIPTION index b419490..714f996 100644 --- a/DESCRIPTION +++ b/DESCRIPTION @@ -1,10 +1,11 @@ Package: dsStatsClient Maintainer: Author: -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 diff --git a/R/findLoginObjects.R b/R/findLoginObjects.R index 439624c..9b0f064 100644 --- a/R/findLoginObjects.R +++ b/R/findLoginObjects.R @@ -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) } -} \ No newline at end of file + 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 diff --git a/R/getOpals.R b/R/getOpals.R index ee86536..f643eb1 100644 --- a/R/getOpals.R +++ b/R/getOpals.R @@ -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) @@ -24,10 +24,12 @@ 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 + } } } } @@ -35,17 +37,18 @@ getOpals <- function(){ 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 \ No newline at end of file diff --git a/azure-pipelines.yml b/azure-pipelines.yml new file mode 100644 index 0000000..3a6334c --- /dev/null +++ b/azure-pipelines.yml @@ -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() diff --git a/azure-pipelines_site.pp b/azure-pipelines_site.pp new file mode 100644 index 0000000..8e70840 --- /dev/null +++ b/azure-pipelines_site.pp @@ -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' +} diff --git a/checkDocumentationUpdated.sh b/checkDocumentationUpdated.sh new file mode 100755 index 0000000..e9ac6fd --- /dev/null +++ b/checkDocumentationUpdated.sh @@ -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 diff --git a/man/findLoginObjects.Rd b/man/findLoginObjects.Rd index 5062bb3..710eab1 100644 --- a/man/findLoginObjects.Rd +++ b/man/findLoginObjects.Rd @@ -1,3 +1,5 @@ +% Generated by roxygen2: do not edit by hand +% Please edit documentation in R/findLoginObjects.R \name{findLoginObjects} \alias{findLoginObjects} \title{searches for opal login object in the environment} @@ -11,16 +13,20 @@ returns a list of opal login objects or stops the process 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. +if the user does not set the argument 'datasources', this function +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. } \author{ -Gaye, A. +Amadou Gaye, Paul Burton (updated 15/10/18). THIS IS VERSION TO USE 8/2/19. } \keyword{internal} - diff --git a/man/getOpals.Rd b/man/getOpals.Rd index d033aa2..1cc1b2e 100644 --- a/man/getOpals.Rd +++ b/man/getOpals.Rd @@ -1,3 +1,5 @@ +% Generated by roxygen2: do not edit by hand +% Please edit documentation in R/getOpals.R \name{getOpals} \alias{getOpals} \title{Gets the opal objects} @@ -11,15 +13,11 @@ a list of opal object obtained after login into the servers This is an internal function. } \details{ - - -The function searches for a list containing object of type -'opal' in the global environment; if more than one list is -found it return the lastest. This way no matter what the -user calls his opal login object it will be captured. +The function searches for a list containing object of type 'opal' +in the global environment; if more than one list is found it return the lastest. +This way no matter what the user calls his opal login object it will be captured. } \author{ -Gaye,A. +Amadou Gaye, Paul Burton (updated 15/10/18). THIS IS VERSION TO USE 8/2/19. } \keyword{internal} -