Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
S
sbws
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Container Registry
Model registry
Operate
Environments
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
juga
sbws
Commits
5cd41577
Unverified
Commit
5cd41577
authored
6 years ago
by
juga
Committed by
GitHub
6 years ago
Browse files
Options
Downloads
Plain Diff
Merge pull request #253 from juga0/ticket27688_graphs_stats
Ticket27688 graphs stats
parents
d0ca906c
6a6c0090
No related branches found
No related tags found
No related merge requests found
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
CHANGELOG.md
+2
-0
2 additions, 0 deletions
CHANGELOG.md
sbws/core/generate.py
+1
-1
1 addition, 1 deletion
sbws/core/generate.py
sbws/lib/v3bwfile.py
+67
-0
67 additions, 0 deletions
sbws/lib/v3bwfile.py
with
70 additions
and
1 deletion
CHANGELOG.md
+
2
−
0
View file @
5cd41577
...
...
@@ -12,6 +12,8 @@ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.
-
Add system physical requirements section to INSTALL (#26937)
-
Warn when there is not enough disk space (#26937)
-
Implement Torflow scaling (#27108)
-
Create methods to easy graph generation and obtain statistics
to compare with current torflow results.(#27688)
### Fixed
...
...
This diff is collapsed.
Click to expand it.
sbws/core/generate.py
+
1
−
1
View file @
5cd41577
...
...
@@ -74,4 +74,4 @@ def main(args, conf):
output
=
args
.
output
or
\
conf
.
getpath
(
'
paths
'
,
'
v3bw_fname
'
).
format
(
now_fname
())
bw_file
.
write
(
output
)
log
.
info
(
'
Mean bandwidth per line: %f
"
KiB
"'
,
bw_file
.
mean_bw
)
bw_file
.
info_stats
This diff is collapsed.
Click to expand it.
sbws/lib/v3bwfile.py
+
67
−
0
View file @
5cd41577
...
...
@@ -139,6 +139,17 @@ class V3BWHeader(object):
assert
isinstance
(
text
,
str
)
return
self
.
from_lines_v110
(
text
.
split
(
LINE_SEP
))
@classmethod
def
from_lines_v100
(
cls
,
lines
):
"""
:param list lines: list of lines to parse
:returns: tuple of V3BWHeader object and non-header lines
"""
assert
isinstance
(
lines
,
list
)
h
=
cls
(
lines
[
0
])
# last line is new line
return
h
,
lines
[
1
:
-
1
]
@staticmethod
def
generator_started_from_file
(
state_fpath
):
'''
...
...
@@ -429,6 +440,27 @@ class V3BWFile(object):
f
=
cls
(
header
,
bw_lines
)
return
f
@classmethod
def
from_v110_fpath
(
cls
,
fpath
):
log
.
info
(
'
Parsing bandwidth file %s
'
,
fpath
)
with
open
(
fpath
)
as
fd
:
text
=
fd
.
read
()
all_lines
=
text
.
split
(
LINE_SEP
)
header
,
lines
=
V3BWHeader
.
from_lines_v110
(
all_lines
)
bw_lines
=
[
V3BWLine
.
from_bw_line_v110
(
line
)
for
line
in
lines
]
return
cls
(
header
,
bw_lines
)
@classmethod
def
from_v100_fpath
(
cls
,
fpath
):
log
.
info
(
'
Parsing bandwidth file %s
'
,
fpath
)
with
open
(
fpath
)
as
fd
:
text
=
fd
.
read
()
all_lines
=
text
.
split
(
LINE_SEP
)
header
,
lines
=
V3BWHeader
.
from_lines_v100
(
all_lines
)
bw_lines
=
sorted
([
V3BWLine
.
from_bw_line_v110
(
l
)
for
l
in
lines
],
key
=
lambda
l
:
l
.
bw
)
return
cls
(
header
,
bw_lines
)
@staticmethod
def
bw_kb
(
bw_lines
,
reverse
=
False
):
bw_lines_scaled
=
copy
.
deepcopy
(
bw_lines
)
...
...
@@ -691,6 +723,41 @@ class V3BWFile(object):
def
median_bw
(
self
):
return
median
([
l
.
bw
for
l
in
self
.
bw_lines
])
@property
def
max_bw
(
self
):
return
max
([
l
.
bw
for
l
in
self
.
bw_lines
])
@property
def
min_bw
(
self
):
return
min
([
l
.
bw
for
l
in
self
.
bw_lines
])
@property
def
info_stats
(
self
):
if
not
self
.
bw_lines
:
return
[
log
.
info
(
'
:
'
.
join
([
attr
,
str
(
getattr
(
self
,
attr
))]))
for
attr
in
[
'
sum_bw
'
,
'
mean_bw
'
,
'
median_bw
'
,
'
num
'
,
'
max_bw
'
,
'
min_bw
'
]]
def
bw_line_for_node_id
(
self
,
node_id
):
"""
Returns the bandwidth line for a given node fingerprint.
Used to combine data when plotting.
"""
bwl
=
[
l
for
l
in
self
.
bw_lines
if
l
.
node_id
==
node_id
]
if
bwl
:
return
bwl
[
0
]
return
None
def
to_plt
(
self
,
attrs
=
[
'
bw
'
],
sorted_by
=
None
):
"""
Return bandwidth data in a format useful for matplotlib.
Used from external tool to plot.
"""
x
=
[
i
for
i
in
range
(
0
,
self
.
num
)]
ys
=
[[
getattr
(
l
,
k
)
for
l
in
self
.
bw_lines
]
for
k
in
attrs
]
return
x
,
ys
,
attrs
def
write
(
self
,
output
):
if
output
==
'
/dev/stdout
'
:
log
.
info
(
"
Writing to stdout is not supported.
"
)
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
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!
Save comment
Cancel
Please
register
or
sign in
to comment