Skip to content

Commit

Permalink
fix(kubegraph): use original metadata on empty analyzer mode
Browse files Browse the repository at this point in the history
  • Loading branch information
HoKim98 committed Jun 1, 2024
1 parent 9204ea2 commit 0b9e327
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 8 deletions.
10 changes: 5 additions & 5 deletions crates/kubegraph/analyzer/llm/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -70,9 +70,9 @@ where
graph: Graph<LazyFrame, GraphMetadataRaw>,
) -> Result<Graph<LazyFrame, GraphMetadataStandard>> {
let VirtualProblemAnalyzer {
original_metadata,
original_metadata: map_from,
r#type: VirtualProblemAnalyzerLLM {},
} = problem.analyzer.clone().into_llm()?;
} = problem.analyzer.clone().try_into_llm()?;
let map_to = problem.spec.metadata;

// TODO: to be implemented
Expand All @@ -82,7 +82,7 @@ where
scope,
} = graph;
Ok(Graph {
data: data.cast(&original_metadata, &map_to),
data: data.cast(&map_from, &map_to),
metadata: map_to,
scope,
})
Expand Down Expand Up @@ -113,11 +113,11 @@ where
}

trait VirtualProblemAnalyzerExt {
fn into_llm(self) -> Result<VirtualProblemAnalyzer<VirtualProblemAnalyzerLLM>>;
fn try_into_llm(self) -> Result<VirtualProblemAnalyzer<VirtualProblemAnalyzerLLM>>;
}

impl VirtualProblemAnalyzerExt for VirtualProblemAnalyzer {
fn into_llm(self) -> Result<VirtualProblemAnalyzer<VirtualProblemAnalyzerLLM>> {
fn try_into_llm(self) -> Result<VirtualProblemAnalyzer<VirtualProblemAnalyzerLLM>> {
let Self {
original_metadata,
r#type,
Expand Down
7 changes: 4 additions & 3 deletions crates/kubegraph/vm/local/src/analyzer.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ use kubegraph_api::{
analyzer::{VirtualProblemAnalyzer, VirtualProblemAnalyzerType},
component::NetworkComponent,
frame::LazyFrame,
graph::{Graph, GraphMetadataExt, GraphMetadataRaw, GraphMetadataStandard},
graph::{Graph, GraphMetadataRaw, GraphMetadataStandard},
problem::VirtualProblem,
};
use schemars::JsonSchema;
Expand Down Expand Up @@ -119,13 +119,14 @@ impl ::kubegraph_api::analyzer::NetworkAnalyzer for NetworkAnalyzer {
Self::Disabled => {
let Graph {
data,
metadata: map_from,
metadata: _,
scope,
} = graph;
let map_from = &problem.analyzer.original_metadata;
let map_to = problem.spec.metadata;

Ok(Graph {
data: data.cast(&map_from.to_pinned(), &map_to),
data: data.cast(map_from, &map_to),
metadata: map_to,
scope,
})
Expand Down

0 comments on commit 0b9e327

Please sign in to comment.