Skip to content
GitLab
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
workflow
pypushflow
Commits
d69ab181
Commit
d69ab181
authored
May 12, 2020
by
payno
Browse files
[add-on] add _BaseWorkflow whiwh should manage the add-on of the workflow
parent
ac6d9542
Changes
1
Hide whitespace changes
Inline
Side-by-side
pypushflow/Workflow.py
View file @
d69ab181
...
...
@@ -31,18 +31,37 @@ from pypushflow.PythonActor import PythonActor as ActorFactory
from
pypushflow.StartActor
import
StartActor
from
pypushflow.StopActor
import
StopActor
from
pypushflow.JoinActor
import
JoinUntilStopSignal
from
pypushflow.addon
import
utils
from
pypushflow.addon.classes
import
BaseWorkflowAddOn
logger
=
logging
.
getLogger
(
'pypushflow'
)
class
Workflow
(
object
):
#from pypushflow import UtilsMongoDb
class
_BaseWorkflow
:
def
__init__
(
self
,
configuration
):
self
.
_configuration
=
configuration
or
{}
self
.
_add_ons
=
[]
for
add_on_class
in
self
.
_getAddOnsClasses
():
self
.
_add_ons
.
append
(
add_on_class
(
workflow
=
self
,
configuration
=
configuration
))
def
_getAddOnsClasses
(
self
):
add_ons
=
[]
for
_
,
classes
in
utils
.
get_registered_add_ons_classes
().
items
():
for
class_
in
classes
:
import
inspect
if
BaseWorkflowAddOn
in
(
inspect
.
getmro
(
class_
)):
add_ons
.
append
(
class_
)
return
add_ons
class
Workflow
(
_BaseWorkflow
):
"""TODO"""
def
__init__
(
self
,
name
):
super
(
Workflow
,
self
).
__init__
()
self
.
name
=
name
self
.
listOnErrorActor
=
[]
#self.mongoId = UtilsMongoDb.initMongo(name=name)
def
connectOnError
(
self
,
actor
):
logger
.
debug
(
"In connectOnError in subModule {0}, actor name {1}"
.
format
(
self
.
name
,
actor
.
name
))
...
...
@@ -58,8 +77,16 @@ class Workflow(object):
return
'/'
+
self
.
name
class
ProcessableWorkflow
:
def
__init__
(
self
,
scheme
):
class
ProcessableWorkflow
(
_BaseWorkflow
):
"""Define a workflow that can be executed
:param scheme: the workflow scheme
:param configuration: some configuration / settings that can be pass to
the add-on.
"""
def
__init__
(
self
,
scheme
,
configuration
=
None
):
super
(
ProcessableWorkflow
,
self
).
__init__
(
configuration
=
configuration
)
assert
isinstance
(
scheme
,
Scheme
)
self
.
_representation
=
scheme
# first load node handlers if any
...
...
Write
Preview
Supports
Markdown
0%
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!
Cancel
Please
register
or
sign in
to comment