Skip to content

Storage config owns data dirs + optional S3; NetCDF output to configured tmp - #291

Merged
robinskil merged 2 commits into
mainfrom
features/adjust-netcdf-tmp
Jun 21, 2026
Merged

robinskil merged 2 commits into
mainfrom
features/adjust-netcdf-tmp

Conversation

@robinskil

Copy link
Copy Markdown
Collaborator

Context

Follow-up to #290, which landed in main as the S3-single-source-of-truth + temp-output rooting work. This PR continues the storage-config cleanup and fixes a latent NetCDF output bug.

Changes

1. Data dirs move into StorageConfig; S3 becomes optional

  • StorageConfig now owns the local layout (data_dir/datasets_dir/tables_dir/tmp_dir), so ObjectStores::new(&StorageConfig) and the iceberg warehouse take one config instead of loose path args re-derived per call site — removing the multi-source temp-dir coupling structurally.
  • S3 is now Option<S3Config>: presence is the backend switch (None = local, Some = S3), replacing the separate data_lake bool.
  • S3Config.bucket is a required Stringobject_store's AmazonS3Builder requires a bucket regardless of addressing style and never infers it from the endpoint; Config::load rejects an empty bucket when S3 is enabled. endpoint/region stay optional.
  • indexes/cache remain in beacon-config's DataDirsConfig.

2. NetCDF output writes to the configured tmp dir

  • The NetCDF sinks hardcoded std::env::temp_dir(), so output: { format: netcdf } ignored config.storage.tmp_dir and wrote to a different directory than the returned file handle — yielding an empty download.
  • DatasetsStore::storage() is now exposed; NetcdfFormat::create_writer_physical_plan reads storage().tmp_dir (the factory already holds the datasets store, which carries the full StorageConfig) and passes it to NetCDFSink/NetCDFNdSink, which write there instead of the OS temp dir.
  • Read-path call sites and factory tests are untouched; only the two sink constructors changed.

Verification

  • cargo build --workspace clean.
  • cargo test --workspace --lib all green.
  • New end-to-end regression test query_with_netcdf_output_writes_under_configured_tmp runs a real NetCDF COPY and asserts the file lands under the configured tmp dir and is non-empty (failed before the fix, passes now).

StorageConfig now owns the local storage layout (data_dir/datasets_dir/
tables_dir/tmp_dir), so ObjectStores::new(&StorageConfig) and the iceberg
warehouse take a single config instead of loose path args re-derived at each
call site. This removes the multi-source temp-dir coupling structurally.

S3 is now Option<S3Config>: presence is the backend switch (None = local,
Some = S3), replacing the separate data_lake bool. Within S3Config the bucket
is a required String (object_store's AmazonS3Builder requires it regardless of
addressing style and never infers it from the endpoint); Config::load rejects
an empty bucket when S3 is enabled. endpoint/region stay optional.

beacon-config keeps indexes/cache in DataDirsConfig; the storage dirs moved to
config.storage. Updated runtime, iceberg, data-lake, and the runtime_config
test accordingly.
The NetCDF sinks hardcoded std::env::temp_dir() for the output file, so
`output: { format: netcdf }` ignored config.storage.tmp_dir and (after the
tmp-store move) wrote to a different directory than the returned file handle —
producing an empty download.

Thread the tmp directory through: expose DatasetsStore::storage(), and in
NetcdfFormat::create_writer_physical_plan read storage().tmp_dir (the factory
already holds the datasets store, which now carries the full StorageConfig) and
pass it to NetCDFSink/NetCDFNdSink, which write there instead of temp_dir().

Adds an end-to-end regression test asserting NetCDF output lands under the
configured tmp dir and is non-empty.
Copilot AI review requested due to automatic review settings June 21, 2026 09:31

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Pull request overview

This PR continues the storage-configuration consolidation by making StorageConfig the single owner of local directory layout and by switching the datasets backend selection to Option<S3Config>. It also fixes a NetCDF output regression where the sink wrote to the OS temp directory instead of the configured tmp directory, causing empty/incorrect downloads.

Changes:

  • Move data_dir / datasets_dir / tables_dir / tmp_dir into StorageConfig and simplify object store initialization to take only &StorageConfig.
  • Make S3 optional (Option<S3Config>) and require S3Config.bucket when S3 is enabled (validated in Config::load).
  • Thread the configured tmp directory into NetCDF sinks and add an end-to-end regression test ensuring NetCDF output is written under config.storage.tmp_dir.

Reviewed changes

Copilot reviewed 11 out of 11 changed files in this pull request and generated 1 comment.

Show a summary per file
File Description
beacon-object-storage/src/lib.rs Simplifies ObjectStores::new to use directory layout from StorageConfig.
beacon-object-storage/src/datasets_store.rs Switches S3 selection to Option<S3Config>, stores full StorageConfig, exposes DatasetsStore::storage().
beacon-object-storage/src/config.rs Expands StorageConfig to own local dirs; makes S3Config.bucket required and simplifies builder creation.
beacon-iceberg/src/catalog.rs Uses Option<S3Config> and storage.datasets_dir for local Iceberg warehouse initialization.
beacon-file-formats/beacon-arrow-netcdf/src/datafusion/sink.rs Updates NetCDF sinks to write into a provided output_dir instead of std::env::temp_dir().
beacon-file-formats/beacon-arrow-netcdf/src/datafusion/mod.rs Threads storage().tmp_dir into NetCDF sink construction.
beacon-data-lake/src/lib.rs Updates tmp dir wiring to use config.storage.tmp_dir.
beacon-core/tests/runtime_config.rs Updates tests to configure storage dirs via config.storage.* instead of config.data.*.
beacon-core/src/runtime.rs Updates object store initialization + Iceberg init call; adds NetCDF tmp-dir regression test.
beacon-config/src/lib.rs Constructs StorageConfig local dirs from BEACON_DATA_DIR; validates S3 bucket presence; creates dirs from config.storage.*.
beacon-config/src/error.rs Adds ConfigError::InvalidStorage for inconsistent storage settings.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment on lines +88 to 94
pub async fn local_datasets_store(datasets_dir: PathBuf) -> StorageResult<DatasetsStore> {
let storage = StorageConfig {
datasets_dir,
..StorageConfig::default()
};
create_datasets_store(&storage).await
}
@robinskil
robinskil merged commit 8587bc6 into main Jun 21, 2026
3 checks passed
@robinskil
robinskil deleted the features/adjust-netcdf-tmp branch June 27, 2026 15:27
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