Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
beat
beat.cmdline
Commits
adad9d5f
Commit
adad9d5f
authored
May 07, 2019
by
Samuel GAIST
Browse files
[common] Refactor handling of Plotterparameter
This asset also has a storage therefore properly handle it.
parent
e961fc91
Changes
2
Hide whitespace changes
Inline
Side-by-side
beat/cmdline/common.py
View file @
adad9d5f
...
...
@@ -53,6 +53,7 @@ from beat.core import dataformat
from
beat.core
import
database
from
beat.core
import
library
from
beat.core
import
plotter
from
beat.core
import
plotterparameter
from
beat.core
import
protocoltemplate
from
beat.core
import
algorithm
from
beat.core
import
toolchain
...
...
@@ -94,6 +95,7 @@ TYPE_VALIDATOR = {
"library"
:
library
.
Library
,
"algorithm"
:
algorithm
.
Algorithm
,
"plotter"
:
plotter
.
Plotter
,
"plotterparameter"
:
plotterparameter
.
Plotterparameter
,
"protocoltemplate"
:
protocoltemplate
.
ProtocolTemplate
,
"toolchain"
:
toolchain
.
Toolchain
,
"experiment"
:
experiment
.
Experiment
,
...
...
@@ -105,14 +107,15 @@ TYPE_STORAGE = {
"library"
:
library
.
Storage
,
"algorithm"
:
algorithm
.
Storage
,
"plotter"
:
plotter
.
Storage
,
"plotterparameter"
:
plotterparameter
.
Storage
,
"protocoltemplate"
:
protocoltemplate
.
Storage
,
"toolchain"
:
toolchain
.
Storage
,
"experiment"
:
experiment
.
Storage
,
}
NOSTORAGE
=
[
"plotterparameter"
]
NOSTORAGE
=
[]
TYPE_NOSTORAGE
=
{
"plotterparameter"
:
"plotterparameters"
}
TYPE_NOSTORAGE
=
{}
TYPE_PLURAL
=
{
"dataformat"
:
"dataformats"
,
...
...
@@ -159,19 +162,12 @@ class Selector(object):
"algorithm"
,
"library"
,
"toolchain"
,
"experiment"
,
"plotter"
,
"plotterparameter"
,
"protocoltemplate"
,
]
self
.
__forkables
=
[
"dataformat"
,
"database"
,
"algorithm"
,
"library"
,
"toolchain"
,
"experiment"
,
"protocoltemplate"
,
]
self
.
__forkables
=
self
.
__versionables
+
[
"experiment"
]
if
os
.
path
.
exists
(
self
.
path
):
self
.
load
()
...
...
@@ -214,30 +210,36 @@ class Selector(object):
return
self
.
__fork
[
type
].
get
(
name
)
def
version
(
self
,
type
,
src
,
dst
):
def
version
(
self
,
type
_
,
src
,
dst
):
"""Registers that object ``dst`` is a new version of object ``src``"""
if
not
type_
in
self
.
__version
:
raise
RuntimeError
(
"Can't create new version of {}"
.
format
(
type_
))
logger
.
info
(
"`%s/%s' is a new version of `%s/%s'"
,
TYPE_PLURAL
[
type
],
TYPE_PLURAL
[
type
_
],
dst
,
TYPE_PLURAL
[
type
],
TYPE_PLURAL
[
type
_
],
src
,
)
self
.
__version
[
type
][
dst
]
=
src
self
.
__version
[
type
_
][
dst
]
=
src
def
version_of
(
self
,
type
,
name
):
def
version_of
(
self
,
type
_
,
name
):
"""Returns the name of the originating version object or ``None``"""
return
self
.
__version
[
type
].
get
(
name
)
if
type_
not
in
self
.
__version
:
return
None
def
delete
(
self
,
type
,
name
):
return
self
.
__version
[
type_
].
get
(
name
)
def
delete
(
self
,
type_
,
name
):
"""Forgets about an object that was being tracked"""
if
name
in
self
.
__fork
[
type
]:
del
self
.
__fork
[
type
][
name
]
if
name
in
self
.
__version
[
type
]:
del
self
.
__version
[
type
][
name
]
if
name
in
self
.
__fork
[
type
_
]:
del
self
.
__fork
[
type
_
][
name
]
if
type_
in
self
.
__version
and
name
in
self
.
__version
[
type
_
]:
del
self
.
__version
[
type
_
][
name
]
def
load
(
self
):
"""Loads contents from file"""
...
...
@@ -923,7 +925,16 @@ def pull(webapi, prefix, type, names, fields, force, indentation):
if
data
is
None
:
status
+=
1
# error
continue
storage
.
save
(
**
data
)
if
type
==
"plotterparameter"
:
declaration
=
{
"description"
:
data
[
"short_description"
],
"plotter"
:
data
[
"plotter"
],
"data"
:
data
[
"data"
]
}
storage
.
save
(
declaration
)
else
:
storage
.
save
(
**
data
)
available
.
add
(
name
)
else
:
# other workflow with no storage (i.e.: plotterparameter)
...
...
beat/cmdline/plotters.py
View file @
adad9d5f
...
...
@@ -46,6 +46,7 @@ from PIL import Image
from
beat.core
import
plotter
from
beat.core
import
dataformat
from
beat.core.plotterparameter
import
Storage
as
PPStorage
from
.
import
common
from
.
import
commands
...
...
@@ -259,7 +260,7 @@ def plot_impl(
with
open
(
os
.
path
.
join
(
prefix
,
common
.
TYPE_NOSTORAGE
[
"plotterparameter"
]
,
PPStorage
.
asset_folder
,
plotterparameter
+
".json"
,
),
"r"
,
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment