Use store-backed run discovery for asset commands

This commit is contained in:
Bryan Helmkamp 2026-04-01 22:24:57 -04:00
parent c7317c35f5
commit 50ca4e4498
4 changed files with 14 additions and 10 deletions

View file

@ -4,17 +4,19 @@ use anyhow::{Context, Result, bail};
use fabro_config::FabroSettingsExt;
use fabro_store::RuntimeState;
use fabro_workflow::assets::{AssetEntry, scan_assets};
use fabro_workflow::run_lookup::{resolve_run, runs_base};
use fabro_workflow::run_lookup::{resolve_run_combined, runs_base};
use crate::args::{AssetCpArgs, GlobalArgs};
use crate::shared::{print_json_pretty, split_run_path};
use crate::store;
use crate::user_config::load_user_settings_with_globals;
pub(super) fn cp_command(args: &AssetCpArgs, globals: &GlobalArgs) -> Result<()> {
pub(super) async fn cp_command(args: &AssetCpArgs, globals: &GlobalArgs) -> Result<()> {
let cli_settings = load_user_settings_with_globals(globals)?;
let base = runs_base(&cli_settings.storage_dir());
let store = store::build_store(&cli_settings.storage_dir())?;
let (run_id, asset_path) = parse_source(&args.source);
let run = resolve_run(&base, run_id)?;
let run = resolve_run_combined(store.as_ref(), &base, run_id).await?;
let runtime_state = RuntimeState::new(&run.path);
let entries = scan_assets(
&runtime_state.assets_dir(),

View file

@ -2,16 +2,18 @@ use anyhow::Result;
use fabro_config::FabroSettingsExt;
use fabro_store::RuntimeState;
use fabro_workflow::assets::scan_assets;
use fabro_workflow::run_lookup::{resolve_run, runs_base};
use fabro_workflow::run_lookup::{resolve_run_combined, runs_base};
use crate::args::{AssetListArgs, GlobalArgs};
use crate::shared::format_size;
use crate::store;
use crate::user_config::load_user_settings_with_globals;
pub(super) fn list_command(args: &AssetListArgs, globals: &GlobalArgs) -> Result<()> {
pub(super) async fn list_command(args: &AssetListArgs, globals: &GlobalArgs) -> Result<()> {
let cli_settings = load_user_settings_with_globals(globals)?;
let base = runs_base(&cli_settings.storage_dir());
let run = resolve_run(&base, &args.run_id)?;
let store = store::build_store(&cli_settings.storage_dir())?;
let run = resolve_run_combined(store.as_ref(), &base, &args.run_id).await?;
let runtime_state = RuntimeState::new(&run.path);
let entries = scan_assets(
&runtime_state.assets_dir(),

View file

@ -5,9 +5,9 @@ use anyhow::Result;
use crate::args::{AssetCommand, AssetNamespace, GlobalArgs};
pub(crate) fn dispatch(ns: AssetNamespace, globals: &GlobalArgs) -> Result<()> {
pub(crate) async fn dispatch(ns: AssetNamespace, globals: &GlobalArgs) -> Result<()> {
match ns.command {
AssetCommand::List(args) => list::list_command(&args, globals),
AssetCommand::Cp(args) => cp::cp_command(&args, globals),
AssetCommand::List(args) => list::list_command(&args, globals).await,
AssetCommand::Cp(args) => cp::cp_command(&args, globals).await,
}
}

View file

@ -182,7 +182,7 @@ async fn main_inner() -> (String, Result<()>) {
Commands::Parse(args) => {
commands::parse::run(&args, &globals)?;
}
Commands::Asset(ns) => commands::asset::dispatch(ns, &globals)?,
Commands::Asset(ns) => commands::asset::dispatch(ns, &globals).await?,
Commands::Store(ns) => commands::store::dispatch(ns, &globals).await?,
Commands::RunsCmd(cmd) => commands::runs::dispatch(cmd, &globals).await?,
Commands::Model { command } => commands::model::execute(command, &globals).await?,