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
921b1e45
Commit
921b1e45
authored
5 years ago
by
Samuel GAIST
Browse files
Options
Downloads
Patches
Plain Diff
[libraries][api] Replace put with serializer
parent
54200d2f
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/libraries/api.py
+20
-24
20 additions, 24 deletions
beat/web/libraries/api.py
with
20 additions
and
24 deletions
beat/web/libraries/api.py
+
20
−
24
View file @
921b1e45
...
...
@@ -29,16 +29,20 @@ from .models import Library
from
.serializers
import
LibrarySerializer
from
.serializers
import
FullLibrarySerializer
from
.serializers
import
LibraryCreationSerializer
from
.serializers
import
LibraryModSerializer
from
..code.api
import
ShareCodeView
,
RetrieveUpdateDestroyCodeView
from
..code.serializers
import
CodeDiffSerializer
from
..common.api
import
(
CheckContributionNameView
,
ListContributionView
,
ListCreateContributionView
)
from
..common.api
import
(
CheckContributionNameView
,
ListContributionView
,
ListCreateContributionView
,
)
from
..code.api
import
DiffView
#----------------------------------------------------------
#
----------------------------------------------------------
class
CheckLibraryNameView
(
CheckContributionNameView
):
...
...
@@ -46,10 +50,11 @@ class CheckLibraryNameView(CheckContributionNameView):
This view sanitizes a library name and
checks whether it is already used.
"""
model
=
Library
#----------------------------------------------------------
#
----------------------------------------------------------
class
ShareLibraryView
(
ShareCodeView
):
...
...
@@ -57,21 +62,23 @@ class ShareLibraryView(ShareCodeView):
This view allows to share a library with
other users and/or teams
"""
model
=
Library
#----------------------------------------------------------
#
----------------------------------------------------------
class
ListLibrariesView
(
ListContributionView
):
"""
List all available libraries
"""
model
=
Library
serializer_class
=
LibrarySerializer
#----------------------------------------------------------
#
----------------------------------------------------------
class
ListCreateLibrariesView
(
ListCreateContributionView
):
...
...
@@ -79,44 +86,33 @@ class ListCreateLibrariesView(ListCreateContributionView):
Read/Write end point that list the libraries available
from a given author and allows the creation of new libraries
"""
model
=
Library
serializer_class
=
LibrarySerializer
writing_serializer_class
=
LibraryCreationSerializer
namespace
=
'
api_libraries
'
namespace
=
"
api_libraries
"
#----------------------------------------------------------
#
----------------------------------------------------------
class
RetrieveUpdateDestroyLibrariesView
(
RetrieveUpdateDestroyCodeView
):
"""
Read/Write/Delete endpoint for a given library
"""
model
=
Library
serializer_class
=
FullLibrarySerializer
writing_serializer_class
=
LibraryModSerializer
def
do_update
(
self
,
request
,
author_name
,
object_name
,
version
=
None
):
modified
,
library
=
super
(
RetrieveUpdateDestroyLibrariesView
,
self
).
do_update
(
request
,
author_name
,
object_name
,
version
)
if
modified
:
# Delete existing experiments using the library (code changed)
experiments
=
[]
for
item
in
library
.
referencing
.
all
():
for
algorithm
in
item
.
used_by_algorithms
.
all
():
experiments
.
append
(
list
(
set
(
map
(
lambda
x
:
x
.
experiment
,
algorithm
.
blocks
.
iterator
()))))
for
experiment
in
set
(
experiments
):
experiment
.
delete
()
return
modified
,
library
#----------------------------------------------------------
# ----------------------------------------------------------
class
DiffLibraryView
(
DiffView
):
"""
This view shows the differences between two libraries
"""
model
=
Library
serializer_class
=
CodeDiffSerializer
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