GithubHelp home page GithubHelp logo

automagic's Introduction

Hello! 👋

I am an Associate Professor of Pediatrics at Cincinnati Children’s Hospital Medical Center and the University of Cincinnati College of Medicine interested in geoinformatics, environmental and population health, and fairness in precision medicine. My research is focused on understanding the heterogeneous effects of environmental exposures and community characteristics on childhood psychiatric and neurobehavioral health outcomes. I am also interested in developing new methods and technologies to support environmental and population health research, including statistical computing tools for geocoding and geomarker assessment, high resolution spatiotemporal air pollution exposure assessment models, and causal inference machine learning methods.

automagic's People

Contributors

cole-brokamp avatar merlinoa avatar stephlocke avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar

automagic's Issues

Add required packages to DESCRIPTION

I really like automagic: It's my go-to package when I get random scripts from colleagues and want to get everything running fast. So thank you for your work here!

I wonder if you would consider adding a function that automatically adds/updates required dependencies in the DESCRIPTION file of an R package in ongoing development. I find myself sometimes working on package code and loosing track of the dependencies I use. Then it's useful to have a function that updates the DESCRIPTION accordingly.

I wrote some code for this purpose in rrtools (https://github.com/benmarwick/rrtools/blob/master/R/manage_dependencies.R), but I think it does not really belong there. It would fit better into a management package like automagic where the search for packages is already implemented.

What do you think? Could this feature become part of automagic?

FR: Support `library("tidyverse")` notation

Speech marks are not supported in the CRAN or git version (as of Issue generation point). Taking the example from parse_packages:

> cat('library("ggplot2")\n # library(curl)\n require(leaflet)\n CB::date_print()\n',file='temp.R')
> parse_packages('temp.R')
[1] "\"ggplot2\"" "leaflet"     "CB"         
> unlink('temp.R')

This should result in

> cat('library("ggplot2")\n # library(curl)\n require(leaflet)\n CB::date_print()\n',file='temp.R')
> parse_packages('temp.R')
[1] "ggplot2" "leaflet"     "CB"         
> unlink('temp.R')

way to avoid installing bloated `*verse` packages?

I commonly start an analysis with library(tidyverse) and then go to use automagic to create a deps.yaml file, but do not want to take the time to manually check which of the tidyverse packages I actually need and substitute the appropriate library calls so that I don't have to install the entire tidyverse every time I deploy (which is usually from source).

An idea would be to add a helper function that can modify deps.yaml automatically to only install *verse packages that are needed.

Error with automagic and dependency file

I can run automagic() on a set of rmd files without error. I tested with manually uninstalled libraries, and installation works fine. However, when I generate a deps-file manually, I get:

installing from deps.yaml file at
C:/Users/Dieter/Documents/report1/deps.yaml

Error in filter_impl(.data, quo) : 
  Evaluation error: object 'GithubRepo' not found.

14: stop(list(message = "Evaluation error: object 'GithubRepo' not found.", 
        call = filter_impl(.data, quo), cppstack = NULL))
13: filter_impl(.data, quo)
12: filter.tbl_df(., !is.na(GithubRepo))
11: dplyr::filter(., !is.na(GithubRepo))
10: function_list[[k]](value)
9: withVisible(function_list[[k]](value))
8: freduce(value, `_function_list`)
7: `_fseq`(`_lhs`)
6: eval(quote(`_fseq`(`_lhs`)), env, env)
5: eval(quote(`_fseq`(`_lhs`)), env, env)
4: withVisible(eval(quote(`_fseq`(`_lhs`)), env, env))
3: deps %>% dplyr::filter(!is.na(GithubRepo))
2: automagic::install_deps_file(directory = directory)
1: automagic()

Note the strange tilde below. I can manually removed the tilde, but the error remains the same.

- Package: odbc
  Repository: CRAN
  Version: 1.1.5
- Package: stringr
  Repository: CRAN
  Version: 1.3.0
- Package: ggplot2
  Repository: CRAN
  Version: 2.2.1
- Package: knitr
  Repository: CRAN
  Version: '1.20'
- Package: tidyr
  Repository: CRAN
  Version: 0.8.0
- Package: dplyr
  Repository: CRAN
  Version: 0.7.4
- Package: lubridate
  Repository: CRAN
  Version: 1.7.4
- Package: cowplot
  Repository: CRAN
  Version: 0.9.2
- Package: pander
  Repository: CRAN
  Version: 0.6.1
- Package: forcats
  Repository: CRAN
  Version: 0.3.0
- Package: SparseM
  Repository: CRAN
  Version: '1.77'
- Package: desctable
  Repository: CRAN
  Version: 0.1.1
- ~
- Package: DBI
  Repository: CRAN
  Version: 1.0.0
- Package: gridExtra
  Repository: CRAN
  Version: '2.3'
- Package: sessioninfo
  Repository: CRAN
  Version: 1.0.0

Interact with deps.yaml

As a continuation to the discussion in #12, it would be nice to also be able to add, remove, or update entries in deps.yaml manually. I'm just thinking out loud here, but the API might look something like this:

library(automagic)

# Initialize deps.yaml with used packages
deps_init()  # currently named make_deps_file()

# Do more work, want to manually add dep, using current installed version/source
deps_add("tidyr")

# or specify the version and repo
deps_add("cole-brokamp/rize", GitHubSHA1 = "4e29652...")

# Install package if not already installed and add to deps.yaml
deps_add("glmnet", version = "2.0.16")
## Installing glmnet...

# Do more work, remove some code and don't need dep
deps_remove("furrr")

# Re-scan code, update package in deps.yaml and add new dependencies
deps_update()

# Or just update package versions of old deps.yaml to match system 
# (implicitly doesn't need to scan code)
deps_update(add = FALSE)

# Or remove previous deps no longer used in code
deps_update(add = FALSE, remove = TRUE)

# Or finally update deps.yaml as in re-create from scratch
# using current project code
deps_update(remove = TRUE)

Add support for more package loading functions

Have you considered to make the parsing code (https://github.com/cole-brokamp/automagic/blob/master/R/parse_packages.R#L52 ff.) modular so that more ways to load packages could be easily managed / added?

I just read https://yihui.name/en/2018/09/xfun-pkg-attach/ and using xfun::pkg_attach(c('ggplot2', 'dplyr', 'shiny')) or pacman::p_load() would not be handled by automagic (correct me if I'm wrong).

If the unit test PR #5 gets merged, I would be happy to have a go at this issue, if you'd welcome the change.

Look for packages to be installed in a single file, or in a list of files only

Hi, your code is excellent and I tweeted about it!

https://twitter.com/unsorsodicorda/status/1038741138964967426

Just one suggestion, would it be possible to add the option to search packages to be installed in a single file, or in a list of files, rather than in all of the files in the specified folder? For now I just copy the one or more files I want automagic to scan, into a temp folder, and setwd() to it. But adding the option to specify one or more files to look into, instead than only a directory, would be neat.

get_dependent_packages() wrong output

Thanks for your great package! It is extremely useful when using it in combination with Docker.
However, I stumbled upon an error when trying to dockerize a shiny app. After some research I came to the following:
When running get_dependent_packages from the automagic package it gave the following output:
get_dependent_packages()
[1] "shiny" "shinydashboard" "shinyBS" "shinyWidgets" [5] "shinyjs" "RODBC" "ggplot2" "geomnet" [9] "scales" "dplyr" "tidyr" "GGally" [13] "plotly" "rhandsontable" "networkD3" "stringr" [17] "shinycssloaders" "flexdashboard" "visNetwork" "ggrepel" [21] "ggthemes" "data.table" "DT" "bcrypt" [25] "lubridate" "jsonlite" "rmarkdown" "pkg_name, character.only = TRUE" [29] "pkg, character.only = TRUE" "devtools" "httr" "\"jsonlite\", character.only = TRUE" [33] "\"devtools\", character.only = TRUE" "\"httr\", character.only = TRUE" "names(pkgs" "tcltk"

Any idea what could be the cause? Thanks!

Still create deps.yaml when package not found

If a package is discovered in the code, but not found locally, make_deps_file() will error and no file is created. Instead of this, it might be better to filter out the un-found packages, create deps.yaml with the found packages, and then warn the user about the packages that weren't found.

Here's a reprex of a situation I ran into this morning.

tmpdir <- tempfile("automagic_test_")
dir.create(tmpdir)
cat(
  "library(stringr)",
  'text_var <- "rstudio::conf()"', 
  file = file.path(tmpdir, "testing.R"),
  sep = "\n"
)
automagic::get_dependent_packages(tmpdir)
#>      [,1]     
#> [1,] "stringr"
#> [2,] "rstudio"
automagic::make_deps_file(tmpdir)
#> Warning in packageDescription(pkg_name): no package 'rstudio' was found
#> Error: $ operator is invalid for atomic vectors

Created on 2019-03-08 by the reprex package (v0.2.1)

prevent documentation of base packages

If I am writing code that includes something like utils::getCRANmirrors(), automagic will write utils to the deps.yaml file and/or try to install it from CRAN, which will generate an error. It would be useful to scrub any "base R" packages from the list of suggested install packages, even if they are explicitly named in the code.

install package from local file?

Thanks for the package! Looks very nice :) It seems to combine the ease of checkpoint with the ability to control packages out of CRAN.

I wonder if it's possible to automatically install packages from local files (zip, tar.gz)? It would be nice to have that option in addition to CRAN and GitHub... For example, for packages that have disappeared (or will eventually disappear) from GitHub but we have downloaded a local copy.

Thanks

remove dependency on pacman

as it is not compatible with versions of R older than 3.5.0 (https://github.com/trinker/pacman/blob/a46cf92b0fa83724b140e5cc8d30872381de6960/DESCRIPTION#L13)

given that this significantly reduces the ability to build things using older versions of R and the pacman package is only used for package guess installs, I would like to remove this dependency.

this is also causing downstream problems for containers that use an older version of R but attempt to install the latest version of automagic from github

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.