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
a2a39223
Commit
a2a39223
authored
6 years ago
by
André Anjos
Browse files
Options
Downloads
Plain Diff
Merge branch 'fix_runner_handling' into 'master'
Fix lazy loading of algorithm's runner See merge request
!25
parents
6e553b9e
82a6493f
Branches
Branches containing commit
Tags
Tags containing commit
1 merge request
!25
Fix lazy loading of algorithm's runner
Pipeline
#24048
passed
6 years ago
Stage: build
Stage: deploy
Changes
1
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
beat/backend/python/executor.py
+13
-3
13 additions, 3 deletions
beat/backend/python/executor.py
with
13 additions
and
3 deletions
beat/backend/python/executor.py
+
13
−
3
View file @
a2a39223
...
@@ -92,7 +92,7 @@ class Executor(object):
...
@@ -92,7 +92,7 @@ class Executor(object):
self
.
data
=
simplejson
.
loads
(
f
.
read
().
decode
(
'
utf-8
'
))
self
.
data
=
simplejson
.
loads
(
f
.
read
().
decode
(
'
utf-8
'
))
self
.
prefix
=
os
.
path
.
join
(
directory
,
'
prefix
'
)
self
.
prefix
=
os
.
path
.
join
(
directory
,
'
prefix
'
)
self
.
runner
=
None
self
.
_
runner
=
None
# Temporary caches, if the user has not set them, for performance
# Temporary caches, if the user has not set them, for performance
database_cache
=
database_cache
if
database_cache
is
not
None
else
{}
database_cache
=
database_cache
if
database_cache
is
not
None
else
{}
...
@@ -134,10 +134,21 @@ class Executor(object):
...
@@ -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
):
def
setup
(
self
):
"""
Sets up the algorithm to start processing
"""
"""
Sets up the algorithm to start processing
"""
self
.
runner
=
self
.
algorithm
.
runner
()
retval
=
self
.
runner
.
setup
(
self
.
data
[
'
parameters
'
])
retval
=
self
.
runner
.
setup
(
self
.
data
[
'
parameters
'
])
logger
.
debug
(
"
User algorithm is setup
"
)
logger
.
debug
(
"
User algorithm is setup
"
)
return
retval
return
retval
...
@@ -146,7 +157,6 @@ class Executor(object):
...
@@ -146,7 +157,6 @@ class Executor(object):
def
prepare
(
self
):
def
prepare
(
self
):
"""
Prepare the algorithm
"""
"""
Prepare the algorithm
"""
self
.
runner
=
self
.
algorithm
.
runner
()
retval
=
self
.
runner
.
prepare
(
self
.
data_loaders
)
retval
=
self
.
runner
.
prepare
(
self
.
data_loaders
)
logger
.
debug
(
"
User algorithm is prepared
"
)
logger
.
debug
(
"
User algorithm is prepared
"
)
return
retval
return
retval
...
...
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