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
eb99b753
Commit
eb99b753
authored
Jan 07, 2015
by
Ioannis Papagiannopoulos
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
defautl plugins (pre/post-processing) added. to be invoked from __init__ of the platform.
parent
97379e0b
Changes
3
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
117 additions
and
0 deletions
+117
-0
dream/plugins/GatherWIPStat.py
dream/plugins/GatherWIPStat.py
+13
-0
dream/plugins/__init__.py
dream/plugins/__init__.py
+24
-0
dream/plugins/plugin.py
dream/plugins/plugin.py
+80
-0
No files found.
dream/plugins/GatherWIPStat.py
0 → 100644
View file @
eb99b753
from
dream.plugins
import
plugin
class
GatherWIPStat
(
plugin
.
InputPreparationPlugin
):
def
preprocess
(
self
,
data
):
"""Preprocess the data, for instance reading spreadsheet.
"""
# by default we add an event generator if using queue stats
if
data
[
"application_configuration"
][
"output"
][
"view_queue_stats"
]:
for
node
in
data
[
"graph"
][
"node"
].
values
():
if
node
[
'_class'
]
in
(
'Dream.Queue'
,
):
node
[
'gatherWipStat'
]
=
1
return
data
dream/plugins/__init__.py
0 → 100644
View file @
eb99b753
# ===========================================================================
# Copyright 2013 University of Limerick
#
# This file is part of DREAM.
#
# DREAM is free software: you can redistribute it and/or modify
# it under the terms of the GNU Lesser General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# DREAM is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU Lesser General Public License for more details.
#
# You should have received a copy of the GNU Lesser General Public License
# along with DREAM. If not, see <http://www.gnu.org/licenses/>.
# ===========================================================================
# See http://peak.telecommunity.com/DevCenter/setuptools#namespace-packages
try
:
__import__
(
'pkg_resources'
).
declare_namespace
(
__name__
)
except
ImportError
:
from
pkgutil
import
extend_path
__path__
=
extend_path
(
__path__
,
__name__
)
\ No newline at end of file
dream/plugins/plugin.py
0 → 100644
View file @
eb99b753
from
copy
import
deepcopy
import
json
from
zope.dottedname.resolve
import
resolve
from
dream.simulation.LineGenerationJSON
import
main
as
simulate_line_json
# helper function to overload a property
def
overloaded_property
(
prop
,
overload
):
prop
=
deepcopy
(
prop
)
prop
.
update
(
overload
)
return
prop
# helper function to return a default configuration dictionary
def
getConfigurationDict
(
self
):
"""Returns the possible nodes to use in the graph editor, and the global
configuration.
"""
return
NotImplementedError
class
Plugin
(
object
):
"""Base class for pre-post processing Plugin.
"""
def
__init__
(
self
,
logger
=
None
):
self
.
logger
=
logger
class
ExecutionPlugin
(
Plugin
):
"""Plugin to handle the execution of multiple simulation runs.
"""
def
run
(
self
,
data
):
"""General execution plugin.
"""
raise
NotImplementedError
class
InputPreparationPlugin
(
Plugin
):
def
preprocess
(
self
,
data
):
"""Preprocess the data before simulation run.
"""
return
data
class
OutputPreparationPlugin
(
Plugin
):
def
postprocess
(
self
,
data
):
"""Postprocess the data after simulation run.
"""
return
data
class
DefaultExecutionPlugin
(
ExecutionPlugin
):
"""Default Execution Plugin just executes one scenario.
"""
def
run
(
self
,
data
):
return
json
.
loads
(
simulate_line_json
(
input_data
=
json
.
dumps
(
data
)))
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
run
(
self
,
data
):
"""Preprocess, execute & postprocess.
"""
for
input_preparation
in
self
.
input_preparation_list
:
data
=
input_preparation
.
preprocess
(
deepcopy
(
data
))
print
1
data
[
"result"
]
=
self
.
execution_plugin
.
run
(
data
)
print
2
print
data
for
output_preparation
in
self
.
output_preparation_list
:
data
=
output_preparation
.
postprocess
(
deepcopy
(
data
))
return
data
\ No newline at end of file
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