Skip to content
GitLab
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
Alberts S
CapybaraNetty
Commits
0e82b6a1
Commit
0e82b6a1
authored
May 11, 2022
by
Alberts S
Browse files
Fixup Visualizer
parent
60508338
Changes
1
Hide whitespace changes
Inline
Side-by-side
Visualizer.py
View file @
0e82b6a1
...
...
@@ -26,10 +26,14 @@ class Visualizer(CapybaraNetty):
G_optimizations
=
await
self
.
get_host_latency_optimization_overview
(
G_simple
.
copy
())
await
self
.
draw_graphs
(
self
.
get_graph_only_improved_overview
(
G_optimizations
),
"optimizations_overview"
)
for
target
in
self
.
external_targets_for_optimizations
:
await
self
.
draw_graphs
(
self
.
get_graph_only_improved_specific_target
(
G_optimizations
,
target
),
f
"optimizations_target_
{
target
}
"
,
)
target_filtered_graph
=
self
.
get_graph_only_improved_specific_target
(
G_optimizations
,
target
)
if
target_filtered_graph
.
number_of_nodes
()
>
0
:
await
self
.
draw_graphs
(
target_filtered_graph
,
f
"optimizations_target_
{
target
}
"
,
)
else
:
self
.
__logger
.
debug
(
f
"Not drawing graph for
{
target
=
}
since the filtered graph is empty"
)
else
:
self
.
__logger
.
warning
(
"Doing nothing since G is empty"
)
...
...
@@ -39,7 +43,14 @@ class Visualizer(CapybaraNetty):
host
=
result
[
"from_name"
]
dest
=
result
[
"to_name"
]
time
=
int
(
result
[
"time"
])
G
.
add_edge
(
host
,
dest
,
weight
=
time
,
color
=
"black"
)
result_kind
=
result
[
"result_kind"
]
if
result_kind
==
"external"
:
attrs
=
{
"weight"
:
time
,
}
else
:
attrs
=
{
f
"weight_
{
result_kind
}
"
:
time
}
G
.
add_edge
(
host
,
dest
,
**
attrs
,
color
=
"black"
)
G
.
nodes
[
host
][
"type"
]
=
result
[
"from_type"
]
G
.
nodes
[
dest
][
"type"
]
=
result
[
"to_type"
]
return
G
...
...
@@ -60,11 +71,13 @@ class Visualizer(CapybaraNetty):
for
key
,
path
in
paths
.
items
():
if
len
(
path
)
>
2
and
not
(
path
[
0
]
in
self
.
external_targets_for_optimizations
or
path
[
-
1
]
in
self
.
external_targets_for_optimizations
and
path
[
-
1
]
in
self
.
external_targets_for_optimizations
):
optimized_ms
=
G
[
key
][
path
[
0
]][
"weight"
]
-
lengths
[
key
]
if
optimized_ms
<
self
.
optimization_threshold_ms
:
self
.
__logger
.
debug
(
f
"IGNORED OPTIMIZATION:
{
optimized_ms
:
<
3
d
}
ms
{
'->'
.
join
(
path
[
::
-
1
])
}
"
)
self
.
__logger
.
debug
(
f
"VISUALIZER IGNORED OPTIMIZATION:
{
optimized_ms
:
<
3
d
}
ms
{
'->'
.
join
(
path
[
::
-
1
])
}
"
)
else
:
color
=
palette
[
palette_index
]
palette_index
+=
1
...
...
@@ -79,7 +92,9 @@ class Visualizer(CapybaraNetty):
G
.
nodes
[
node
][
"improved_path"
]
=
True
G
.
nodes
[
node
].
setdefault
(
"improved_path_targets"
,
[]).
append
(
target
)
self
.
__logger
.
info
(
f
"VIABLE OPTIMIZATION:
{
optimized_ms
:
<
3
d
}
ms
{
'->'
.
join
(
path
[
::
-
1
])
}
"
)
self
.
__logger
.
info
(
f
"VISUALIZER VIABLE OPTIMIZATION:
{
optimized_ms
:
<
3
d
}
ms
{
'->'
.
join
(
path
[
::
-
1
])
}
"
)
return
G
def
get_graph_only_improved_overview
(
self
,
G
:
nx
.
Graph
):
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment