Giter Club home page Giter Club logo

pkgmeta's Introduction

R-CMD-check pkgdown codecov Project Status CRAN_Status_Badge R-Universe_Status_Badge DOI

pkgmeta

R Package for meta-analysis of KWB-R packages on Github. It is a wrapper to the R packages 'codemetar' and 'pkgnet' for providing insights into the development of the R packages on Github.

Installation

For details on how to install KWB-R packages checkout our installation tutorial.

### Optionally: specify GitHub Personal Access Token (GITHUB_PAT)
### See here why this might be important for you:
### https://kwb-r.github.io/kwb.pkgbuild/articles/install.html#set-your-github_pat

# Sys.setenv(GITHUB_PAT = "mysecret_access_token")

# Install package "remotes" from CRAN
if (! require("remotes")) {
  install.packages("remotes", repos = "https://cloud.r-project.org")
}

# Install KWB package 'pkgmeta' from GitHub
remotes::install_github("KWB-R/pkgmeta")

Documentation

Release: https://kwb-r.github.io/pkgmeta

Development: https://kwb-r.github.io/pkgmeta/dev

pkgmeta's People

Contributors

hsonne avatar mrustl avatar

Watchers

 avatar  avatar  avatar  avatar

Forkers

mrustl

pkgmeta's Issues

Add functions for package reverse dependency check

As described in http://www.tinyverse.org/, R package dependencies should be as lean as possible. To check wether this is the case for our KWB-R packages the follwing functions should be added to pkgmeta and added to a vignette for automating this analysis (at least for the public R packages).

get_recursive_pkg_dependencies <-
  function(pkgs,
           library_path = .libPaths(),
           dbg = TRUE) {
    pkgs_installed <-
      pkgs[pkgs %in% rownames(installed.packages(lib.loc = library_path))]
    
    setNames(lapply(pkgs_installed, function(pkg) {
      kwb.utils::catAndRun(
        sprintf("Getting recursive dependencies for '%s'", pkg),
        expr = {
          packrat:::recursivePackageDependencies(pkg,
                                                 lib.loc = library_path)
        },
        dbg = dbg
      )
    }),
    nm = pkgs_installed)
    
  }


get_pkg_dependencies <-
  function(pkgs,
           library_path = .libPaths(),
           dbg = TRUE) {
    pkgs_installed <-
      pkgs[pkgs %in% rownames(installed.packages(lib.loc = library_path))]
    
    setNames(lapply(pkgs_installed, function(pkg) {
      kwb.utils::catAndRun(
        sprintf("Getting dependencies for '%s'", pkg),
        expr = {
          packrat:::getPackageDependencies(pkg, lib.loc = library_path)
        },
        dbg = dbg
      )
    }),
    nm = pkgs_installed)
    
  }



###############################################################################
### Define Function for Installing KWB-R GitHub Packages
###############################################################################

install_kwb_github_packages <- function(pkgs_kwb,
                                        dependencies = TRUE,
                                        ...) {
  pkgs_kwb_github <- sprintf("KWB-R/%s", pkgs_kwb)
  
  sapply(
    pkgs_kwb_github,
    FUN = function(gh_repo) {
      try(remotes::install_github(repo = gh_repo,
                                  dependencies = dependencies,
                                  ...))
    }
  )
}


###############################################################################
### Use the Install Function For KWB-R Packages 
###############################################################################


pkgs <- pkgmeta::get_github_packages()


install_kwb_github_packages(pkgs_kwb = pkgs$name, upgrade = "always")

pkgs_recursive_dependencies <- get_recursive_pkg_dependencies(pkgs$name)
pkgs_dependencies <- get_pkg_dependencies(pkgs$name)


deps_df <-  tibble::tibble(package = names(total_deps_per_pkg), 
               n_dependencies = sapply(pkgs_dependencies, length),
               n_recursive_dependencies = sapply(pkgs_recursive_dependencies, length)) %>% 
  dplyr::arrange(dplyr::desc(n_recursive_dependencies))

