Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
beat.core
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
14
Issues
14
List
Boards
Labels
Milestones
Merge Requests
3
Merge Requests
3
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
beat
beat.core
Commits
6735c859
Commit
6735c859
authored
May 03, 2019
by
Samuel GAIST
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
[protocoltemplate] Implement support for prototype
parent
1a1a8c49
Pipeline
#29848
passed with stage
in 22 minutes and 31 seconds
Changes
3
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
37 additions
and
15 deletions
+37
-15
beat/core/protocoltemplate.py
beat/core/protocoltemplate.py
+20
-15
beat/core/prototypes/protocoltemplate.json
beat/core/prototypes/protocoltemplate.json
+11
-0
beat/core/test/test_protocoltemplate.py
beat/core/test/test_protocoltemplate.py
+6
-0
No files found.
beat/core/protocoltemplate.py
View file @
6735c859
...
...
@@ -48,6 +48,7 @@ Forward importing from :py:mod:`beat.backend.python.protocoltemplate`:
import
six
from
.
import
schema
from
.
import
prototypes
from
beat.backend.python.protocoltemplate
import
Storage
from
beat.backend.python.protocoltemplate
import
(
...
...
@@ -106,18 +107,22 @@ class ProtocolTemplate(BackendProtocolTemplate):
self
.
storage
=
None
self
.
dataformats
=
{}
# preloaded dataformats
if
isinstance
(
data
,
six
.
string_types
):
# user has passed a file pointer
self
.
_name
=
data
self
.
storage
=
Storage
(
self
.
prefix
,
self
.
_name
)
data
=
self
.
storage
.
json
.
path
if
not
self
.
storage
.
json
.
exists
():
self
.
errors
.
append
(
"Protocol template declaration file not found: %s"
%
data
)
return
# this runs basic validation, including JSON loading if required
self
.
data
,
self
.
errors
=
schema
.
validate
(
"protocoltemplate"
,
data
)
if
self
.
errors
:
return
# don't proceed with the rest of validation
if
data
is
None
:
# loads prototype and validates it
self
.
data
,
self
.
errors
=
prototypes
.
load
(
"protocoltemplate"
)
assert
not
self
.
errors
,
"
\
n
* %s"
%
"
\
n
*"
.
join
(
self
.
errors
)
# nosec
else
:
if
isinstance
(
data
,
six
.
string_types
):
# user has passed a file pointer
self
.
_name
=
data
self
.
storage
=
Storage
(
self
.
prefix
,
self
.
_name
)
data
=
self
.
storage
.
json
.
path
if
not
self
.
storage
.
json
.
exists
():
self
.
errors
.
append
(
"Protocol template declaration file not found: %s"
%
data
)
return
# this runs basic validation, including JSON loading if required
self
.
data
,
self
.
errors
=
schema
.
validate
(
"protocoltemplate"
,
data
)
if
self
.
errors
:
return
# don't proceed with the rest of validation
beat/core/prototypes/protocoltemplate.json
0 → 100644
View file @
6735c859
{
"schema_version"
:
1
,
"sets"
:
[
{
"name"
:
"name"
,
"outputs"
:
{
"out"
:
"user/single_integer/1"
}
}
]
}
beat/core/test/test_protocoltemplate.py
View file @
6735c859
...
...
@@ -41,6 +41,12 @@ from . import prefix, tmp_prefix
from
.utils
import
cleanup
def
test_default
():
obj
=
ProtocolTemplate
(
prefix
,
data
=
None
)
nose
.
tools
.
assert_true
(
obj
.
valid
,
"
\
n
* %s"
%
"
\
n
* "
.
join
(
obj
.
errors
))
def
test_export
():
for
protocol_name
in
[
"double"
,
...
...
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