Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
P
pycalibration
Manage
Activity
Members
Labels
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Deploy
Model registry
Analyze
Contributor 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
calibration
pycalibration
Commits
f5cc4a41
Commit
f5cc4a41
authored
11 months ago
by
Karim Ahmed
Committed by
Philipp Schmidt
11 months ago
Browse files
Options
Downloads
Patches
Plain Diff
add tests for decide_run_parameters
parent
ca74aab2
No related branches found
No related tags found
1 merge request
!993
[Webservice] Enable two runs detectors
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
tests/test_webservice.py
+24
-5
24 additions, 5 deletions
tests/test_webservice.py
webservice/webservice.py
+4
-7
4 additions, 7 deletions
webservice/webservice.py
with
28 additions
and
12 deletions
tests/test_webservice.py
+
24
−
5
View file @
f5cc4a41
from
collections
import
namedtuple
import
datetime
as
dt
import
logging
import
sys
import
datetime
as
dt
from
collections
import
namedtuple
from
pathlib
import
Path
from
unittest
import
mock
import
pytest
from
webservice.webservice
import
decide_run_parameters
sys
.
path
.
insert
(
0
,
Path
(
__file__
).
parent
/
'
webservice
'
)
import
webservice
# noqa: import not at top of file
from
webservice.messages
import
MigrationError
# noqa: import not at top
from
webservice.webservice
import
(
# noqa: import not at top of file
check_files
,
check_run_type_skip
,
config
,
get_slurm_nice
,
get_slurm_partition
,
merge
,
parse_config
,
run_action
,
wait_on_transfer
,
get_slurm_partition
,
get_slurm_nice
,
config
,
)
VALID_BEAMTIME
=
{
...
...
@@ -444,3 +446,20 @@ async def test_skip_runs_exception(return_value, status_code, caplog):
assert
"
run information does not contain expected key
"
in
caplog
.
text
# And `False` should be returned
assert
ret
==
False
def
test_decide_run_parameters_single_run
():
assert
decide_run_parameters
([
123
],
1
)
==
{
'
run
'
:
123
}
def
test_decide_run_parameters_three_runs
():
expected
=
{
'
run-high
'
:
1
,
'
run-med
'
:
2
,
'
run-low
'
:
3
}
assert
decide_run_parameters
([
1
,
2
,
3
],
3
)
==
expected
def
test_decide_run_parameters_mismatched_runs
():
with
pytest
.
raises
(
ValueError
):
decide_run_parameters
([
1
,
2
,
3
,
4
],
3
)
with
pytest
.
raises
(
ValueError
):
decide_run_parameters
([
1
,
2
],
3
)
This diff is collapsed.
Click to expand it.
webservice/webservice.py
+
4
−
7
View file @
f5cc4a41
...
...
@@ -404,13 +404,10 @@ def decide_run_parameters(runs, expected_number_of_runs):
dict: Mapping for run notebook parameters names and values.
"""
runs_dict
=
{}
if
expected_number_of_runs
==
3
:
if
len
(
runs
)
==
1
:
return
{
'
run-high
'
:
runs
[
0
],
'
run-med
'
:
'
0
'
,
'
run-low
'
:
'
0
'
}
else
:
# len(runs) == 3
return
{
'
run-high
'
:
runs
[
0
],
'
run-med
'
:
runs
[
1
],
'
run-low
'
:
runs
[
2
]}
if
expected_number_of_runs
==
3
and
len
(
runs
)
==
1
:
return
{
'
run-high
'
:
runs
[
0
],
'
run-med
'
:
'
0
'
,
'
run-low
'
:
'
0
'
}
elif
expected_number_of_runs
==
3
and
len
(
runs
)
==
3
:
return
{
'
run-high
'
:
runs
[
0
],
'
run-med
'
:
runs
[
1
],
'
run-low
'
:
runs
[
2
]}
elif
expected_number_of_runs
==
2
and
len
(
runs
)
==
2
:
return
{
'
run-high
'
:
runs
[
0
],
'
run-low
'
:
runs
[
1
]}
elif
len
(
runs
)
==
1
:
# single run operation modes.
...
...
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