Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
P
Poulpe
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
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
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
octobus
Poulpe
Commits
96a19a19
Commit
96a19a19
authored
2 years ago
by
Pierre-Yves David
Browse files
Options
Downloads
Patches
Plain Diff
benchmark: factor DATA-VARS parsing in a `data_vars_key` function
Lets repeat ourself less.
parent
5747709d
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
python-libs/poulpe/benchmarks.py
+20
-14
20 additions, 14 deletions
python-libs/poulpe/benchmarks.py
with
20 additions
and
14 deletions
python-libs/poulpe/benchmarks.py
+
20
−
14
View file @
96a19a19
...
...
@@ -10,6 +10,12 @@
)
def
data_vars_key
(
value
):
"""
return the data-vars key for a value if any, None otherwise
"""
if
value
is
not
None
and
value
.
startswith
(
'
DATA-VARS:
'
):
return
value
.
split
(
'
:
'
,
1
)[
1
]
return
None
class
UnknownBenchmarkMethod
(
KeyError
):
pass
...
...
@@ -160,8 +166,8 @@
def
needed_vars
(
self
):
variables
=
set
()
cwd
=
self
.
get_var
(
'
simple-command.cwd
'
)
if
cwd
is
not
None
and
cwd
.
startswith
(
'
DATA-VARS:
'
):
key
=
cwd
.
split
(
'
:
'
,
1
)[
1
]
key
=
data_vars_key
(
cwd
)
if
key
is
not
None
:
variables
.
add
(
key
)
# XXX missing the "variable" part
return
variables
...
...
@@ -252,11 +258,11 @@
variables
=
{}
if
variables_data
is
not
None
:
for
name
,
value
in
variables_data
.
items
():
if
value
.
startswith
(
'
DATA-VARS:
'
):
key
=
value
.
split
(
'
:
'
,
1
)[
1
]
key
=
data_vars_key
(
value
)
if
key
is
not
None
:
value
=
get_var
(
key
)
assert
value
is
not
None
variables
[
name
]
=
value
self
.
command
=
self
.
base_command
.
format
(
**
variables
)
...
...
@@ -257,11 +263,11 @@
value
=
get_var
(
key
)
assert
value
is
not
None
variables
[
name
]
=
value
self
.
command
=
self
.
base_command
.
format
(
**
variables
)
if
self
.
cwd
.
startswith
(
'
DATA-VARS:
'
):
key
=
self
.
cwd
.
split
(
'
:
'
,
1
)[
1
]
key
=
data_vars_key
(
self
.
cwd
)
if
key
is
not
None
:
self
.
cwd
=
get_var
(
key
)
class
PerfBenchmark
(
Benchmark
):
...
...
@@ -312,9 +318,9 @@
def
needed_vars
(
self
):
variables
=
set
()
cwd
=
self
.
get_var
(
'
hg-perf-ext.cwd
'
)
if
cwd
is
not
None
and
cwd
.
startswith
(
'
DATA-VARS:
'
):
key
=
cwd
.
split
(
'
:
'
,
1
)[
1
]
key
=
data_vars_key
(
cwd
)
if
key
is
not
None
:
variables
.
add
(
key
)
args
=
self
.
get_var
(
'
hg-perf-ext.args
'
)
if
args
is
not
None
:
for
value
in
args
:
...
...
@@ -317,9 +323,9 @@
variables
.
add
(
key
)
args
=
self
.
get_var
(
'
hg-perf-ext.args
'
)
if
args
is
not
None
:
for
value
in
args
:
if
value
.
startswith
(
'
DATA-VARS:
'
):
key
=
value
.
split
(
'
:
'
,
1
)[
1
]
key
=
data_vars_key
(
value
)
if
key
is
not
None
:
variables
.
add
(
key
)
return
variables
...
...
@@ -345,8 +351,8 @@
cwd
=
data_env_path
cfg_cwd
=
self
.
get_var
(
'
hg-perf-ext.cwd
'
)
if
cfg_cwd
is
not
None
:
if
cfg_cwd
.
startswith
(
'
DATA-VARS:
'
):
key
=
cfg_cwd
.
split
(
'
:
'
,
1
)[
1
]
key
=
data_vars_key
(
cfg_cwd
)
if
key
is
not
None
:
cfg_cwd
=
data_var
(
key
)
cwd
=
os
.
path
.
join
(
cwd
,
cfg_cwd
)
...
...
@@ -372,8 +378,8 @@
]
def
filter_arg
(
value
):
if
value
.
startswith
(
'
DATA-VARS:
'
):
key
=
value
.
split
(
'
:
'
,
1
)[
1
]
key
=
data_vars_key
(
value
)
if
key
is
not
None
:
value
=
data_var
(
key
)
assert
value
is
not
None
return
value
...
...
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