use std::fmt;
use std::str::FromStr;
use crate::error::JammiError;
#[derive(Debug, Clone, Copy, PartialEq, Eq)]
pub enum ResultTableStatus {
Building,
Ready,
Failed,
}
impl fmt::Display for ResultTableStatus {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
match self {
Self::Building => write!(f, "building"),
Self::Ready => write!(f, "ready"),
Self::Failed => write!(f, "failed"),
}
}
}
impl FromStr for ResultTableStatus {
type Err = JammiError;
fn from_str(s: &str) -> Result<Self, Self::Err> {
match s {
"building" => Ok(Self::Building),
"ready" => Ok(Self::Ready),
"failed" => Ok(Self::Failed),
other => Err(JammiError::Catalog(format!(
"Unknown result table status: '{other}'"
))),
}
}
}
#[derive(Debug, Clone, Copy, PartialEq, Eq)]
pub enum FineTuneJobStatus {
Queued,
Running,
Completed,
Failed,
}
impl fmt::Display for FineTuneJobStatus {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
match self {
Self::Queued => write!(f, "queued"),
Self::Running => write!(f, "running"),
Self::Completed => write!(f, "completed"),
Self::Failed => write!(f, "failed"),
}
}
}
impl FromStr for FineTuneJobStatus {
type Err = JammiError;
fn from_str(s: &str) -> Result<Self, Self::Err> {
match s {
"queued" => Ok(Self::Queued),
"running" => Ok(Self::Running),
"completed" => Ok(Self::Completed),
"failed" => Ok(Self::Failed),
other => Err(JammiError::Catalog(format!(
"Unknown fine-tune job status: '{other}'"
))),
}
}
}
#[derive(Debug, Clone, Copy, PartialEq, Eq)]
pub enum EvalRunStatus {
Completed,
}
impl fmt::Display for EvalRunStatus {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
match self {
Self::Completed => write!(f, "completed"),
}
}
}
impl FromStr for EvalRunStatus {
type Err = JammiError;
fn from_str(s: &str) -> Result<Self, Self::Err> {
match s {
"completed" => Ok(Self::Completed),
other => Err(JammiError::Catalog(format!(
"Unknown eval run status: '{other}'"
))),
}
}
}
#[derive(Debug, Clone, Copy, PartialEq, Eq)]
pub enum ModelStatus {
Registered,
Loaded,
}
impl fmt::Display for ModelStatus {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
match self {
Self::Registered => write!(f, "registered"),
Self::Loaded => write!(f, "loaded"),
}
}
}
impl FromStr for ModelStatus {
type Err = JammiError;
fn from_str(s: &str) -> Result<Self, Self::Err> {
match s {
"registered" => Ok(Self::Registered),
"loaded" => Ok(Self::Loaded),
other => Err(JammiError::Catalog(format!(
"Unknown model status: '{other}'"
))),
}
}
}