Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
beat.web
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
Model registry
Operate
Environments
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
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
beat
beat.web
Commits
3efeff1b
Commit
3efeff1b
authored
5 years ago
by
Samuel GAIST
Committed by
Samuel GAIST
5 years ago
Browse files
Options
Downloads
Patches
Plain Diff
[experiments][api] Make use of py3_cmp
parent
77a07c89
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
beat/web/experiments/api.py
+4
-13
4 additions, 13 deletions
beat/web/experiments/api.py
with
4 additions
and
13 deletions
beat/web/experiments/api.py
+
4
−
13
View file @
3efeff1b
...
...
@@ -62,7 +62,7 @@ from ..common.api import (
from
..common.mixins
import
CommonContextMixin
from
..common.exceptions
import
ShareError
from
..common.serializers
import
SharingSerializer
from
..common.utils
import
validate_restructuredtext
,
ensure_html
from
..common.utils
import
validate_restructuredtext
,
ensure_html
,
py3_cmp
from
..toolchains.models
import
Toolchain
...
...
@@ -111,15 +111,6 @@ class ListCreateExperimentsView(ListCreateContributionView):
def
_getStatusLabel
(
status
):
return
[
s
for
s
in
Experiment
.
STATUS
if
s
[
0
]
==
status
][
0
][
1
]
def
_cmp
(
a
,
b
):
"""
cmp is not available anymore in Python 3. This method is implemetend
as recommended in the documentation for this kind of use case.
Based on:
https://docs.python.org/3.0/whatsnew/3.0.html#ordering-comparisons
"""
return
(
a
>
b
)
-
(
a
<
b
)
def
_custom_compare
(
exp1
,
exp2
):
PENDING
=
_getStatusLabel
(
Experiment
.
PENDING
)
...
...
@@ -129,7 +120,7 @@ class ListCreateExperimentsView(ListCreateContributionView):
if
exp2
[
"
status
"
]
!=
PENDING
:
return
-
1
elif
exp1
[
"
creation_date
"
]
!=
exp2
[
"
creation_date
"
]:
return
_cmp
(
exp1
[
"
creation_date
"
],
exp2
[
"
creation_date
"
])
return
py3
_cmp
(
exp1
[
"
creation_date
"
],
exp2
[
"
creation_date
"
])
else
:
return
1
elif
exp2
[
"
status
"
]
==
PENDING
:
...
...
@@ -142,7 +133,7 @@ class ListCreateExperimentsView(ListCreateContributionView):
]
if
(
exp1
[
"
status
"
]
in
tier3_states
)
and
(
exp2
[
"
status
"
]
in
tier3_states
):
return
_cmp
(
exp2
[
"
end_date
"
],
exp1
[
"
end_date
"
])
return
py3
_cmp
(
exp2
[
"
end_date
"
],
exp1
[
"
end_date
"
])
elif
(
exp1
[
"
status
"
]
in
tier3_states
)
and
(
exp2
[
"
status
"
]
not
in
tier3_states
):
...
...
@@ -152,7 +143,7 @@ class ListCreateExperimentsView(ListCreateContributionView):
):
return
1
return
_cmp
(
exp1
[
"
start_date
"
],
exp2
[
"
start_date
"
])
return
py3
_cmp
(
exp1
[
"
start_date
"
],
exp2
[
"
start_date
"
])
# Retrieve the experiments
fields_to_return_original
=
self
.
get_serializer_fields
(
request
)
...
...
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