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
8e42547f
Commit
8e42547f
authored
Apr 22, 2020
by
payno
Browse files
add management of add-ons
parent
03e88d35
Changes
4
Hide whitespace changes
Inline
Side-by-side
pypushflow/AbstractActor.py
View file @
8e42547f
...
...
@@ -25,8 +25,6 @@ __date__ = "28/05/2019"
import
logging
#from pypushflow import UtilsMongoDb
logger
=
logging
.
getLogger
(
'pypushflow'
)
...
...
@@ -55,23 +53,9 @@ class AbstractActor(object):
))
actor
.
trigger
(
inData
)
# def uploadDataToMongo(self, actorData={}, script=None):
# if self.parent is not None:
# if self.parent.mongoId is not None:
# if self.actorId is None:
# actorPath = self.getActorPath() + '/' + self.name
# self.actorId = UtilsMongoDb.initActor(
# workflowId=self.parent.mongoId,
# name=actorPath,
# actorData=actorData,
# script=script
# )
# else:
# UtilsMongoDb.addDataToActor(
# workflowId=self.parent.mongoId,
# actorId=self.actorId,
# actorData=actorData
# )
def
getActorPath
(
self
):
return
self
.
parent
.
getActorPath
()
def
get_addons
(
self
):
"""Return the list of add-on that will be apply to this actor"""
raise
NotImplementedError
()
pypushflow/addon/__init__.py
0 → 100644
View file @
8e42547f
from
.classes
import
*
\ No newline at end of file
pypushflow/addon/classes.py
0 → 100644
View file @
8e42547f
# coding: utf-8
# /*##########################################################################
#
# Copyright (c) 2019-2020 European Synchrotron Radiation Facility
#
# Permission is hereby granted, free of charge, to any person obtaining a copy
# of this software and associated documentation files (the "Software"), to deal
# in the Software without restriction, including without limitation the rights
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
# copies of the Software, and to permit persons to whom the Software is
# furnished to do so, subject to the following conditions:
#
# The above copyright notice and this permission notice shall be included in
# all copies or substantial portions of the Software.
#
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
# THE SOFTWARE.
#
# ###########################################################################*/
__authors__
=
[
"H. Payno"
]
__license__
=
"MIT"
__date__
=
"22/04/2020"
class
BaseWorkflowAddOn
:
"""Base class for a Workflow instance"""
def
__init__
(
self
,
workflow_instance
):
pass
class
BaseActorAddOn
:
"""Base class to define an add on for an actor"""
def
__init__
(
self
,
target
):
"""Apply an add on to classes that are instances of target class"""
self
.
__target
=
target
@
property
def
target
(
self
):
return
self
.
__target
def
pre_trigger_action
(
self
,
actor
):
pass
def
post_trigger_action
(
self
,
actor
):
pass
pypushflow/addon/utils.py
0 → 100644
View file @
8e42547f
# coding: utf-8
# /*##########################################################################
#
# Copyright (c) 2019-2020 European Synchrotron Radiation Facility
#
# Permission is hereby granted, free of charge, to any person obtaining a copy
# of this software and associated documentation files (the "Software"), to deal
# in the Software without restriction, including without limitation the rights
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
# copies of the Software, and to permit persons to whom the Software is
# furnished to do so, subject to the following conditions:
#
# The above copyright notice and this permission notice shall be included in
# all copies or substantial portions of the Software.
#
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
# THE SOFTWARE.
#
# ###########################################################################*/
__authors__
=
[
"H. Payno"
]
__license__
=
"MIT"
__date__
=
"22/04/2020"
import
logging
import
pkgutil
import
inspect
_logger
=
logging
.
getLogger
(
__name__
)
def
get_registered_add_ons
():
"""Return the list of registered add-on"""
try
:
import
ppfaddon
except
ImportError
:
_logger
.
info
(
'no add on found'
)
return
[]
else
:
modules
=
[]
for
importer
,
modname
,
ispkg
in
pkgutil
.
iter_modules
(
ppfaddon
.
__path__
):
if
ispkg
:
modules
.
append
(
modname
)
return
modules
def
get_registered_add_ons_classes
():
"""Return the list of registered add-on classes"""
classes
=
[]
add_on_modules
=
get_registered_add_ons
()
for
module
in
add_on_modules
:
package_name
=
'.'
.
join
((
'ppfaddon'
,
module
))
try
:
mymodule
=
__import__
(
package_name
,
fromlist
=
[
'foo'
])
for
element_name
in
dir
(
mymodule
):
element
=
getattr
(
mymodule
,
element_name
)
if
inspect
.
isclass
(
element
):
classes
.
append
(
element
)
except
ImportError
as
e
:
_logger
.
error
(
str
(
e
))
return
classes
def
is_add_on_class_relative_to
(
add_on_class
,
myclass
):
"""Return the list of registered add-on classes"""
return
isinstance
(
myclass
,
add_on_class
.
target
)
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