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
028dc8bf
Commit
028dc8bf
authored
6 years ago
by
juga
Browse files
Options
Downloads
Patches
Plain Diff
Add args to generate to scale as torflow too
parent
e64ecd47
No related branches found
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
sbws/core/generate.py
+14
-3
14 additions, 3 deletions
sbws/core/generate.py
with
14 additions
and
3 deletions
sbws/core/generate.py
+
14
−
3
View file @
028dc8bf
from
sbws.globals
import
(
fail_hard
,
SBWS_SCALE_CONSTANT
)
from
sbws.globals
import
(
fail_hard
,
SBWS_SCALE_CONSTANT
,
TORFLOW_SCALING
,
SBWS_SCALING
)
from
sbws.lib.v3bwfile
import
V3BWFile
from
sbws.lib.resultdump
import
load_recent_results_in_datadir
from
argparse
import
ArgumentDefaultsHelpFormatter
...
...
@@ -31,11 +32,14 @@ def gen_parser(sub):
p
.
add_argument
(
'
--scale-constant
'
,
default
=
SBWS_SCALE_CONSTANT
,
type
=
int
,
help
=
'
When scaling bw weights, scale them using this const
'
'
multiplied by the number of measured relays
'
)
p
.
add_argument
(
'
--scale
'
,
action
=
'
store_true
'
,
p
.
add_argument
(
'
--scale
_sbws
'
,
action
=
'
store_true
'
,
help
=
'
If specified, do not use bandwidth values as they
'
'
are, but scale them such that we have a budget of
'
'
scale_constant * num_measured_relays = bandwidth to give
'
'
out, and we do so proportionally
'
)
p
.
add_argument
(
'
-t
'
,
'
--scale_torflow
'
,
action
=
'
store_true
'
,
help
=
'
If specified, do not use bandwidth values as they
'
'
are, but scale them in the way Torflow does.
'
)
def
main
(
args
,
conf
):
...
...
@@ -46,6 +50,12 @@ def main(args, conf):
fail_hard
(
'
%s does not exist
'
,
datadir
)
if
args
.
scale_constant
<
1
:
fail_hard
(
'
--scale-constant must be positive
'
)
if
args
.
scale_sbws
:
scaling_method
=
SBWS_SCALING
elif
args
.
scale_torflow
:
scaling_method
=
TORFLOW_SCALING
else
:
scaling_method
=
None
fresh_days
=
conf
.
getint
(
'
general
'
,
'
data_period
'
)
reset_bw_ipv4_changes
=
conf
.
getboolean
(
'
general
'
,
'
reset_bw_ipv4_changes
'
)
...
...
@@ -59,7 +69,8 @@ def main(args, conf):
'
ran sbws scanner recently?)
'
)
return
state_fpath
=
conf
.
getpath
(
'
paths
'
,
'
state_fname
'
)
bw_file
=
V3BWFile
.
from_results
(
results
,
state_fpath
,
args
.
scale_constant
)
bw_file
=
V3BWFile
.
from_results
(
results
,
state_fpath
,
args
.
scale_constant
,
scaling_method
)
output
=
args
.
output
or
\
conf
.
getpath
(
'
paths
'
,
'
v3bw_fname
'
).
format
(
now_fname
())
bw_file
.
write
(
output
)
...
...
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