Where communities thrive


  • Join over 1.5M+ people
  • Join over 100K+ communities
  • Free without limits
  • Create your own community
People
Repo info
Activity
  • Sep 09 18:47
    klmr assigned #88
  • Jun 20 13:32

    klmr on feature-mod-file

    (compare)

  • Jun 20 13:32
    klmr closed #132
  • Jun 20 13:31

    klmr on new-api

    WIP Make `file` function more u… Remove obsolete test case Rename file unit test context and 2 more (compare)

  • Jun 20 13:31
    klmr closed #157
  • Jun 20 13:30
    klmr synchronize #157
  • Jun 20 13:30

    klmr on feature-mod-file

    Use integer literals consistent… Replace leftover uses of the ob… Don’t export all names during t… and 2 more (compare)

  • May 30 15:22

    klmr on new-api

    Use integer literals consistent… Replace leftover uses of the ob… Don’t export all names during t… and 1 more (compare)

  • May 25 09:28
    klmr commented #158
  • May 25 09:27
    klmr commented #158
  • May 25 09:26
    klmr commented #158
  • May 25 09:26
    klmr commented #158
  • May 24 19:43
    mschubert commented #157
  • May 24 19:39
    mschubert commented #132
  • May 24 19:32
    mschubert commented #158
  • May 24 19:32
    mschubert commented #158
  • May 24 19:13
    klmr commented #129
  • May 24 19:12
    klmr labeled #158
  • May 24 19:12
    klmr labeled #158
  • May 24 19:12
    klmr opened #158
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.