ropensci / targets

Function-oriented Make-like declarative workflows for R
https://docs.ropensci.org/targets/
Other
937 stars 75 forks source link

Wrong debugging suggestions in debug. #1223

Closed eliocamp closed 9 months ago

eliocamp commented 9 months ago

When using the debug option for this target:

     , tar_target(son_files, cmip_select_season(files, season = "SON", folder = son_dir),
                  pattern = map(files, files_latest_modified), 
                  format = "file_fast"
                  )

I get this message:

ℹ You are now running an interactive debugger in target son_files_c0ec9533.
  You can enter code and print objects as with the normal R console.
  How to use: https://adv-r.hadley.nz/debugging.html#browser

ℹ The debugger is poised to run the command of target son_files_c0ec9533:

     cmip_select_season(files, season = "SON", folder = son_dir)

ℹ Tip: run debug(cmip_select_season(files, season = "SON", folder = son_dir)) and then enter "c"
  to move the debugger inside function cmip_select_season(files, season = "SON", folder = son_dir)().
  Then debug the function as you would normally (without `targets`).

I think this is wrong. Running debug(cmip_select_season(files, season = "SON", folder = son_dir)) ran the command and then try to debug the result of the function. In my case, the result is a filename and I get:

Error in debug(cmip_select_season(files, season = "SON", folder = son_dir)) : 
  could not find function "/home/elio.campitelli/ceofcmip6/data/derived_data/cmip/SON/tos_Omon_IPSL-CM6A-LR_historical_r26i1p1f1_gn_185001-201412.nc"

I think that the message should say

ℹ Tip: run debug(cmip_select_season) and then enter "c"
  to move the debugger inside function cmip_select_season().
wlandau commented 9 months ago

Thanks, https://github.com/ropensci/targets/commit/2837739e0b752f79dd839b43b9f2edf574d579fb makes the debugger message more generic and fixes this issue.