Hacktoberfest 2026: le issue che i maintainer hanno segnato per ottobre, aperte e adatte ai principianti. Sfoglia le issue Hacktoberfest

Option to send $sample() output to file instead of console

Aperta
#473 2 commenti 1 reazione 0 assegnatari Vedi su GitHub

I maintainer di solito rispondono entro 1 giorno

Nessuno ha ancora preso questa issue.

Valutazione

Difficoltà
4/5
Tempo stimato
3-5 giorni
Idoneità per principianti
45/100
Tipo di issue
Funzionalità
Chiarezza
Abbastanza chiara
Stato di attività
Tranquilla
Stack tecnologico
r

Direzione di ricerca

Inizia dal punto di ingresso $sample() e verifica come processx gestisce attualmente i messaggi della console, usando come contesto la discussione in #424. Determina se l'output debba supportare console, file o entrambi, quindi aggiungi una copertura che dimostri che la diagnostica viene instradata in base all'interfaccia scelta. Il lavoro è completo quando il comportamento selezionato è documentato e verificato.

Scritto dal modello di indicizzazione a partire dal testo della issue.

Descrizione

feature

Summary

I would like to be able to route to a file all of the messages (diagnostics, etc.) that $sample() prints to the console.

Possible interface options

There are two obvious options for how to expose this:

  1. Have a new argument (something like messages_file or messages_out_path) that take a file path and sends all output to that file.
  2. Change the show_messages argument to accept a boolean or a file path:
  • TRUE prints messages to console
  • FALSE prints no messages
  • path sends messages to file instead of console

The second option has the appeal of not adding another (fairly specific) argument, though it does make this argument take mixed types (logical or character). This is a little messy, but not unprecedented (for example, callr does it here).

This second option would also mean that the user could either print to console or save to file, but not both. Looking at the implementation in processx, we may be stuck with this behavior regardless, in which case I'd prefer this second solution. However, I think ideally the user could choose console, file, or both.

Additional context

This originally came out of discussion in #424 and @rok-cesnovar suggested splitting this into its own issue.

There are some possible workarounds, which I think makes this not super high priority. For example, @wlandau uses withr for this purpose in stantargets. It's also possible to call $sample() within either callr::r() or callr::r_bg() and use the show, stdout, and stderr args to accomplish any desired combo of logging to the console and/or a file:

res <- callr::r(
  {function() stanmod$sample(...)},
  args = list(stanmod),
  show = TRUE,                # controls printing to console
  stdout = "/some/log/file",  # sends stdout to file
  stderr = "2>&1"             # interleaves stderr with stdout
)
Lingua principale
R
Stelle
160
Fork
69
Merge medio
1g 8h
PR unite (30g)
20

Preparare l'ambiente

Come iniziare

  1. Leggi tutta la issue e poi la guida ai contributi del progetto.
  2. Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
  3. Fai un fork del repository e lavora su un branch.
  4. Apri una pull request che faccia riferimento al numero della issue.

Altre issue di stan-dev/cmdstanr

Tutte le issue di stan-dev/cmdstanr

Issue simili

Altre issue su R

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.