Using this locally with GITHUB_PAT with private KWB-R repo scope (installation failed for 2 private repos, see #2), these are the total (recursive) dependencies:

package n_dependencies n_recursive_dependencies
kwb.flusshygiene.app 12 109
fhpredict 13 107
kwb.flusshygiene 9 100
aquanes.report 25 99
kwb.kuras 4 90
kwb.ogre.model 5 90
kwb.ogre 10 89
kwb.package 3 88
sema.berlin.app 20 88
fakin.path.app 18 86
kwb.dswt 7 86
kwb.endnote 15 84
pkgmeta 18 79
kwb.miacso 1 78
kwb.rain 5 78
kwb.misc 9 77
kwb.qmra 15 76
kwb.read 7 75
datacamp 21 68
kwb.fakin 20 65
kwb.pkgbuild 13 61
sema.berlin 7 55
kwb.twitter 6 52
kwb.umberto 9 52
kwb.monitoring 8 49
kwb.pubs 10 49
AquaNES 3 48
kwb.sema 7 48
kwb.lca 4 46
kwb.dygraph 3 44
kwb.mia.evalCritO2 2 43
kwb.readxl 6 43
kwb.mia.iw 6 42
kwb.test.datetime 2 42
kwb.base 6 41
kwb.orcid 5 39
kwb.epanet 4 38
kwb.geosalz 12 38
kwb.resilience 1 37
kwb.event 3 36
kwb.pkgstatus 8 36
kwb.site 4 35
kwb.plot 3 34
qmra.db 10 34
kwbGompitz 3 33
kwb.svn 9 31
kwb.test 2 30
kwb.demeau 9 29
kwb.pathdict 4 28
kwb.code 3 27
kwb.file 5 26
kwb.ucode 1 18
kwb.dwd 10 17
kwb.wtaq 4 17
algoliar 5 16
kwb.hantush 1 15
kwb.vs2dh 4 8
kwb.odmx 3 5
kwb.logger 4 4
kwb.odm 3 4
kwb.quantum 3 4
kwb.dwa.m150 2 3
kwb.context 2 2
kwb.db 2 2
kwb.gocr 2 2
kwb.optiwells 1 2
kwb.rerau 2 2
kwb.datetime 1 1
kwb.en13508.2 1 1
kwb.graph 1 1
kwb.iview 1 1
kwb.virtualdub 1 1
kwb.barplot 0 0
kwb.default 0 0
kwb.utils 0 0

Vignette build error on Travis (due to codemetar::create_codemeta() error)

Running the code below in the "analyse-rpackages.Rmd" vignette on Travis

pkgs <- pkgmeta::get_github_packages()

pkgs_codemetar <- withr::with_libpaths(new = "/home/travis/R/Library",
                                       code = {
                                       lapply(pkgs$name,
                                                function(x) {
                           print(glue::glue("Writing codemeta for R package {x}"))
                           codemetar::create_codemeta(pkg = x)})})

errors with the following output on Travis:

── Building articles ───────────────────────────────────────────────────────────
Writing 'articles/index.html'
Reading 'vignettes/analyse-rpackages.Rmd'
Error in if (grepl("github.com\\/.*\\/.*", cm$codeRepository)) { : 
  argument is of length zero
Error in if (grepl("github.com\\/.*\\/.*", cm$codeRepository)) { : 
  argument is of length zero
Calls: <Anonymous> ... build_site -> build_site_external -> <Anonymous> -> get_result
Execution halted
Script failed with status 1

see https://travis-ci.org/KWB-R/pkgmeta/jobs/480645714#L4356

Any idea codemetar expert @hsonne why this happens?

Installation of 6 private KWB-R packages fails

Installation for private KWB-R packages as described in https://kwb-r.github.io/kwb.pkgbuild/articles/install.html#kwb-r-packages currently fails for 5 repos.

###############################################################################
### Define Function for Installing KWB-R GitHub Packages
###############################################################################

install_kwb_github_packages <- function(pkgs_kwb,
                                        dependencies = TRUE,
                                        ...) {
  pkgs_kwb_github <- sprintf("KWB-R/%s", pkgs_kwb)
  
  sapply(
    pkgs_kwb_github,
    FUN = function(gh_repo) {
      try(remotes::install_github(repo = gh_repo,
                                  dependencies = dependencies,
                                  ...))
    }
  )
}


###############################################################################
### Use the Install Function For KWB-R Packages for Project BaSaR
###############################################################################


pkgs <- pkgmeta::get_github_packages()


install_kwb_github_packages(pkgs_kwb = pkgs$name, upgrade = "always")

"Error : Failed to install 'kwb.context' from GitHub:\n  (converted from warning) installation of package ‘C:/Users/mrustl.KWB/AppData/Local/Temp/Rtmpof8Wpw/file2ee47967418/kwb.context_0.1.tar.gz’ had non-zero exit status\n" 

"Error : Failed to install 'kwb.furain' from GitHub:\n  (converted from warning) packages ‘kwb.gocr’, ‘kwb.iview’, ‘magickx’ are not available (for R version 3.6.1)\n" 

"Error : Failed to install 'kwb.kuras' from GitHub:\n  (converted from warning) installation of package ‘C:/Users/mrustl.KWB/AppData/Local/Temp/Rtmpof8Wpw/file2ee44fe226b5/kwb.kuras_0.0.99.tar.gz’ had non-zero exit status\n" 

Adding of pkg dependencies in field "Remotes" required:

  • KWB-R/kwb.context

  • KWB-R/kwb.kuras

  • KWB-R/kwb.miacso

  • KWB-R/kwb.ucode

Additional changes required:

  • KWB-R/kwb.furain

  • KWB-R/kwb.rsprotox

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.