-
The following code is from src/graphql/outlier.rs #[derive(Debug, Deserialize, SimpleObject)]
#[graphql(complex)]
pub(super) struct Outlier {
#[graphql(skip)]
pub(super) id: i64, //timestamp
#[graphql(skip)]
pub(super) events: Vec<i64>,
pub(super) size: i64,
pub(super) model_id: i32,
}
pub trait FromKeys: Sized {
/// Creates a new instance from the given keys.
///
/// # Errors
///
/// Returns an error if the key or value cannot be deserialized.
fn from_keys(keys: &[Box<[u8]>]) -> Result<Self>;
}
impl FromKeys for Outlier {
fn from_keys(keys: &[Box<[u8]>]) -> Result<Self> {
let size = i64::try_from(keys.len())?;
let mut events: Vec<i64> = Vec::new();
let keys: Vec<_> = keys.iter().take(DEFAULT_OUTLIER_SIZE).collect();
let Some(first_key) = keys.first() else {
return Err(anyhow!("Failed to read outlier's first key").into());
};
let (model_id, timestamp, _, event, _) =
bincode::DefaultOptions::new().deserialize::<RankedOutlierKey>(first_key)?;
events.push(event);
for key in keys {
let (_, _, _, event, _) =
bincode::DefaultOptions::new().deserialize::<RankedOutlierKey>(key)?;
events.push(event);
}
events.sort_unstable();
Ok(Self {
id: timestamp,
events,
size,
model_id,
})
}
} It seems that the purpose of the Outlier definition is to showcase the id along with the associated events it represents. However, the from_keys function appears to be attempting something different:
I find this a bit perplexing and am wondering whether I've overlooked something. |
Beta Was this translation helpful? Give feedback.
Replies: 3 comments 4 replies
-
@kimhanbeom Do you remember the |
Beta Was this translation helpful? Give feedback.
-
In review: src/agent/request.rs: Outlier events are stored into fn update_outliers(
store: &Store,
model_id: i32,
timestamp: i64,
outliers: &[OutlierInfo],
) -> Result<()> {
let map = store.outlier_map();
for outlier in outliers {
let key = bincode::DefaultOptions::new().serialize(&(
model_id,
timestamp,
outlier.rank,
outlier.id,
&outlier.source,
))?;
let value = bincode::DefaultOptions::new().serialize(&(outlier.distance, DEFAULT_SAVED))?;
map.insert(&key, &value)?;
}
Ok(())
} in review-web/src/graphql/outlier.rs: RankedOutlierKey is produced from Outlier event like following. type RankedOutlierKey = (i32, i64, i64, i64, String); // model_id, timestamp, rank, id, source
impl From<PreserveOutliersInput> for RankedOutlierKey {
fn from(input: PreserveOutliersInput) -> Self {
(
input.model_id,
input.timestamp,
input.rank,
input.id,
input.source,
)
}
}
The outlier event retrieved from the The code |
Beta Was this translation helpful? Give feedback.
-
Beta Was this translation helpful? Give feedback.
The outlier events are used in our Web UI and also 3-rd party UIs too. In our Web UI, outlier events are used in two ways.
Firstly, outlier events are displayed to describe a round of a model beside of model and clusters. In this UI, the outlier events are displayed to show it's content to the user. Users will gain knowledge about what type of outlier events was generated in the latest round.
Secondly, there is RankedOutlier UI. In the UI, the outlier events can be filtered or searched i…