Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
beat.backend.python
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.backend.python
Commits
8676e52d
Commit
8676e52d
authored
7 years ago
by
Samuel GAIST
Browse files
Options
Downloads
Patches
Plain Diff
[dbexecution] Added missing doc and fixed doc related warning
Also fixed import warnings
parent
281b33f7
Branches
Branches containing commit
Tags
Tags containing commit
2 merge requests
!17
Merge development branch 1.5.x
,
!13
Improve documentation
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
beat/backend/python/dbexecution.py
+31
-20
31 additions, 20 deletions
beat/backend/python/dbexecution.py
with
31 additions
and
20 deletions
beat/backend/python/dbexecution.py
+
31
−
20
View file @
8676e52d
...
...
@@ -26,18 +26,25 @@
###############################################################################
'''
Execution utilities
'''
"""
===========
dbexecution
===========
Execution utilities
"""
import
os
import
logging
logger
=
logging
.
getLogger
(
__name__
)
import
simplejson
# from . import schema
from
.database
import
Database
from
.message_handler
import
MessageHandler
logger
=
logging
.
getLogger
(
__name__
)
class
DBExecutor
(
object
):
...
...
@@ -48,10 +55,11 @@ class DBExecutor(object):
prefix (str): Establishes the prefix of your installation.
data (dict, str): The piece of data representing the block to be executed.
data (dict, str): The piece of data representing the block to be
executed.
It must validate against the schema defined for execution blocks. If a
string is passed, it is supposed to be a fully qualified absolute path
to
a JSON file containing the block execution information.
string is passed, it is supposed to be a fully qualified absolute path
to
a JSON file containing the block execution information.
dataformat_cache (:py:class:`dict`, Optional): A dictionary mapping
dataformat names to loaded dataformats. This parameter is optional and,
...
...
@@ -70,8 +78,8 @@ class DBExecutor(object):
Attributes:
errors (list): A list containing errors found while loading this
execution
block.
errors (list): A list containing errors found while loading this
execution
block.
data (dict): The original data for this executor, as loaded by our JSON
decoder.
...
...
@@ -89,15 +97,15 @@ class DBExecutor(object):
input_list (inputs.InputList): A list of inputs that will be served to
the algorithm.
data_sources (list): A list with all data-sources created by our
execution
loader.
data_sources (list): A list with all data-sources created by our
execution
loader.
"""
def
__init__
(
self
,
message_handler
,
prefix
,
cache_root
,
data
,
dataformat_cache
=
None
,
database_cache
=
None
):
def
__init__
(
self
,
message_handler
,
prefix
,
cache_root
,
data
,
dataformat_cache
=
None
,
database_cache
=
None
):
# Initialisation
s
# Initialisation
self
.
prefix
=
prefix
self
.
databases
=
{}
self
.
views
=
{}
...
...
@@ -112,7 +120,7 @@ class DBExecutor(object):
self
.
dataformat_cache
=
dataformat_cache
if
dataformat_cache
is
not
None
else
{}
# Load the data
if
not
isinstance
(
data
,
dict
):
# User has passed a file name
if
not
isinstance
(
data
,
dict
):
# User has passed a file name
if
not
os
.
path
.
exists
(
data
):
self
.
errors
.
append
(
'
File not found: %s
'
%
data
)
return
...
...
@@ -134,9 +142,9 @@ class DBExecutor(object):
# Load the database
if
details
[
'
database
'
]
not
in
self
.
databases
:
if
details
[
'
database
'
]
in
database_cache
:
#
reuse
if
details
[
'
database
'
]
in
database_cache
:
#
reuse
db
=
database_cache
[
details
[
'
database
'
]]
else
:
#
load it
else
:
#
load it
db
=
Database
(
self
.
prefix
,
details
[
'
database
'
],
self
.
dataformat_cache
)
database_cache
[
db
.
name
]
=
db
...
...
@@ -156,7 +164,7 @@ class DBExecutor(object):
if
key
not
in
self
.
views
:
view
=
db
.
view
(
details
[
'
protocol
'
],
details
[
'
set
'
])
if
details
[
'
channel
'
]
==
self
.
data
[
'
channel
'
]:
#
synchronized
if
details
[
'
channel
'
]
==
self
.
data
[
'
channel
'
]:
#
synchronized
start_index
,
end_index
=
self
.
data
.
get
(
'
range
'
,
(
None
,
None
))
else
:
start_index
,
end_index
=
(
None
,
None
)
...
...
@@ -178,15 +186,16 @@ class DBExecutor(object):
self
.
message_handler
.
set_data_sources
(
self
.
data_sources
)
def
process
(
self
):
self
.
message
_
handler
.
start
()
"""
Starts the
message
handler
"""
self
.
message_handler
.
start
()
@property
def
address
(
self
):
return
self
.
message
_
handler
.
address
"""
Address of the
message
handler
"""
return
self
.
message_handler
.
address
@property
def
valid
(
self
):
...
...
@@ -195,6 +204,8 @@ class DBExecutor(object):
def
wait
(
self
):
"""
Wait for the message handle to finish
"""
self
.
message_handler
.
join
()
self
.
message_handler
=
None
...
...
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