Spaces:
Running
Running
Upload folder using huggingface_hub
Browse files- app.py +2 -2
- src/graph.py +11 -1
app.py
CHANGED
|
@@ -349,5 +349,5 @@ with gr.Blocks(title="AnomalyOS", theme=gr.themes.Soft()) as demo:
|
|
| 349 |
analytics_out = gr.Textbox(label="System Stats", lines=15)
|
| 350 |
|
| 351 |
btn_refresh.click()
|
| 352 |
-
|
| 353 |
-
|
|
|
|
| 349 |
analytics_out = gr.Textbox(label="System Stats", lines=15)
|
| 350 |
|
| 351 |
btn_refresh.click()
|
| 352 |
+
fn=load_analytics,
|
| 353 |
+
inputs=[],
|
src/graph.py
CHANGED
|
@@ -29,7 +29,17 @@ class KnowledgeGraph:
|
|
| 29 |
with open(path) as f:
|
| 30 |
data = json.load(f)
|
| 31 |
|
| 32 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 33 |
print(f"Knowledge graph loaded: "
|
| 34 |
f"{self.graph.number_of_nodes()} nodes, "
|
| 35 |
f"{self.graph.number_of_edges()} edges")
|
|
|
|
| 29 |
with open(path) as f:
|
| 30 |
data = json.load(f)
|
| 31 |
|
| 32 |
+
# Handle both old and new NetworkX node-link formats
|
| 33 |
+
if "links" in data:
|
| 34 |
+
data["links"] = data.get("links", [])
|
| 35 |
+
try:
|
| 36 |
+
self.graph = nx.node_link_graph(data)
|
| 37 |
+
except Exception:
|
| 38 |
+
# Try with edges key for older NetworkX
|
| 39 |
+
if "links" in data and "edges" not in data:
|
| 40 |
+
data["edges"] = data.pop("links")
|
| 41 |
+
self.graph = nx.node_link_graph(data)
|
| 42 |
+
|
| 43 |
print(f"Knowledge graph loaded: "
|
| 44 |
f"{self.graph.number_of_nodes()} nodes, "
|
| 45 |
f"{self.graph.number_of_edges()} edges")
|