Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 14 additions & 12 deletions crates/nemoclaw-build/src/images.rs
Original file line number Diff line number Diff line change
Expand Up @@ -208,20 +208,22 @@ pub fn plan(
// target. Name the platforms that build it instead; other selections, such
// as groups or the reference image, keep Bake's own resolution.
let supported = platform_harnesses(root, platform)?;
let mut others = None;
for name in selection.iter().filter(|name| !supported.contains(name)) {
if others.is_none() {
others = Some(
PLATFORMS
.into_iter()
.filter(|other| *other != platform)
.map(|other| Ok((other, platform_harnesses(root, other)?)))
.collect::<Result<Vec<_>>>()?,
);
}
let unsupported: Vec<&String> = selection
.iter()
.filter(|name| !supported.contains(name))
.collect();
let others = if unsupported.is_empty() {
Vec::new()
} else {
PLATFORMS
.into_iter()
.filter(|other| *other != platform)
.map(|other| Ok((other, platform_harnesses(root, other)?)))
.collect::<Result<Vec<_>>>()?
};
for name in unsupported {
let building: Vec<&str> = others
.iter()
.flatten()
.filter(|(_, harnesses)| harnesses.contains(name))
.map(|(other, _)| *other)
.collect();
Expand Down
32 changes: 18 additions & 14 deletions crates/nemoclaw-cli/src/formatting.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ use crate::{
};
use nemoclaw_sdk::{Error, OperationResult, Outcome};
use std::{
borrow::Cow,
collections::BTreeSet,
io::IsTerminal,
path::PathBuf,
Expand Down Expand Up @@ -91,6 +92,13 @@ impl RenderContext {
.collect()
}

fn add_warnings(&self, value: &mut serde_json::Value) {
let warnings = self.warnings();
if !warnings.is_empty() {
value["warnings"] = serde_json::json!(warnings);
}
}

fn append_warnings(&self, output: &mut String) {
let warnings = self.warnings();
if !warnings.is_empty() {
Expand Down Expand Up @@ -131,8 +139,7 @@ pub(crate) fn render(
},
OutputFormat::Json => {
let mut value = serde_json::to_value(&result)?;
let warnings = context.warnings();
if !warnings.is_empty() { value["warnings"] = serde_json::json!(warnings); }
context.add_warnings(&mut value);
if result.outcome == Outcome::Planned {
value["complete"] = serde_json::Value::Bool(result.deferred.is_empty());
}
Expand Down Expand Up @@ -608,10 +615,7 @@ pub(crate) fn render_error(
"stateDirectory": context.state_dir,
"error": { "message": message },
});
let warnings = context.warnings();
if !warnings.is_empty() {
details["warnings"] = serde_json::json!(warnings);
}
context.add_warnings(&mut details);
if let Some(input) = &context.input {
details["input"] = serde_json::json!(input);
}
Expand All @@ -631,15 +635,15 @@ pub(crate) fn render_error(
details["remainingState"] = serde_json::json!(remaining);
}
let help = match sdk {
Some(Error::SandboxChangeRefused { .. }) => Some(
"Keep this deployment's state. Use a separate deployment with a fresh UID and state directory; see docs/usage.md#choose-the-change-path. Export and destroy still use the retained configuration.".to_owned(),
),
Some(Error::SandboxStartup { .. }) => Some(
"Inspect the sandbox with OpenShell using this deployment's gateway and workspace; collect gateway and supervisor logs before cleanup.".to_owned(),
),
Some(Error::DockerModelUpdateRefused { service }) => Some(format!(
"To replace the running model container, set spec.services.{service}.updatePolicy: Recreate and apply again; the model is unavailable until the replacement starts. See docs/inference.md#set-container-limits-and-update-policy."
Some(Error::SandboxChangeRefused { .. }) => Some(Cow::Borrowed(
"Keep this deployment's state. Use a separate deployment with a fresh UID and state directory; see docs/usage.md#choose-the-change-path. Export and destroy still use the retained configuration.",
)),
Some(Error::SandboxStartup { .. }) => Some(Cow::Borrowed(
"Inspect the sandbox with OpenShell using this deployment's gateway and workspace; collect gateway and supervisor logs before cleanup.",
)),
Some(Error::DockerModelUpdateRefused { service }) => Some(Cow::Owned(format!(
"To replace the running model container, set spec.services.{service}.updatePolicy: Recreate and apply again; the model is unavailable until the replacement starts. See docs/inference.md#set-container-limits-and-update-policy."
))),
_ => None,
};
if let Some(help) = &help {
Expand Down
6 changes: 3 additions & 3 deletions crates/nemoclaw-sdk/src/state/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -432,14 +432,14 @@ impl StateBinding {

pub(crate) struct Store {
pub directory: PathBuf,
_lock: File,
lock: File,
}
impl Drop for Store {
fn drop(&mut self) {
// A concurrently spawned child can retain the shared open file
// description until exec. Closing our descriptor alone would then
// leave the deployment locked after this operation has finished.
let _ = self._lock.unlock();
let _ = self.lock.unlock();
}
}
impl Store {
Expand Down Expand Up @@ -469,7 +469,7 @@ impl Store {
})?;
Ok(Self {
directory: directory.into(),
_lock: lock,
lock,
})
}
pub fn load(&self) -> Result<Option<Record>, Error> {
Expand Down
2 changes: 1 addition & 1 deletion crates/nemoclaw-sdk/src/state/tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ fn dropping_store_releases_lock_while_a_duplicate_descriptor_remains_open() {
let store = Store::open(directory.path()).unwrap();
// Model the shared open file description inherited by a concurrent spawn
// before exec closes the child's copy, without depending on spawn timing.
let inherited = store._lock.try_clone().unwrap();
let inherited = store.lock.try_clone().unwrap();
assert!(Store::open(directory.path()).is_err());
drop(store);

Expand Down