diff --git a/.Rbuildignore b/.Rbuildignore new file mode 100644 index 0000000..665c9c0 --- /dev/null +++ b/.Rbuildignore @@ -0,0 +1,10 @@ +^misc$ +^\.vs$ +\.sln$ +\.Rproj$ +\.Rxproj$ +^\.Rproj\.user$ +.travis.yml +CONTRIBUTING.md +^LICENSE\.md$ +azure-pipelines.yml diff --git a/.gitignore b/.gitignore index 26fad6f..3192c1c 100644 --- a/.gitignore +++ b/.gitignore @@ -34,3 +34,5 @@ vignettes/*.pdf # Shiny token, see https://shiny.rstudio.com/articles/shinyapps.html rsconnect/ + +misc/ diff --git a/DESCRIPTION b/DESCRIPTION new file mode 100644 index 0000000..4fecb7f --- /dev/null +++ b/DESCRIPTION @@ -0,0 +1,23 @@ +Package: AzureVision +Title: Interface to Azure Computer Vision Service +Version: 0.0.1 +Authors@R: c( + person("Hong", "Ooi", , "hongooi@microsoft.com", role = c("aut", "cre")), + person("Microsoft", role="cph") + ) +Description: An interface to the Azure Computer Vision service API. +URL: https://github.com/Azure/AzureVision https://github.com/Azure/AzureR +BugReports: https://github.com/Azure/AzureVision/issues +License: MIT + file LICENSE +Depends: + R (>= 3.3) +Imports: + AzureRMR, + httr (>= 1.3) +Suggests: + AzureAuth, + jpeg, + png, + svglite +Roxygen: list(markdown=TRUE) +RoxygenNote: 6.1.1 diff --git a/LICENSE b/LICENSE index 3d8b93b..23124c4 100644 --- a/LICENSE +++ b/LICENSE @@ -1,21 +1,2 @@ - MIT License - - Copyright (c) Microsoft Corporation. - - Permission is hereby granted, free of charge, to any person obtaining a copy - of this software and associated documentation files (the "Software"), to deal - in the Software without restriction, including without limitation the rights - to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - copies of the Software, and to permit persons to whom the Software is - furnished to do so, subject to the following conditions: - - The above copyright notice and this permission notice shall be included in all - copies or substantial portions of the Software. - - THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - SOFTWARE +YEAR: 2019 +COPYRIGHT HOLDER: Microsoft diff --git a/LICENSE.md b/LICENSE.md new file mode 100644 index 0000000..866fd8a --- /dev/null +++ b/LICENSE.md @@ -0,0 +1,21 @@ +# MIT License + +Copyright (c) Microsoft Corporation. + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all +copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +SOFTWARE diff --git a/NAMESPACE b/NAMESPACE new file mode 100644 index 0000000..ea40a46 --- /dev/null +++ b/NAMESPACE @@ -0,0 +1,3 @@ +# Generated by roxygen2: do not edit by hand + +import(AzureRMR) diff --git a/R/AzureVision.R b/R/AzureVision.R new file mode 100644 index 0000000..0555a97 --- /dev/null +++ b/R/AzureVision.R @@ -0,0 +1,41 @@ +#' @import AzureRMR +NULL + +globalVariables(c("self", "private")) + +.onLoad <- function(libname, pkgname) +{ + add_methods() +} + + +add_methods <- function() +{ + az_resource_group$set("public", "create_vision_service", overwrite=TRUE, + function(name, location=self$location, sku="S1", ...) + { + az_resource$new(self$token, self$subscription, self$name, + type="Microsoft.CognitiveServices/accounts", + name=name, + location=location, + kind="ComputerVision", + sku=list(name=sku), ...) + }) + + az_resource_group$set("public", "get_vision_service", overwrite=TRUE, + function(name) + { + az_resource$new(self$token, self$subscription, self$name, + type="Microsoft.CognitiveServices/accounts", + name=name) + }) + + az_resource_group$set("public", "delete_vision_service", overwrite=TRUE, + function(name, confirm=TRUE, wait=FALSE) + { + az_resource$new(self$token, self$subscription, self$name, + type="Microsoft.CognitiveServices/accounts", + name=name, + deployed_properties=list(NULL))$delete(confirm=confirm, wait=wait) + }) +} diff --git a/azure-pipelines.yml b/azure-pipelines.yml new file mode 100644 index 0000000..7b7e1d1 --- /dev/null +++ b/azure-pipelines.yml @@ -0,0 +1,55 @@ +variables: +- group: GH +- name: R_LIBS_USER + value: '$(Agent.BuildDirectory)/R/library' + +pool: + vmImage: 'ubuntu-latest' + +container: $[variables['rockerImage']] + +steps: +- bash: | + export CLOUDYR_REPO=$(echo $(Build.Repository.Name) | sed "s/Azure/cloudyr/") + git push --prune https://$(ghPat)@github.com/$CLOUDYR_REPO +refs/remotes/origin/*:refs/heads/* +refs/tags/*:refs/tags/* + displayName: 'Copy to Cloudyr' + condition: eq(variables['Build.SourceBranch'], 'refs/heads/master') + +- bash: | + echo "options(repos = '$(cranRepo)')" > ~/.Rprofile + echo ".libPaths(c('$R_LIBS_USER', .libPaths()))" >> ~/.Rprofile + mkdir -p $R_LIBS_USER + displayName: 'Setup R library directory' + +- task: CacheBeta@0 + inputs: + key: ./DESCRIPTION | "$(rockerImage)" | "$(cranRepo)" + path: $(R_LIBS_USER) + displayName: 'Caching packages' + +- bash: | + Rscript -e "pkgs <- c('remotes', 'rcmdcheck', 'drat'); if(length(find.package(pkgs, quiet=TRUE)) != length(pkgs)) install.packages(pkgs)" + Rscript -e "remotes::install_deps(dependencies=TRUE)" + displayName: 'Installing package dependencies' + +- bash: | + Rscript -e "f <- pkgbuild::build(dest_path='$(Build.ArtifactStagingDirectory)'); rcmdcheck::rcmdcheck(f, args='--no-manual', error_on='warning', check_dir='check')" + displayName: 'Checking package' + +- bash: | + export PKGBUILD_GZ=$(ls $(Build.ArtifactStagingDirectory)/*.gz) + mkdir drat + cd drat + git init + git config user.email "dummy@example.com" + git config user.name "Azure Pipelines" + git remote add upstream "https://$(ghPat)@github.com/cloudyr/cloudyr.github.io.git" + git fetch upstream + git checkout master + Rscript -e "drat::insertPackage('$PKGBUILD_GZ', repodir='./drat')" + git add --all + git commit -m "add $PKGBUILD_GZ (build $(Build.BuildId))" + git push + displayName: 'Update Cloudyr drat' + condition: and(succeeded(), eq(variables['Build.SourceBranch'], 'refs/heads/master')) + \ No newline at end of file