InsightNet is a Python-based tool for analyzing local routing models by inferring the global state of a network and listing all possible alive/failed edge combinations for a given local state. It includes both a CLI and an API, supports multiple output formats (CSV, JSON, JSONL, DOT), and is containerized with Docker for easy deployment and reproducibility.
-
Clone the repository
git clone https://github.com/zachathanasiadis/InsightNet.git cd InsightNet -
Install dependencies
poetry install
The repository includes example files to help you get started:
sample_graphs/– Contains example input graph JSON files for testing the CLI.sample_requests/– Contains example API request JSON files for testing the API.
Run the CLI tool with:
python -m insightnet \
--input-json path/to/input.json \
--current-state edge,node \
--output path/to/output.csvRequired Arguments:
--input-json(-i): Path to the input JSON file containing the routing model and graph data.--current-state(-s): The edge and node of the state to be queried, separated by a comma.--output(-o): Output file path with extension (.csv,.json,.jsonl,.dot).
Required CLI Input JSON Fields:
routing_model(string): The name of the routing model.nodes(list of strings): List of node names.edge_to_node_mapping(list): Each item specifies an edge and the nodes it connects:edge(int): Edge identifier.nodes(list of strings): Nodes connected by this edge.
routing_table(list of dictionaries): Each item specifies the routing rules for a node.
Example Command:
python -m insightnet -i sample_graphs/graph4.json -s 2,A -o results/output.jsonlExample Output (results/output.jsonl):
{"path": [[2, "A"], [null, "B"]], "alive_edges": [2], "failed_edges": [3]}
{"path": [[2, "A"], [2, "B"], [null, "A"]], "alive_edges": [2], "failed_edges": [1, 3]}
{"path": [[2, "A"], [3, "B"], [null, "C"]], "alive_edges": [2, 3], "failed_edges": [1]}
{"path": [[2, "A"], [3, "B"], [3, "C"], [null, "B"]], "alive_edges": [2, 3], "failed_edges": [1]}
{"path": [[2, "A"], [3, "B"], [3, "C"], [2, "B"], [null, "A"]], "alive_edges": [2, 3], "failed_edges": [1]}Run the API with Docker
-
Build the Docker image:
docker build -t insightnet-api . -
Run the API container:
docker run -p 8000:8000 insightnet-api
The API will be available at http://localhost:8000.
Endpoint:
POST /infer
Required Request Body Fields:
routing_model(string): The name of the routing model.nodes(list of strings): List of node names.edge_to_node_mapping(list): Each item specifies an edge and the nodes it connects:edge(int): Edge identifier.nodes(list of strings): Nodes connected by this edge.
routing_table(list of dictionaries): Each item specifies the routing rules for a node.current_state(string): State to be queried, formatted as"edge,node".
Example Request:
curl -X POST "http://localhost:8000/infer" \
-H "Content-Type: application/json" \
-d @sample_requests/request1.jsonExample Response:
{
"results": [
{
"path": [[1,"v1"],[null,"v2"]],
"alive_edges": [1],
"failed_edges": [2]
},
{
"path": [[1,"v1"],[1,"v2"],[null,"v1"]],
"alive_edges": [1],
"failed_edges": [2]
},
{
"path": [[1,"v1"],[2,"v2"],[null,"v3"]],
"alive_edges": [1,2],
"failed_edges": []
},
{
"path": [[1,"v1"],[2,"v2"],[2,"v3"],[null,"v2"]],
"alive_edges": [1,2],
"failed_edges": []
},
{
"path": [[1,"v1"],[2,"v2"],[2,"v3"],[1,"v2"],[null,"v1"]],
"alive_edges": [1,2],
"failed_edges": []
}
]
}- Zacharias Athanasiadis (Github)
- Csaba Györgyi (Github) – Project advisor, for guidance and feedback throughout the development of InsightNet.