Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
C
cb-util
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
Christoph Alt
cb-util
Commits
d36547a6
Commit
d36547a6
authored
1 year ago
by
Christoph Alt
Browse files
Options
Downloads
Patches
Plain Diff
fixed the variable encoding/escaping within the generated queries
parent
b0a7a2fc
Branches
Branches containing commit
No related tags found
No related merge requests found
Pipeline
#61321
passed
1 year ago
Stage: test
Stage: deploy
Stage: trigger
Changes
3
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
dashboards/influx_queries.py
+1
-1
1 addition, 1 deletion
dashboards/influx_queries.py
tests/test_dashboard_creation.py
+1
-1
1 addition, 1 deletion
tests/test_dashboard_creation.py
tests/test_influx_queries.py
+33
-24
33 additions, 24 deletions
tests/test_influx_queries.py
with
35 additions
and
26 deletions
dashboards/influx_queries.py
+
1
−
1
View file @
d36547a6
...
@@ -60,7 +60,7 @@ def get_variable_condition(variable_name: str, *, tag_key: str = None) -> str:
...
@@ -60,7 +60,7 @@ def get_variable_condition(variable_name: str, *, tag_key: str = None) -> str:
clean_lhs
=
clean_rhs
clean_lhs
=
clean_rhs
if
not
clean_rhs
:
if
not
clean_rhs
:
raise
ValueError
(
"
Empty variable name
"
)
raise
ValueError
(
"
Empty variable name
"
)
return
f
'"
{
clean_lhs
}
"
=~ /^$
{
clean_rhs
}
$/
'
return
f
'"
{
clean_lhs
}
"
=~ /^${
{
{
clean_rhs
}
:regex}}
$/
'
def
join_conditions
(
conditions
:
List
[
str
],
operators
:
Union
[
List
[
str
],
str
]):
def
join_conditions
(
conditions
:
List
[
str
],
operators
:
Union
[
List
[
str
],
str
]):
...
...
This diff is collapsed.
Click to expand it.
tests/test_dashboard_creation.py
+
1
−
1
View file @
d36547a6
...
@@ -15,7 +15,7 @@ measurment_name = 'UniformGridGPU'
...
@@ -15,7 +15,7 @@ measurment_name = 'UniformGridGPU'
q1
=
Query
(
q1
=
Query
(
select_
=
'
mlupsPerProcess
'
,
select_
=
'
mlupsPerProcess
'
,
from_
=
measurment_name
,
from_
=
measurment_name
,
where_
=
'"
collisionSetup
"
=~ /^$collisionSetup$/ AND
"
host
"
=~ /^$host$/ AND
"
cellsPerBlock_0
"
=~ /^$cellsPerBlock_0$/
'
,
where_
=
'"
collisionSetup
"
=~ /^$
{
collisionSetup
:regex}
$/ AND
"
host
"
=~ /^$
{
host
:regex}
$/ AND
"
cellsPerBlock_0
"
=~ /^$
{
cellsPerBlock_0
:regex}
$/
'
,
group_by
=
[
group_by
=
[
"
blocks_0
"
,
"
blocks_0
"
,
"
blocks_1
"
,
"
blocks_1
"
,
...
...
This diff is collapsed.
Click to expand it.
tests/test_influx_queries.py
+
33
−
24
View file @
d36547a6
import
pytest
import
pytest
from
dashboards.influx_queries
import
(
Query
,
get_variable_condition
,
from
dashboards.influx_queries
import
(
join_conditions
,
show_tag_values
)
Query
,
get_variable_condition
,
join_conditions
,
show_tag_values
,
)
def
test_query
():
def
test_query
():
q
=
Query
(
q
=
Query
(
select_
=
'
mlupsPerProcess
'
,
select_
=
"
mlupsPerProcess
"
,
from_
=
'
UniformGridGPU
'
,
from_
=
"
UniformGridGPU
"
,
where_
=
'"
host
"
=~ /^$host$/ AND
"
collisionSetup
"
=~ /^$collisionSetup$/
'
,
where_
=
'"
host
"
=~ /^$
{
host
:regex}
$/ AND
"
collisionSetup
"
=~ /^$
{
collisionSetup
:regex}
$/
'
,
group_by
=
[
group_by
=
[
"
blocks_0
"
,
"
blocks_0
"
,
"
blocks_1
"
,
"
blocks_1
"
,
...
@@ -21,28 +25,30 @@ def test_query():
...
@@ -21,28 +25,30 @@ def test_query():
"
gpuBlockSize_2
"
,
"
gpuBlockSize_2
"
,
"
collisionSetup
"
,
"
collisionSetup
"
,
"
stencil
"
,
"
stencil
"
,
"
streamingPattern
"
"
streamingPattern
"
,
]
]
,
)
)
q1
=
(
'
SELECT
"
mlupsPerProcess
"
'
q1
=
(
'
FROM
"
UniformGridGPU
"
'
'
SELECT
"
mlupsPerProcess
"
'
'
WHERE (
"
host
"
=~ /^$host$/ AND
"
collisionSetup
"
=~ /^$collisionSetup$/) AND $timeFilter
'
'
FROM
"
UniformGridGPU
"
'
'
GROUP BY
"
blocks_0
"
,
"
blocks_1
"
,
"
blocks_2
"
,
'
'
WHERE (
"
host
"
=~ /^${host:regex}$/ AND
"
collisionSetup
"
=~ /^${collisionSetup:regex}$/) AND $timeFilter
'
'"
cellsPerBlock_0
"
,
"
cellsPerBlock_1
"
,
"
cellsPerBlock_2
"
,
'
'
GROUP BY
"
blocks_0
"
,
"
blocks_1
"
,
"
blocks_2
"
,
'
'"
gpuBlockSize_0
"
,
"
gpuBlockSize_1
"
,
"
gpuBlockSize_2
"
,
'
'"
cellsPerBlock_0
"
,
"
cellsPerBlock_1
"
,
"
cellsPerBlock_2
"
,
'
'"
collisionSetup
"
,
"
stencil
"
,
"
streamingPattern
"'
)
'"
gpuBlockSize_0
"
,
"
gpuBlockSize_1
"
,
"
gpuBlockSize_2
"
,
'
'"
collisionSetup
"
,
"
stencil
"
,
"
streamingPattern
"'
)
assert
q1
==
str
(
q
)
assert
q1
==
str
(
q
)
def
test_show_tag_values
():
def
test_show_tag_values
():
s
=
show_tag_values
(
"
UniformGridGPU
"
,
"
host
"
)
s
=
show_tag_values
(
"
UniformGridGPU
"
,
"
host
"
)
assert
s
==
'
SHOW TAG VALUES FROM
\
"
UniformGridGPU
\
"
WITH key =
\
"
host
\
"
'
assert
s
==
'
SHOW TAG VALUES FROM
"
UniformGridGPU
"
WITH key =
"
host
"'
def
test_get_variable_condtion
():
def
test_get_variable_condtion
():
assert
get_variable_condition
(
"
host
"
)
==
'"
host
"
=~ /^$host$/
'
assert
get_variable_condition
(
"
host
"
)
==
'"
host
"
=~ /^$
{
host
:regex}
$/
'
assert
get_variable_condition
(
"
host
"
)
==
'"
host
"
=~ /^$host$/
'
assert
get_variable_condition
(
"
host
"
)
==
'"
host
"
=~ /^$
{
host
:regex}
$/
'
with
pytest
.
raises
(
ValueError
):
with
pytest
.
raises
(
ValueError
):
get_variable_condition
(
""
)
get_variable_condition
(
""
)
with
pytest
.
raises
(
ValueError
):
with
pytest
.
raises
(
ValueError
):
...
@@ -55,21 +61,24 @@ def test_join_conditions_two():
...
@@ -55,21 +61,24 @@ def test_join_conditions_two():
h
=
get_variable_condition
(
"
host
"
)
h
=
get_variable_condition
(
"
host
"
)
c
=
get_variable_condition
(
"
collisionSetup
"
)
c
=
get_variable_condition
(
"
collisionSetup
"
)
actual
=
join_conditions
([
h
,
c
],
"
AND
"
)
actual
=
join_conditions
([
h
,
c
],
"
AND
"
)
excpected
=
'"
host
"
=~ /^$host$/ AND
"
collisionSetup
"
=~ /^$collisionSetup$/
'
excpected
=
'"
host
"
=~ /^$
{
host
:regex}
$/ AND
"
collisionSetup
"
=~ /^$
{
collisionSetup
:regex}
$/
'
assert
actual
==
excpected
assert
actual
==
excpected
def
test_join_conditions_three
():
def
test_join_conditions_three
():
conds
=
[
get_variable_condition
(
name
)
for
name
in
[
"
host
"
,
conds
=
[
"
collisionSetup
"
,
get_variable_condition
(
name
)
"
cellsPerBlock_0
"
]]
for
name
in
[
"
host
"
,
"
collisionSetup
"
,
"
cellsPerBlock_0
"
]
]
# excpected = '"host" =~ /^$host$/ AND "collisionSetup" =~ /^$collisionSetup$/'
# excpected = '"host" =~ /^$host$/ AND "collisionSetup" =~ /^$collisionSetup$/'
assert
join_conditions
(
conds
,
"
AND
"
)
==
"
AND
"
.
join
(
conds
)
assert
join_conditions
(
conds
,
"
AND
"
)
==
"
AND
"
.
join
(
conds
)
assert
join_conditions
(
conds
,
[
"
AND
"
,
"
AND
"
])
==
"
AND
"
.
join
(
conds
)
assert
join_conditions
(
conds
,
[
"
AND
"
,
"
AND
"
])
==
"
AND
"
.
join
(
conds
)
assert
join_conditions
(
conds
,
[
"
AND
"
])
==
"
AND
"
.
join
(
conds
)
assert
join_conditions
(
conds
,
[
"
AND
"
])
==
"
AND
"
.
join
(
conds
)
assert
join_conditions
(
conds
,
[
"
OR
"
])
==
"
OR
"
.
join
(
conds
)
assert
join_conditions
(
conds
,
[
"
OR
"
])
==
"
OR
"
.
join
(
conds
)
excpected
=
(
'"
host
"
=~ /^$host$/
'
excpected
=
(
'
AND
"
collisionSetup
"
=~ /^$collisionSetup$/
'
'"
host
"
=~ /^${host:regex}$/
'
'
OR
"
cellsPerBlock_0
"
=~ /^$cellsPerBlock_0$/
'
)
'
AND
"
collisionSetup
"
=~ /^${collisionSetup:regex}$/
'
'
OR
"
cellsPerBlock_0
"
=~ /^${cellsPerBlock_0:regex}$/
'
)
assert
join_conditions
(
conds
,
[
"
AND
"
,
"
OR
"
])
==
excpected
assert
join_conditions
(
conds
,
[
"
AND
"
,
"
OR
"
])
==
excpected
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