Skip to content

Say why a fit can't read its CSV files after the temp directory is gone - #1316

Merged
jgabry merged 2 commits into
v1.0from
temp-csv-hint
Oct 8, 2026
Merged

jgabry merged 2 commits into
v1.0from
temp-csv-hint

Conversation

@jgabry

@jgabry jgabry commented Oct 7, 2026

Copy link
Copy Markdown
Member

Submission Checklist

  • Run unit tests
  • Declare copyright holder and agree to license (see below)

Summary

Fixes #1012. Replaces #1178 (and #1176 before it) with a smaller change.

A fit restored from a cached Quarto or R Markdown chunk, or loaded with readRDS() in a later session, points at CSV files in the old session's temporary directory, and the first $draws() fails inside read_cmdstan_csv() with checkmate's "File does not exist". A new private csv_files_() method on CmdStanFit throws an error that says what happened and what to do (pass output_dir or save with $save_object()).

$save_output_files() moves the files out of the temp directory but leaves using_tempdir as it was (for reasons), so we also check that the files are still in the run's recorded output_dir (the dirname() comparison in the code).

Copyright and Licensing

Please list the copyright holder for the work you are submitting
(this will be you or your assignee, such as a university or company):
Jonah Gabry

By submitting this pull request, the copyright holder is agreeing to
license the submitted work under the following licenses:

@jgabry
jgabry changed the base branch from master to v1.0 October 7, 2026 23:17
Comment thread R/fit.R
files <- self$output_files(include_failed = FALSE)
output_dir <- self$runset$args$output_dir
if (!all(file.exists(files)) &&
isTRUE(self$runset$args$using_tempdir) &&

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

as_cmdstan_fit() has no runset, so using_tempdir is NULL so using isTRUE

Comment thread R/fit.R Outdated
output_dir <- self$runset$args$output_dir
if (!all(file.exists(files)) &&
isTRUE(self$runset$args$using_tempdir) &&
all(dirname(files) == output_dir)) {

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

$save_output_files() moves the files out of the temp directory but leaves using_tempdir as it was (for reasons), so we need to check that the files still sit in the run's recorded output_dir

@codecov-commenter

codecov-commenter commented Oct 7, 2026 •

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
⚠️ Please upload report for BASE (v1.0@ca9b4d3). Learn more about missing BASE report.

Additional details and impacted files
@@           Coverage Diff           @@
##             v1.0    #1316   +/-   ##
=======================================
  Coverage        ?   93.98%           
=======================================
  Files           ?       19           
  Lines           ?     7363           
  Branches        ?        0           
=======================================
  Hits            ?     6920           
  Misses          ?      443           
  Partials        ?        0           

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

On WSL the output directory is a //wsl$ network path, and R's Windows
dirname() spells the leading // as \\ to preserve the share, so the
comparison in csv_files_() was never true there.
@jgabry
jgabry marked this pull request as ready for review October 8, 2026 04:20
@jgabry
jgabry merged commit 73171d8 into v1.0 Oct 8, 2026
18 checks passed
@jgabry
jgabry deleted the temp-csv-hint branch October 8, 2026 14:53
@jgabry jgabry mentioned this pull request Oct 19, 2026
2 tasks done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Errors re-rendering quarto html with cached chunks and cmdstanr.

2 participants