Where communities thrive


  • Join over 1.5M+ people
  • Join over 100K+ communities
  • Free without limits
  • Create your own community
People
Repo info
Activity
  • Jul 29 19:05

    klmr on new-api

    Move functions into the correct… Add documentation for importing… (compare)

  • Jul 22 08:35
    flying-sheep commented #148
  • Jul 21 14:29

    klmr on new-api

    Shell-quote arguments to R in t… Fix relative imports from globa… (compare)

  • Jul 19 17:59

    klmr on develop

    Ignore vignette build output di… (compare)

  • Jul 19 17:54

    klmr on master

    Deployment (compare)

  • Jul 19 17:53

    klmr on develop

    Update Makefile to new version … (compare)

  • Jul 19 17:48

    klmr on master

    Deployment (compare)

  • Jul 19 17:46

    klmr on master

    Deployment (compare)

  • Jul 19 17:45

    klmr on develop

    Update Makefile to new version … (compare)

  • Jul 19 12:41

    klmr on develop

    Bump version number (compare)

  • Jul 19 12:40

    klmr on develop

    Fix getting script_path from co… Bump version number (compare)

  • Jul 19 12:38

    klmr on develop

    Bump version number (compare)

  • Jul 19 12:35

    klmr on develop

    Bump version number (compare)

  • Jul 19 12:32
    klmr commented #148
  • Jul 19 12:29
    klmr closed #148
  • Jul 19 12:28

    klmr on develop

    Fix getting script_path from co… (compare)

  • Jul 19 12:28
    klmr commented #148
  • Jul 19 12:27
    klmr commented #148
  • Jul 19 12:26
    klmr commented #148
  • Jul 19 11:26
    flying-sheep opened #148
Ian Fiske
@ianfiske
Has anyone had any luck using the modules package on shinyapps.io? I can use it fine locally, but deploy to shinyapps fails when trying to install modules with the error installing source package ‘modules’ ...
R inst
preparing package for lazy loading help
**
installing help indices
building package indices installing vignettes
** testing if installed package can be loaded
Error in file(filename, "r", encoding = encoding) :
cannot open the connection
Calls: source -> file
In addition: Warning message:
In file(filename, "r", encoding = encoding) :
cannot open file '//.Rprofile': No such file or directory
Execution halted
ERROR: loading failed
  • removing ‘/usr/local/lib/R/site-library/modules’
    ############################# End Log
    Error: Unhandled Exception: Child Task 27247330 failed: Error building image: Error building modules (0.7.1). Build exited with non-zero status: 1
    Execution halted
Konrad Rudolph
@klmr
Oh. I can reproduce this.
I’m not sure what causes this but I have a suspicion that the .Rprofile file in the project root confuses the installer.
That’s arguably a bug in the shinyapps installer, since there’s nothing that forbids non-project files in a package directory (even though R CMD CHECK doesn’t like it).
I’ll file a bug report with shinyapps and see whether we can figure this out. Thanks for the report!
Ian Fiske
@ianfiske
Thanks for looking into this! As someone that frequently switches between Python and R, I much prefer the Pythonic module system to R's packages. Your modules package is great!
Konrad Rudolph
@klmr
Apologies for the delay (I was busy finishing up my PhD thesis, finally submitted last week; yay). The bug report is now available here: rstudio/shinyapps#152
Ian Fiske
@ianfiske
Thanks for reporting with the Shinyapps team! And congrats on submitting your thesis. Hopefully you don't have too many edits! (I had to add a chapter to mine)
Konrad Rudolph
@klmr
Okay, this required substantial action on my part to work. It’s implemented with klmr/modules@a0a065c
It seems to work fine: https://klmr.shinyapps.io/testshiny
please let me know if/when you find any issues.
Ian Fiske
@ianfiske
Thank you for putting the work into this fix. I can't wait to get back to Python-style modules in R for faster and cleaner development.
pshearer
@pshearer
This looks like a great package! Can't wait to use it on my next R project.
Holger Brandl
@holgerbrandl
great package, thanks a lot!
Holger Brandl
@holgerbrandl

Is it possible to ship my code as a regular package with no default exports, and use modules to import bits as needed? Example

## install my package (once only for sure)
devtools::install_github("holgerbrandl/datautils")

## load it, which will export nothing in its NAMESPACE
require(datautils) 

## import a source file from within the package
modules::import('bio/bioinfo_commons', attach=TRUE)

Obviously the last line does not work that way. Is such a usecase supported by modules?

Konrad Rudolph
@klmr
@holgerbrandl Although that use case isn’t really supported, it does work; just leave out the unnecessary require statement, and adjust the import path; using
options(import.path = .libPaths())
# and then:
modules::import('datautils/inst/bio/bioinf_commons')
Note that, due to the R package structure requirements, you need to put the module files inside the inst folder in the package.
If you instead want to load the package code itself, simply use modules::import_package('datautils') but (once again due to how R packages work) this doesn’t allow you to use nested modules (bio/bioinf_commons). :-(
Holger Brandl
@holgerbrandl
Thanks @klmr for this nice explanation about inst. Indeed loading the packages seemed not correct in the first place.
Holger Brandl
@holgerbrandl
If packages are not the intended mode for code deployment when using modules, what other mechanism would you suggest to allow some user to install my modules? To me, (ab)using the r package system for installation, and modules for fine-grained namespace control seemed like a nice combo.
Holger Brandl
@holgerbrandl
One downside of the suggested solution is that there is no meaningful error. When saying modules::import(‘datautils/inst/bio/bioinfo_commons’), it should fail with Error: ‘datautils' is not installed! Install first if datautils is not yet installed. This would be more consistent with import_packageerror behavior.
However, I guess without an additional verb (such as import_from_package('datautils/inst/bio/bioinf_commons')there is no easy way to overcome that problem.
Holger Brandl
@holgerbrandl
On a more general note, I’d love if import could somehow recurse into sub-directories. So in my case modules::import(‘datautils/inst/bio’, attach=T) should import and attach all methods under bio. But maybe this defeats the purpose of having a module system?
Konrad Rudolph
@klmr
Hi @holgerbrandl, apologies for my absenteeism. Busy time of year. To answer your questions, the intended mechanism for module deployment is (unfortunately) still in the works. You can check the existing discussions here:
For now, the way I (and others) use modules is to have them as GitHub projects (but really, anything works) and to git clone the ones I need. Not elegant but it works. Any package mechanism would probably be built on top of that.
I agree that using the existing package mechanism would be nice but unfortunately the way R packages load code is fundamentally at odds with modules; i.e. all information about nested packages get lost. Also, CRAN would probably agree that this is abuse, and hate it. ;-)
Anyway, it’s worth noting that the modules API is due for a fundamental overhaul soon (I just need to find time); see #129
Konrad Rudolph
@klmr
Regarding your recursive-attach use-case: yes, this somewhat defeats the purpose of modules; in fact, attaching everything in a module is going to be more strongly discouraged in the future (similar to how import * from foo is strongly discouraged in Python). But: you can achieve something along these lines by using export_submodule inside a module.