Repository navigation
Mitokic/11072026/pkg dep tech debt - #304
Conversation
tune 2.x dropped foreach support, so inner_parallel = TRUE ran tuning and refits sequentially. Register each local PSOCK pool as the future plan so tune shares the same workers, and restore the caller's plan in par_end() and cancel_parallel(). - Attach worker packages on all workers at pool start; otherwise future launches tune's first tasks one worker at a time. - Declare finnts as a dependency of the six multistep engines and add it to train_models() refit pkgs, so refits on fresh workers no longer drop back-test predictions silently. - Require R >= 4.1, tune >= 2.0.1, dials >= 1.4.0, parsnip >= 1.3.0, recipes >= 1.1.1, rsample >= 1.3.1, workflows >= 1.3.0; import future and future.apply. Version 0.7.0.9021. - Add parallel-util and installed inner-parallel worker tests, plus a multistep dependency test. Update NEWS, vignettes, cran-comments and the optional-dependencies rule. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
…1707) - Replace dials::grid_latin_hypercube() in ensemble_models() with grid_space_filling(type = "latin_hypercube") via a documented helper. Grids are identical for two or more points; one-point grids now match individual models and stay reproducible for a given seed. - Replace the six timetk::tk_augment_slidify() calls, which rely on deprecated purrr::cross_df(), with augment_rolling_windows(). R1 and R2 prepared features are byte-identical. - Fix lofo_fn() to call get_recipe_configurable(), so LOFO feature selection works for monthly, quarterly and yearly local models, both sequentially and with inner_parallel. - Remove unused tuning helpers in models.R and stale globalVariables. - Add deprecated-API and LOFO tests; stub LOFO in the multistep summary test to keep it within its runtime budget. Update NEWS and the feature-selection vignette. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
…(Phase 2, AB#81707) - get_cores() uses parallelly::availableCores(omit = 1), respecting container CPU limits; explicit num_cores is capped and never below 1. Adds parallelly (>= 1.42.0) to Imports. - Inner pools are sized to useful work (grid x validation folds or refit splits) and reused within a scope: across series run one after another, across forecast_time_series() stages, and across one series' Agent iterations and update steps (including inside each Spark task). - Spark (D13): with num_cores = NULL, each task's inner pool gets its share of the executor node (floor(node cores / tasks per executor) - 1). The budget is passed inner-only, so saved run logs are unchanged. - LOFO receives num_cores and joins the inner pool. - Model averages are computed in one grouped, bit-identical pass in process below 3,000 combinations; on the pool path, averages lost on workers are recomputed in the main process with a warning instead of silently dropped (D4, D17). - Removes the unreachable qs worker-package branch. - Docs: parallel-processing vignette (executor-cores trade-off, memory note), num_cores help for seven functions, NEWS. Targeted tests passed; full validation not run by request. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
…#81707) - reset_spark() reconnects Synapse and Databricks connections through their own method; other connections keep method, master, app name and config. - prep_data() on Spark passes an explicit output schema, so sparklyr no longer runs prep on partial series to infer it, and collects the per-series transformation table, fixing the -orig_combo_info write when stationary or box_cox is on (CSV and Parquet). - train_models() Spark tasks share one inner pool between feature selection and training. - C1 source fingerprints from Spark-table input now match local input. - Parquet reads no longer memory-map files (Windows rewrite lock) and read text Hyperparameter_ID as numeric, so model and average forecasts combine. - Vignette: Synapse connection example, conditional sparklyr.apply.packages note, sparklyr version note; archived qs serializer advice removed. - Tests: shared grouped spark_apply() emulation matching sparklyr 1.8.6 on Spark 3.5.1, plus fails-first regression tests for each change. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
…81707) Synapse /synfs and Databricks /dbfs FUSE mounts can report a file Spark tasks just wrote as missing, or return its old content, for over 180 s. read_settled() re-reads those outputs with a bounded backoff (195 s) only on mounted paths; local and API-backed storage read once as before, and callers keep their own validation and errors. - Wired into get_forecast_data(), log_best_run(), load_agent_forecast(), reconcile_hierarchical_data(), the reconciled read in final_models(), and the summarize_models() model and forecast reads. - Nested settled reads run once so waits never multiply. - validate_best_model() shares missing_best_model_combos(); new best_models_complete() is the readiness check. - AGENTS.md FUSE rule extended; NEWS bullet added. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
read_settled() re-ran folder listings on /synfs and /dbfs whenever a first read was stale (get_forecast_data(): 2 listings fresh, 8 always stale). Listings now run once before the re-read loop and only reads repeat, so listing counts match main in every case. - get_forecast_data() lists, then settles a read of that file list (sdf reads still use the path). - reconcile_hierarchical_data() shares its path-based file list with non-Spark reads. - load_agent_forecast() loads best runs once before re-reading forecasts. - log_best_run() leaves the all-series read to get_forecast_data(). - AGENTS.md and read_settled() docs: list file names before re-reading. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
- bind_rows_fill() replaces plyr::rbind.fill() in load_update_runs() and read_file()'s CSV fallback: missing columns are NA, a column that is text anywhere stays text, numbers combine as numbers. Identical to rbind.fill in 18 probed cases. - model_average_combinations() uses utils::combn() on sorted IDs, the same order gtools::combinations() gave, so saved average Model_IDs are unchanged. - Dropped from Imports, the worker package list and the custom-model package boundary; custom models may now also declare future, future.apply and parallelly, fixing the contract test broken since those became imports. - Characterization tests for the CSV fallback, best-run metadata and average ID order; the averaging reference test uses combn(). Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
The six multistep engines registered their fit function without its package, so parsnip looked it up on the search path. Where finnts was loaded but not attached (Spark workers without library(finnts), background jobs, finnts:: callers) tune silently dropped glmnet, xgboost, cubist, mars and svm models. Register the fit with pkg = "finnts" like the other custom engines, and add an installed-namespace test that fits all six in a process where finnts is loaded but not attached. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
parallel picks one random port per R process from 11000-11999, so Spark tasks on one node that start inner pools together could pick the same port. The later pool failed to open it, doSpark returned the error, and train_models() stopped the whole stage. Start each pool on a port parallelly::freePort() finds free (honoring R_PARALLEL_PORT and leaving the random-number stream untouched) and retry only serverSocket() port errors, up to three ports. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
The automatic MARS grid could pick exhaustive pruning, which searches every subset of terms. With finnts' lag and rolling features and large num_terms draws, one fit took over 15 minutes (earth reported 3.5e13 subsets on a 96-month series) while the other methods take under a second. Automatic grids now choose from backward, none, forward and seqrep. Only MARS rows of saved hyperparameter grids change, since the seed is reset per model; update_forecast() refits saved runs with their stored hyperparameters. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
…e 5, AB#81707) The installer only compared finnts' own minimum versions, so a newly installed tune 2.1.0 could sit next to dials 1.4.0 (finnts asks for 1.3.0, tune needs 1.4.3) and fail to load. Walk every installed package reachable through Depends and Imports, read from metadata so nothing is loaded: the old check loaded each dependency and the helper check loaded ellmer, which on Windows stops R from upgrading those packages in the same session. Upgrade unmet packages for up to three rounds before loading finnts. Detect cores with parallelly when installed, matching finnts, so container and scheduler limits apply. Document core detection, worker reuse and measured worker memory. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Brings in main through #302 (skill 0.3.6, package 0.7.0.9021). No conflicts; main's reworded combo-trimming NEWS bullet is kept. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
…707) Main already uses 0.7.0.9021, so this branch's unreleased notes move to the single 0.7.0.9022 section. The skill changelog records the dependency-tree installer check and parallelly core detection. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
When a model errors on every resample, tune keeps the error as a note: tuning then stops with "All models failed" and fit_resamples() returns no .pred column, so train_models(), ensemble refits and update_forecast() failed with "Column .pred doesn't exist" and the cause was lost. Synapse run 4's C5 update hit this for every series with a foundation-model winner because the session had no Chronos or TimesFM credentials. Raise "Model 'x' failed on every validation or back-test split: <first tune error note>" instead. Failure flow, fallbacks and saved outputs are unchanged. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Phase 4 listed forecast files first and re-read stale results for every get_forecast_data() call, including return_type = "sdf". Spark reads those tables from storage, not through the mount, and main's bulk-path contract test failed on this branch. List and settle only data-frame reads; Spark tables keep the single wildcard-path read. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Synapse run 4 (C10b) showed a no-cache mount adds no slowdown, and it avoids the stale-file wait after Spark stages. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
devtools::check() on the branch reported an undeclared-package WARNING for ps:: and vctrs:: in two branch tests, NOTE items for the foreach variable chunk and reset_spark()'s assign(envir = .GlobalEnv), and single-worker pools in multi-worker tests: --as-cran sets _R_CHECK_LIMIT_CORES_, which caps parallelly::availableCores() at two. Check worker processes and register the fake collect() method with base R, declare chunk, assign sc through a variable as main did, and lift the core cap for non-CRAN test runs only (setup-cores.R). Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Calls tail() without utils::, and the foreach/dplyr names job, best_rows and expected_key, raised "no visible global function or binding" NOTEs that CRAN expects fixed; tail() also relied on utils being attached. Qualify it as utils::tail(), as elsewhere in finnts, and declare the names. Exclude .git from builds: in a git worktree it is a file, which R CMD build only skips as a directory. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
main took 0.7.0.9022 with PR #303, so this branch moves past it. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
There was a problem hiding this comment.
🟡 Changes recommended
Outer local pools lack error-path cleanup, so training or storage failures can leave Finn’s future plan active and workers running.
4 open issues
What changed in this PR
This PR updates finnts to 0.7.0.9023, modernizing parallel forecasting and improving reliability across local and Spark workflows.
Changes:
- Reuses worker pools for tuning and refitting, respects CPU limits, and accelerates model averaging.
- Improves Spark preparation, mounted-storage reads, multistep fitting, and failure reporting.
- Raises dependency requirements, updates installation tooling and documentation, and adds regression coverage.
| File | Description |
|---|---|
| vignettes/tips-for-production.Rmd | Adds cluster dependency-upgrade guidance. |
| vignettes/parallel-processing.Rmd | Explains worker reuse, Spark sizing, and mount configuration. |
| vignettes/feature-selection.Rmd | Clarifies LOFO scope and parallel execution. |
| tests/testthat/test-summarize-models-feature-selection.R | Stubs separately tested LOFO work. |
| tests/testthat/test-read-write-data.R | Covers CSV compatibility, Parquet reads, and storage retries. |
| tests/testthat/test-prep_models.R | Checks automatic MARS pruning choices. |
| tests/testthat/test-prep_data.R | Compares Spark and local transformation metadata. |
| tests/testthat/test-parallel-util.R | Tests pool lifecycle, core budgets, and Spark reconnects. |
| tests/testthat/test-multistep.R | Tests worker registration and unattached fitting. |
| tests/testthat/test-inner-parallel-workers.R | Compares parallel and sequential forecasts. |
| tests/testthat/test-hierarchical.R | Tests reconciliation retries without repeated listings. |
| tests/testthat/test-final_models.R | Tests averaging equivalence and failure recovery. |
| tests/testthat/test-feature-selection-lofo.R | Tests LOFO results, parallelism, and pool reuse. |
| tests/testthat/test-deprecated-api-replacements.R | Checks replacement grid and rolling-window behavior. |
| tests/testthat/test-custom-model-c1-drivers.R | Aligns Spark mocks with grouped-worker behavior. |
| tests/testthat/test-chronos.R | Checks underlying resampling error messages. |
| tests/testthat/test-agent-update-forecast.R | Covers mixed metadata and worker context. |
| tests/testthat/test-agent-forecast-selection.R | Tests forecast retries with reused file listings. |
| tests/testthat/test-agent-artifact-reads.R | Tests delayed model and forecast visibility. |
| tests/testthat/setup-cores.R | Lifts the check-time core cap for non-CRAN tests. |
| tests/testthat/helper-spark-apply.R | Adds grouped Spark execution emulation. |
| skills/finn/version.json | Records the skill release and changes. |
| skills/finn/tests/test_skill.R | Tests core detection and dependency traversal. |
| skills/finn/scripts/install_finnts.R | Checks transitive dependencies before loading packages. |
| skills/finn/scripts/finn_common.R | Uses allocation-aware CPU detection. |
| skills/finn/references/updates.md | Documents transitive dependency requirements. |
| skills/finn/references/setup.md | Clarifies dependency upgrades during installation. |
| skills/finn/references/parallelism.md | Updates worker reuse and resource guidance. |
| skills/finn/README.md | Clarifies CPU-based worker budgeting. |
| R/utility.R | Adds compatible CSV row binding and future import. |
| R/train_models.R | Reuses inner pools and improves resampling errors. |
| R/read_write_data.R | Adds settled reads and safer Parquet handling. |
| R/prep_data.R | Fixes Spark schemas and replaces deprecated rolling calls. |
| R/parallel_util.R | Implements reusable pools, future plans, and Spark budgets. |
| R/multistep_xgboost.R | Registers package-qualified worker fitting. |
| R/multistep_svm_rbf.R | Registers package-qualified worker fitting. |
| R/multistep_svm_poly.R | Registers package-qualified worker fitting. |
| R/multistep_mars.R | Registers package-qualified worker fitting. |
| R/multistep_glmnet.R | Registers package-qualified worker fitting. |
| R/multistep_cubist.R | Registers package-qualified worker fitting. |
| R/models.R | Removes legacy helpers and excludes exhaustive MARS pruning. |
| R/hierarchy.R | Retries mounted forecasts and qualifies utility calls. |
| R/forecast_time_series.R | Shares an inner pool across modeling stages. |
| R/final_models.R | Optimizes averaging and retries reconciled reads. |
| R/feature_selection.R | Fixes LOFO recipe calls and forwards core limits. |
| R/ensemble_models.R | Reuses pools and replaces deprecated grid generation. |
| R/custom_models.R | Updates allowed custom-model dependencies. |
| R/custom_model_validation.R | Qualifies the date-validation utility call. |
| R/custom_model_drafts.R | Qualifies diagnostic-history utility calls. |
| R/agent_update_forecast.R | Shares pools and improves metadata and refit handling. |
| R/agent_summarize_models.R | Retries temporarily unavailable summary inputs. |
| R/agent_iterate_forecast.R | Shares iteration pools and retries forecast reads. |
| NEWS.md | Documents improvements, fixes, and migration requirements. |
| NAMESPACE | Adds the generated future.apply import. |
| man/update_forecast.Rd | Updates core-allocation documentation. |
| man/train_models.Rd | Updates core-allocation documentation. |
| man/prep_data.Rd | Documents allocation-aware core limits. |
| man/iterate_forecast.Rd | Updates core-allocation documentation. |
| man/forecast_time_series.Rd | Updates core-allocation documentation. |
| man/final_models.Rd | Updates core-allocation documentation. |
| man/ensemble_models.Rd | Updates core-allocation documentation. |
| DESCRIPTION | Bumps the version and revises dependency requirements. |
| cran-comments.md | Updates dependency counts and R compatibility notes. |
| AGENTS.md | Documents bounded reads for mounted Spark outputs. |
| .Rbuildignore | Excludes Git metadata from package builds. |
| .claude/rules/optional-dependencies.md | Removes the obsolete R 4.0 support requirement. |
Review effort: Balanced
…1707) Address PR #304 review. par_start() points the session's future plan at a new local pool, but stages ended it only on success: an error left the caller with Finn's plan and running workers. Add par_end_on_exit(), which registers par_end() for the pool object on stage exit, after every stage-level par_start() (13 sites). A failing train_models() test covers it, and the dispatch test's par_end() mock now collects from a live pool only. Gate worker tests on usable workers (get_cores) instead of host CPUs, compare the skill's check-limit core test with parallelly under the same limit, and skip the Parquet prep_data case without arrow. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
There was a problem hiding this comment.
🟡 Changes recommended
The readiness check can accept a stale forecast before best-model selection is visible, causing every trained model to be marked non-winning and an incorrect summary to be saved without retrying.
1 open issue
4 resolved since last review
Review effort: Balanced
A mount can return a non-empty forecast copy that train_models() wrote before selection, or miss the winning average file, so the summary read now waits until the series has a Best_Model "Yes" row. Off-mount reads are unchanged. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
There was a problem hiding this comment.
🔵 Needs a closer look
The pool lifecycle, Spark, and mounted-storage changes require installed-worker and cross-platform integration validation, while even focused checks could not run because Rscript is unavailable.
No open issues 🎉
1 resolved since last review
Review effort: Balanced
… pin (AB#81707) - Tests that need two local workers skip when the CRAN profile's core limit leaves one; the grouped-hierarchy test keeps its sequential checks. - Examples that call set_run_info() use distinct run names, so examples run within the same second no longer share a run. - The recipe-read worker test compares resolved paths (macOS /var is a symlink) and reports every CSV the workers read when it fails. - Pin seriation 1.5.8 on R 4.1; seriation 1.6.0, imported by corrr, requires R 4.3. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
pak installs the suggested packages of the pinned seriation 1.5.8, and dbscan now requires R 4.3. finnts doesn't use dbscan. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
pak reports one blocked suggestion per run (dbscan, then smacof via Hmisc), so ignore every suggested package of the pinned seriation 1.5.8 outside finnts' dependency tree. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>


This pull request updates the
finntspackage to version 0.7.0.9023, introducing major improvements to parallel processing, Spark compatibility, dependency requirements, and bug fixes. The changes enhance performance, reliability, and compatibility, especially for parallel and Spark-based workflows, while also raising minimum package and R version requirements. Several deprecated dependencies are removed, and new ones are added to support improved parallelization. The update also includes important bug fixes and clarifies documentation and dependency management.Key changes:
Parallel Processing & Performance Improvements
inner_parallel = TRUEnow tunes and refits models in parallel usingtune2.x and thefutureecosystem, reusing worker pools, respecting CPU limits, and improving Spark integration. Pools are sized dynamically, and worker processes are reused across series for efficiency. [1] [2] [3] [4] [5]Spark & Storage Robustness
read_settled()to handle delayed file visibility and stale content, reducing intermittent missing file errors and improving reliability in distributed environments. [1] [2] [3] [4] [5]Dependency & Compatibility Updates
tune(>= 2.0.1),dials,parsnip,recipes,rsample, andworkflows. Addsfuture,future.apply, andparallellyto Imports; removes deprecatedplyrandgtools. [1] [2] [3] [4] [5] [6]Bug Fixes
.predcolumn.finntsis loaded but not attached.Breaking Changes
Other improvements:
Please review the updated documentation and NEWS for full details on migration and new capabilities.