Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
beat
beat.backend.python
Commits
82a6493f
Commit
82a6493f
authored
Oct 05, 2018
by
Samuel GAIST
Browse files
[executor] Fix lazy loading of algorithm's runner
parent
6e553b9e
Pipeline
#24046
passed with stage
in 3 minutes and 15 seconds
Changes
1
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
beat/backend/python/executor.py
View file @
82a6493f
...
...
@@ -92,7 +92,7 @@ class Executor(object):
self
.
data
=
simplejson
.
loads
(
f
.
read
().
decode
(
'utf-8'
))
self
.
prefix
=
os
.
path
.
join
(
directory
,
'prefix'
)
self
.
runner
=
None
self
.
_
runner
=
None
# Temporary caches, if the user has not set them, for performance
database_cache
=
database_cache
if
database_cache
is
not
None
else
{}
...
...
@@ -134,10 +134,21 @@ class Executor(object):
)
@
property
def
runner
(
self
):
"""Returns the algorithm runner
This property allows for lazy loading of the runner
"""
if
self
.
_runner
is
None
:
self
.
_runner
=
self
.
algorithm
.
runner
()
return
self
.
_runner
def
setup
(
self
):
"""Sets up the algorithm to start processing"""
self
.
runner
=
self
.
algorithm
.
runner
()
retval
=
self
.
runner
.
setup
(
self
.
data
[
'parameters'
])
logger
.
debug
(
"User algorithm is setup"
)
return
retval
...
...
@@ -146,7 +157,6 @@ class Executor(object):
def
prepare
(
self
):
"""Prepare the algorithm"""
self
.
runner
=
self
.
algorithm
.
runner
()
retval
=
self
.
runner
.
prepare
(
self
.
data_loaders
)
logger
.
debug
(
"User algorithm is prepared"
)
return
retval
...
...
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