Skip to content

rpkg: dvs_init returns config as a single-row tibble#170

Open
CGMossa wants to merge 2 commits into
mainfrom
feat/dvs-init-returns-tibble
Open

rpkg: dvs_init returns config as a single-row tibble#170
CGMossa wants to merge 2 commits into
mainfrom
feat/dvs-init-returns-tibble

Conversation

@CGMossa
Copy link
Copy Markdown
Contributor

@CGMossa CGMossa commented Apr 29, 2026

AI-written details

Summary

  • dvs_init previously returned list(status = "initialized") and printed DVS Initialized to stderr, giving R callers no programmatic view of what was actually configured.
  • Now returns a one-row tibble:
    > dvs_init(storage_path = "/tmp/storage", compression = "none",
    +          metadata_folder_name = "custom_meta", group = "staff")
    # A tibble: 1 x 4
      compression metadata_folder_name backend_path  backend_group
      <chr>       <chr>                <chr>         <chr>
    1 none        custom_meta          /tmp/storage  staff
  • Return type changes from Result<List> to Result<ColumnarDataFrame>; builds with vec_to_dataframe(&[config])?. No view struct: Backend already has #[serde(untagged)], so Backend::Local(LocalBackend{..}) flattens transparently into backend_path / backend_group via miniextendr's recursive nested-struct flattening. cli: Option<CliConfig> is skipped at init time by its existing skip_serializing_if = "Option::is_none".
  • Drops the invisible flag and the r_println!("DVS Initialized") line. The printed tibble is now the visible signal.
  • R wrapper wraps the result in tibble::as_tibble() for parity with dvs_add / dvs_get / dvs_status.
  • Adds a testthat case asserting shape, column names, and values.
  • Adds ui/main_init.sh exercising the option matrix (defaults, --no-compression, custom metadata folder, group, all combined, storage-inside-repo guard) so the CLI dvs.toml can be eyeballed alongside the R tibble.
  • justfile includes init in ui_names so just ui-publish picks it up.

Carved out: ui-trace cleanup (xtrace filter + deferred set -x) moved to #198.

Test plan

  • just rpkg-test passes (cargo + testthat, including the new init tibble test)
  • bash ui/main_init.sh runs to completion across all 6 scenarios; CLI dvs.toml matches R tibble values

Notes

  • When metadata_folder_name is left at its default (None), it appears as a list-column with a single NULL rather than NA_character_, because miniextendr's columnar serializer cannot infer the inner type from a bare None. With any explicit string it's a clean <chr> column. Functional but not pretty; left as follow-up.

Drafted by Claude (claude-opus-4-7). Reviewed by the author.

@dpastoor
Copy link
Copy Markdown
Member

like it!

@CGMossa
Copy link
Copy Markdown
Contributor Author

CGMossa commented Apr 30, 2026

This is a good start, but I would like to try and resolve A2-ai/miniextendr#307 before going further with this. The Option<..> fields become list-cols, even though they ought not to. This is a limitation due to the serde serialization model, and R's nuanced/typed NA. I would like these inits to be stackable, and as list-cols, they are not, if in another invocation an actual value is passed.

CGMossa added 2 commits May 17, 2026 11:09
Replaces the placeholder list("status" = "initialized") return with a
columnar data frame that flattens dvs::config::Config into atomic
columns:

  | compression | metadata_folder_name | backend_path | backend_group |

`Backend::Local(LocalBackend{..})` flattens because Backend already
carries `#[serde(untagged)]`; `cli: Option<CliConfig>` is skipped at
init time via the existing `skip_serializing_if = "Option::is_none"`.
miniextendr's columnar serializer recursively flattens nested structs
into `parent_child` columns, so no view struct is needed.

The R wrapper now wraps the result with `tibble::as_tibble()` for
parity with dvs_add / dvs_get / dvs_status.

Adds ui/main_init.sh exercising the option matrix (defaults, no
compression, custom metadata folder, group, all combined, and the
storage-inside-repo guard) so CLI dvs.toml can be eyeballed against
the R tibble side-by-side.
Adds `init` to ui_names so `just ui-run` / `ui-render` / `ui-publish`
pick up ui/main_init.sh and write to ui/output/ui-init.html.
@CGMossa CGMossa force-pushed the feat/dvs-init-returns-tibble branch from 1c771ba to 1f3c91e Compare May 17, 2026 09:16
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.

2 participants