Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
dream
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
1
Issues
1
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
nexedi
dream
Commits
ecdf8b29
Commit
ecdf8b29
authored
Jan 20, 2015
by
Jérome Perrin
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Platform: simplify plugin registry
parent
10ad9717
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
29 additions
and
42 deletions
+29
-42
dream/platform/__init__.py
dream/platform/__init__.py
+2
-15
dream/plugins/plugin.py
dream/plugins/plugin.py
+16
-12
dream/simulation/Examples/PartJobShopAllInOneEmpty.json
dream/simulation/Examples/PartJobShopAllInOneEmpty.json
+11
-15
No files found.
dream/platform/__init__.py
View file @
ecdf8b29
...
...
@@ -133,26 +133,13 @@ def runSimulation():
def
_runSimulation
(
parameter_dict
):
try
:
return
dict
(
success
=
True
,
data
=
getPluginRestistry
(
parameter_dict
).
run
(
parameter_dict
))
registry
=
PluginRegistry
(
app
.
logger
,
parameter_dict
)
return
dict
(
success
=
True
,
data
=
registry
.
run
(
parameter_dict
))
except
Exception
,
e
:
tb
=
traceback
.
format_exc
()
app
.
logger
.
error
(
tb
)
return
dict
(
error
=
tb
)
def
getPluginRestistry
(
data
):
# input plugins
input_plugin_list
=
data
[
"application_configuration"
][
"preprocessing_plugin_list"
]
# output plugins
output_plugin_list
=
data
[
"application_configuration"
][
"postprocessing_plugin_list"
]
# executor plugin
executor_name
=
data
[
"application_configuration"
][
"processing_plugin"
]
# XXX default value ?
# remove the executor plugin from the input plugins list
registry
=
PluginRegistry
(
logger
=
app
.
logger
,
input_preparation_class_list
=
input_plugin_list
,
output_preparation_class_list
=
output_plugin_list
,
execution_plugin_class
=
executor_name
)
return
registry
@
app
.
route
(
"/runKnowledgeExtraction"
,
methods
=
[
"POST"
,
"OPTIONS"
])
def
runKnowledgeExtraction
():
parameter_dict
=
request
.
json
...
...
dream/plugins/plugin.py
View file @
ecdf8b29
...
...
@@ -21,8 +21,9 @@ def getConfigurationDict(self):
class
Plugin
(
object
):
"""Base class for pre-post processing Plugin.
"""
def
__init__
(
self
,
logger
=
None
):
def
__init__
(
self
,
logger
,
configuration_dict
):
self
.
logger
=
logger
self
.
configuration_dict
=
configuration_dict
class
ExecutionPlugin
(
Plugin
):
"""Plugin to handle the execution of multiple simulation runs.
...
...
@@ -64,25 +65,28 @@ class DefaultExecutionPlugin(ExecutionPlugin):
class
PluginRegistry
(
object
):
"""Registry of plugins.
"""
def
__init__
(
self
,
logger
,
input_preparation_class_list
,
output_preparation_class_list
,
execution_plugin_class
):
self
.
input_preparation_list
=
tuple
([
resolve
(
name
)(
logger
)
for
name
in
input_preparation_class_list
])
self
.
output_preparation_list
=
tuple
([
resolve
(
name
)(
logger
)
for
name
in
output_preparation_class_list
])
self
.
execution_plugin
=
resolve
(
execution_plugin_class
)(
logger
)
def
__init__
(
self
,
logger
,
data
):
self
.
input_preparation_list
=
[]
for
plugin_data
in
data
[
'application_configuration'
][
'pre_processing_plugin_list'
]:
self
.
input_preparation_list
.
append
(
resolve
(
plugin_data
[
'_class'
])(
logger
,
plugin_data
))
self
.
output_preparation_list
=
[]
for
plugin_data
in
data
[
'application_configuration'
][
'post_processing_plugin_list'
]:
self
.
output_preparation_list
.
append
(
resolve
(
plugin_data
[
'_class'
])(
logger
,
plugin_data
))
plugin_data
=
data
[
'application_configuration'
][
'processing_plugin'
]
self
.
execution_plugin
=
resolve
(
plugin_data
[
'_class'
])(
logger
,
plugin_data
)
def
run
(
self
,
data
):
"""Preprocess, execute & postprocess.
"""
for
input_preparation
in
self
.
input_preparation_list
:
data
=
input_preparation
.
preprocess
(
deepcopy
(
data
))
data
=
self
.
execution_plugin
.
run
(
data
)
for
output_preparation
in
self
.
output_preparation_list
:
data
=
output_preparation
.
postprocess
(
deepcopy
(
data
))
return
data
\ No newline at end of file
return
data
dream/simulation/Examples/PartJobShopAllInOneEmpty.json
View file @
ecdf8b29
...
...
@@ -785,24 +785,20 @@
"gadget"
:
"Output_viewDebugJson"
}
},
"preprocessing_plugin_list"
:
[
{
"plugin"
:
"dream.plugins.Debug.Debug"
,
"argument"
:
"Argument Value"
},
{
"plugin"
:
"dream.plugins.OldStylePartJobShopWIP.OldStylePartJobShopWIP"
,
"input_id"
:
"Simulation"
}
],
"processing_plugin"
:
{
"plugin"
:
"ACO"
},
"postprocessing_plugin_list"
:
[
"pre_processing_plugin_list"
:
[
{
"_class"
:
"dream.plugins.Debug.Debug"
,
"argument"
:
"Argument Value"
},
{
"plugin"
:
"CalculateConfidenceIntervals"
"_class"
:
"dream.plugins.OldStylePartJobShopWIP.OldStylePartJobShopWIP"
,
"input_id"
:
"Simulation"
}
],
"processing_plugin"
:
{
"_class"
:
"dream.plugins.ACO.ACO"
},
"post_processing_plugin_list"
:
[],
"general"
:
{
"properties"
:
{
"numberOfReplications"
:
{
...
...
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