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
c990fa11
Commit
c990fa11
authored
6 years ago
by
Samuel GAIST
Browse files
Options
Downloads
Patches
Plain Diff
[experiments][api] Fix key search in dictionaries
parent
49d76162
No related branches found
Branches containing commit
No related tags found
Tags containing commit
2 merge requests
!255
1.4.x
,
!242
Py3 compatibility
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
beat/web/experiments/api.py
+13
-13
13 additions, 13 deletions
beat/web/experiments/api.py
with
13 additions
and
13 deletions
beat/web/experiments/api.py
+
13
−
13
View file @
c990fa11
...
@@ -157,7 +157,7 @@ class ListCreateExperimentsView(ListCreateContributionView):
...
@@ -157,7 +157,7 @@ class ListCreateExperimentsView(ListCreateContributionView):
def
post
(
self
,
request
,
author_name
):
def
post
(
self
,
request
,
author_name
):
data
=
request
.
data
data
=
request
.
data
if
data
.
has_key
(
'
name
'
)
:
if
'
name
'
in
data
:
if
not
(
isinstance
(
data
[
'
name
'
],
six
.
string_types
)):
if
not
(
isinstance
(
data
[
'
name
'
],
six
.
string_types
)):
return
BadRequestResponse
(
'
Invalid name
'
)
return
BadRequestResponse
(
'
Invalid name
'
)
...
@@ -170,7 +170,7 @@ class ListCreateExperimentsView(ListCreateContributionView):
...
@@ -170,7 +170,7 @@ class ListCreateExperimentsView(ListCreateContributionView):
else
:
else
:
name
=
None
name
=
None
if
data
.
has_key
(
'
short_description
'
)
:
if
'
short_description
'
in
data
:
if
not
(
isinstance
(
data
[
'
short_description
'
],
six
.
string_types
)):
if
not
(
isinstance
(
data
[
'
short_description
'
],
six
.
string_types
)):
return
BadRequestResponse
(
'
Invalid short_description
'
)
return
BadRequestResponse
(
'
Invalid short_description
'
)
...
@@ -183,7 +183,7 @@ class ListCreateExperimentsView(ListCreateContributionView):
...
@@ -183,7 +183,7 @@ class ListCreateExperimentsView(ListCreateContributionView):
else
:
else
:
short_description
=
''
short_description
=
''
if
data
.
has_key
(
'
description
'
)
:
if
'
description
'
in
data
:
if
not
(
isinstance
(
data
[
'
description
'
],
six
.
string_types
)):
if
not
(
isinstance
(
data
[
'
description
'
],
six
.
string_types
)):
raise
serializers
.
ValidationError
({
'
description
'
:
'
Invalid description data
'
})
raise
serializers
.
ValidationError
({
'
description
'
:
'
Invalid description data
'
})
description
=
data
[
'
description
'
]
description
=
data
[
'
description
'
]
...
@@ -194,13 +194,13 @@ class ListCreateExperimentsView(ListCreateContributionView):
...
@@ -194,13 +194,13 @@ class ListCreateExperimentsView(ListCreateContributionView):
else
:
else
:
description
=
None
description
=
None
if
not
(
data
.
has_key
(
'
toolchain
'
))
:
if
'
toolchain
'
not
in
data
:
return
BadRequestResponse
(
'
Must indicate a toolchain name
'
)
return
BadRequestResponse
(
'
Must indicate a toolchain name
'
)
if
not
(
isinstance
(
data
[
'
toolchain
'
],
six
.
string_types
)):
if
not
(
isinstance
(
data
[
'
toolchain
'
],
six
.
string_types
)):
return
BadRequestResponse
(
'
Invalid toolchain name
'
)
return
BadRequestResponse
(
'
Invalid toolchain name
'
)
if
not
(
data
.
has_key
(
'
declaration
'
))
:
if
'
declaration
'
not
in
data
:
return
BadRequestResponse
(
'
Must indicate a declaration
'
)
return
BadRequestResponse
(
'
Must indicate a declaration
'
)
if
not
(
isinstance
(
data
[
'
declaration
'
],
dict
))
and
\
if
not
(
isinstance
(
data
[
'
declaration
'
],
dict
))
and
\
...
@@ -341,17 +341,17 @@ class RetrieveUpdateDestroyExperimentView(RetrieveUpdateDestroyContributionView)
...
@@ -341,17 +341,17 @@ class RetrieveUpdateDestroyExperimentView(RetrieveUpdateDestroyContributionView)
return
BadRequestResponse
(
'
Experiment is not in pending state
'
)
return
BadRequestResponse
(
'
Experiment is not in pending state
'
)
for
key
in
data
.
keys
():
for
key
in
data
.
keys
():
if
not
(
key
in
allowed_fields
)
:
if
key
not
in
allowed_fields
:
return
BadRequestResponse
(
'
Experiment is not in pending state
'
)
return
BadRequestResponse
(
'
Experiment is not in pending state
'
)
# Available fields (not returned by default):
# Available fields (not returned by default):
# - html_description
# - html_description
if
request
.
GET
.
has_key
(
'
fields
'
)
:
if
'
fields
'
in
request
.
GET
:
fields_to_return
=
request
.
GET
[
'
fields
'
].
split
(
'
,
'
)
fields_to_return
=
request
.
GET
[
'
fields
'
].
split
(
'
,
'
)
else
:
else
:
fields_to_return
=
[]
fields_to_return
=
[]
if
data
.
has_key
(
'
name
'
)
:
if
'
name
'
in
data
:
if
not
(
isinstance
(
data
[
'
name
'
],
six
.
string_types
)):
if
not
(
isinstance
(
data
[
'
name
'
],
six
.
string_types
)):
raise
serializers
.
ValidationError
({
'
name
'
:
'
Invalid name
'
})
raise
serializers
.
ValidationError
({
'
name
'
:
'
Invalid name
'
})
name
=
data
[
'
name
'
].
replace
(
'
'
,
'
_
'
)
name
=
data
[
'
name
'
].
replace
(
'
'
,
'
_
'
)
...
@@ -361,14 +361,14 @@ class RetrieveUpdateDestroyExperimentView(RetrieveUpdateDestroyContributionView)
...
@@ -361,14 +361,14 @@ class RetrieveUpdateDestroyExperimentView(RetrieveUpdateDestroyContributionView)
else
:
else
:
name
=
None
name
=
None
if
data
.
has_key
(
'
short_description
'
)
:
if
'
short_description
'
in
data
:
if
not
(
isinstance
(
data
[
'
short_description
'
],
six
.
string_types
)):
if
not
(
isinstance
(
data
[
'
short_description
'
],
six
.
string_types
)):
raise
serializers
.
ValidationError
({
'
short_description
'
:
'
Invalid short_description
'
})
raise
serializers
.
ValidationError
({
'
short_description
'
:
'
Invalid short_description
'
})
short_description
=
data
[
'
short_description
'
]
short_description
=
data
[
'
short_description
'
]
else
:
else
:
short_description
=
None
short_description
=
None
if
data
.
has_key
(
'
description
'
)
:
if
'
description
'
in
data
:
if
not
(
isinstance
(
data
[
'
description
'
],
six
.
string_types
)):
if
not
(
isinstance
(
data
[
'
description
'
],
six
.
string_types
)):
raise
serializers
.
ValidationError
({
'
description
'
:
'
Invalid description data
'
})
raise
serializers
.
ValidationError
({
'
description
'
:
'
Invalid description data
'
})
description
=
data
[
'
description
'
]
description
=
data
[
'
description
'
]
...
@@ -379,7 +379,7 @@ class RetrieveUpdateDestroyExperimentView(RetrieveUpdateDestroyContributionView)
...
@@ -379,7 +379,7 @@ class RetrieveUpdateDestroyExperimentView(RetrieveUpdateDestroyContributionView)
else
:
else
:
description
=
None
description
=
None
if
data
.
has_key
(
'
declaration
'
)
:
if
'
declaration
'
in
data
:
if
not
(
isinstance
(
data
[
'
declaration
'
],
dict
))
and
\
if
not
(
isinstance
(
data
[
'
declaration
'
],
dict
))
and
\
not
(
isinstance
(
data
[
'
declaration
'
],
six
.
string_types
)):
not
(
isinstance
(
data
[
'
declaration
'
],
six
.
string_types
)):
raise
serializers
.
ValidationError
({
'
declaration
'
:
'
Invalid declaration
'
})
raise
serializers
.
ValidationError
({
'
declaration
'
:
'
Invalid declaration
'
})
...
@@ -394,7 +394,7 @@ class RetrieveUpdateDestroyExperimentView(RetrieveUpdateDestroyContributionView)
...
@@ -394,7 +394,7 @@ class RetrieveUpdateDestroyExperimentView(RetrieveUpdateDestroyContributionView)
except
:
except
:
raise
serializers
.
ValidationError
({
'
declaration
'
:
'
Invalid declaration data
'
})
raise
serializers
.
ValidationError
({
'
declaration
'
:
'
Invalid declaration data
'
})
if
de
claration
.
has_key
(
'
descrip
tion
'
)
:
if
'
de
scription
'
in
declara
tion
:
if
short_description
is
not
None
:
if
short_description
is
not
None
:
raise
serializers
.
ValidationError
({
'
short_description
'
:
'
A short description is already provided in the experiment declaration
'
})
raise
serializers
.
ValidationError
({
'
short_description
'
:
'
A short description is already provided in the experiment declaration
'
})
...
@@ -409,7 +409,7 @@ class RetrieveUpdateDestroyExperimentView(RetrieveUpdateDestroyContributionView)
...
@@ -409,7 +409,7 @@ class RetrieveUpdateDestroyExperimentView(RetrieveUpdateDestroyContributionView)
raise
serializers
.
ValidationError
({
'
short_description
'
:
'
Short description too long
'
})
raise
serializers
.
ValidationError
({
'
short_description
'
:
'
Short description too long
'
})
if
data
.
has_key
(
'
toolchain
'
)
:
if
'
toolchain
'
in
data
:
if
not
(
isinstance
(
data
[
'
toolchain
'
],
six
.
string_types
)):
if
not
(
isinstance
(
data
[
'
toolchain
'
],
six
.
string_types
)):
raise
serializers
.
ValidationError
({
'
toolchain
'
:
'
Invalid toolchain name
'
})
raise
serializers
.
ValidationError
({
'
toolchain
'
:
'
Invalid toolchain name
'
})
...
...
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