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
303a970b
Commit
303a970b
authored
Jan 20, 2015
by
Jérome Perrin
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Platform: simplify plugin registry
parent
893371a8
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 @
303a970b
...
@@ -133,26 +133,13 @@ def runSimulation():
...
@@ -133,26 +133,13 @@ def runSimulation():
def
_runSimulation
(
parameter_dict
):
def
_runSimulation
(
parameter_dict
):
try
:
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
:
except
Exception
,
e
:
tb
=
traceback
.
format_exc
()
tb
=
traceback
.
format_exc
()
app
.
logger
.
error
(
tb
)
app
.
logger
.
error
(
tb
)
return
dict
(
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"
])
@
app
.
route
(
"/runKnowledgeExtraction"
,
methods
=
[
"POST"
,
"OPTIONS"
])
def
runKnowledgeExtraction
():
def
runKnowledgeExtraction
():
parameter_dict
=
request
.
json
parameter_dict
=
request
.
json
...
...
dream/plugins/plugin.py
View file @
303a970b
...
@@ -21,8 +21,9 @@ def getConfigurationDict(self):
...
@@ -21,8 +21,9 @@ def getConfigurationDict(self):
class
Plugin
(
object
):
class
Plugin
(
object
):
"""Base class for pre-post processing Plugin.
"""Base class for pre-post processing Plugin.
"""
"""
def
__init__
(
self
,
logger
=
None
):
def
__init__
(
self
,
logger
,
configuration_dict
):
self
.
logger
=
logger
self
.
logger
=
logger
self
.
configuration_dict
=
configuration_dict
class
ExecutionPlugin
(
Plugin
):
class
ExecutionPlugin
(
Plugin
):
"""Plugin to handle the execution of multiple simulation runs.
"""Plugin to handle the execution of multiple simulation runs.
...
@@ -64,25 +65,28 @@ class DefaultExecutionPlugin(ExecutionPlugin):
...
@@ -64,25 +65,28 @@ class DefaultExecutionPlugin(ExecutionPlugin):
class
PluginRegistry
(
object
):
class
PluginRegistry
(
object
):
"""Registry of plugins.
"""Registry of plugins.
"""
"""
def
__init__
(
self
,
logger
,
def
__init__
(
self
,
logger
,
data
):
input_preparation_class_list
,
output_preparation_class_list
,
self
.
input_preparation_list
=
[]
execution_plugin_class
):
for
plugin_data
in
data
[
'application_configuration'
][
'pre_processing_plugin_list'
]:
self
.
input_preparation_list
=
tuple
([
resolve
(
name
)(
logger
)
for
name
in
self
.
input_preparation_list
.
append
(
resolve
(
plugin_data
[
'_class'
])(
logger
,
plugin_data
))
input_preparation_class_list
])
self
.
output_preparation_list
=
tuple
([
resolve
(
name
)(
logger
)
for
name
in
self
.
output_preparation_list
=
[]
output_preparation_class_list
])
for
plugin_data
in
data
[
'application_configuration'
][
'post_processing_plugin_list'
]:
self
.
execution_plugin
=
resolve
(
execution_plugin_class
)(
logger
)
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
):
def
run
(
self
,
data
):
"""Preprocess, execute & postprocess.
"""Preprocess, execute & postprocess.
"""
"""
for
input_preparation
in
self
.
input_preparation_list
:
for
input_preparation
in
self
.
input_preparation_list
:
data
=
input_preparation
.
preprocess
(
deepcopy
(
data
))
data
=
input_preparation
.
preprocess
(
deepcopy
(
data
))
data
=
self
.
execution_plugin
.
run
(
data
)
data
=
self
.
execution_plugin
.
run
(
data
)
for
output_preparation
in
self
.
output_preparation_list
:
for
output_preparation
in
self
.
output_preparation_list
:
data
=
output_preparation
.
postprocess
(
deepcopy
(
data
))
data
=
output_preparation
.
postprocess
(
deepcopy
(
data
))
return
data
return
data
\ No newline at end of file
dream/simulation/Examples/PartJobShopAllInOneEmpty.json
View file @
303a970b
...
@@ -785,24 +785,20 @@
...
@@ -785,24 +785,20 @@
"gadget"
:
"Output_viewDebugJson"
"gadget"
:
"Output_viewDebugJson"
}
}
},
},
"preprocessing_plugin_list"
:
[
"pre_processing_plugin_list"
:
[
{
{
"plugin"
:
"dream.plugins.Debug.Debug"
,
"_class"
:
"dream.plugins.Debug.Debug"
,
"argument"
:
"Argument Value"
"argument"
:
"Argument Value"
},
},
{
"plugin"
:
"dream.plugins.OldStylePartJobShopWIP.OldStylePartJobShopWIP"
,
"input_id"
:
"Simulation"
}
],
"processing_plugin"
:
{
"plugin"
:
"ACO"
},
"postprocessing_plugin_list"
:
[
{
{
"plugin"
:
"CalculateConfidenceIntervals"
"_class"
:
"dream.plugins.OldStylePartJobShopWIP.OldStylePartJobShopWIP"
,
"input_id"
:
"Simulation"
}
}
],
],
"processing_plugin"
:
{
"_class"
:
"dream.plugins.ACO.ACO"
},
"post_processing_plugin_list"
:
[],
"general"
:
{
"general"
:
{
"properties"
:
{
"properties"
:
{
"numberOfReplications"
:
{
"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