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
5e72b0ff
Commit
5e72b0ff
authored
Mar 12, 2014
by
Jérome Perrin
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Configure in the GUI the URL for KE data
parent
32110ef4
Changes
4
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
89 additions
and
58 deletions
+89
-58
dream/platform/__init__.py
dream/platform/__init__.py
+39
-35
dream/platform/static/src/dream.js
dream/platform/static/src/dream.js
+26
-5
dream/platform/static/src/dream_launcher.js
dream/platform/static/src/dream_launcher.js
+12
-18
dream/simulation/GUI/Default.py
dream/simulation/GUI/Default.py
+12
-0
No files found.
dream/platform/__init__.py
View file @
5e72b0ff
...
...
@@ -20,6 +20,7 @@
import
sys
import
argparse
import
json
import
urllib
import
xlrd
import
traceback
import
multiprocessing
...
...
@@ -148,9 +149,9 @@ def getConfigurationDict():
def
runKnowledgeExtraction
():
parameter_dict
=
request
.
json
[
'json'
]
# TODO: really run knowledge extraction and change values
:
workbook
=
xlrd
.
open_workbook
(
'dream/KnowledgeExtraction/Mockup_ProcessingTimes.xls'
)
#Using xlrd library opens the Excel document with the input data
try
:
workbook
=
xlrd
.
open_workbook
(
file_contents
=
urllib
.
urlopen
(
parameter_dict
[
'general'
][
'ke_url'
]).
read
())
worksheets
=
workbook
.
sheet_names
()
worksheet_ProcessingTimes
=
worksheets
[
0
]
#It defines the worksheet_ProcessingTimes as the first sheet of the Excel file
...
...
@@ -180,9 +181,12 @@ def runKnowledgeExtraction():
dictToAdd
[
aParameter
]
=
aParameterValue
if
bParameter
:
dictToAdd
[
bParameter
]
=
bParameterValue
print
dictToAdd
parameter_dict
[
'nodes'
][
element
][
'processingTime'
]
=
dictToAdd
return
jsonify
(
parameter_dict
)
return
jsonify
(
dict
(
success
=
True
,
data
=
parameter_dict
))
except
Exception
,
e
:
tb
=
traceback
.
format_exc
()
app
.
logger
.
error
(
tb
)
return
jsonify
(
dict
(
error
=
tb
))
def
main
(
*
args
):
parser
=
argparse
.
ArgumentParser
(
description
=
'Launch the DREAM simulation platform.'
)
...
...
dream/platform/static/src/dream.js
View file @
5e72b0ff
...
...
@@ -252,11 +252,8 @@
that
.
prepareDialogForGeneralProperties
();
};
/** Runs the simulation, and call the callback with results once the
* simulation is finished.
*/
that
.
runSimulation
=
function
(
callback
)
{
// handle Dream.General properties (in another function maybe ?)
that
.
readGeneralPropertiesDialog
=
function
()
{
// handle Dream.General properties
var
prefix
=
"
General-
"
,
properties
=
{},
prefixed_property_id
;
...
...
@@ -271,7 +268,13 @@
}
});
that
.
setGeneralProperties
(
properties
);
}
/** Runs the simulation, and call the callback with results once the
* simulation is finished.
*/
that
.
runSimulation
=
function
(
callback
)
{
that
.
readGeneralPropertiesDialog
()
$
.
ajax
(
'
../runSimulation
'
,
{
data
:
JSON
.
stringify
({
...
...
@@ -285,6 +288,24 @@
});
};
/** Runs the knowledge extraction, and call the callback with results once the
* KE is finished.
*/
that
.
runKnowledgeExtraction
=
function
(
callback
)
{
that
.
readGeneralPropertiesDialog
()
$
.
ajax
(
'
../runKnowledgeExtraction
'
,
{
data
:
JSON
.
stringify
({
json
:
that
.
getData
()
}),
contentType
:
'
application/json
'
,
type
:
'
POST
'
,
success
:
function
(
data
,
textStatus
,
jqXHR
)
{
callback
(
data
);
}
});
};
that
.
displayResult
=
function
(
idx
)
{
var
active_tab
=
$
(
"
#reports
"
).
data
(
"
ui-tabs
"
)
?
$
(
"
#reports
"
).
tabs
(
"
option
"
,
"
active
"
)
:
0
;
...
...
dream/platform/static/src/dream_launcher.js
View file @
5e72b0ff
...
...
@@ -156,27 +156,21 @@
// Enable "Run Knowledge Extraction" button
$
(
"
#run_knowledge_extraction
"
).
button
().
click
(
function
(
e
)
{
$
(
"
#run_knowledge_extraction
"
).
button
(
'
disable
'
);
$
(
"
#ke_loading_spinner
"
).
show
();
$
.
ajax
(
'
../runKnowledgeExtraction
'
,
{
data
:
JSON
.
stringify
({
json
:
dream_instance
.
getData
()
}),
contentType
:
'
application/json
'
,
type
:
'
POST
'
,
success
:
function
(
data
,
textStatus
,
jqXHR
)
{
loadData
(
data
);
$
(
"
#ke_loading_spinner
"
).
hide
();
$
(
"
#run_knowledge_extraction
"
).
button
(
'
enable
'
);
},
error
:
function
()
{
$
(
"
#run_knowledge_extraction
"
).
button
(
'
disable
'
);
$
(
'
#error
'
).
empty
();
dream_instance
.
runKnowledgeExtraction
(
function
(
data
)
{
$
(
"
#ke_loading_spinner
"
).
hide
();
$
(
"
#run_knowledge_extraction
"
).
button
(
'
enable
'
);
if
(
data
[
'
success
'
])
{
loadData
(
data
.
data
);
}
else
{
$
(
"
#error
"
).
text
(
data
[
"
error
"
]).
show
().
effect
(
'
shake
'
,
50
);
console
.
error
(
data
[
'
error
'
])
}
});
}
)
});
// Enable "Run Simulation" button
$
(
"
#run_simulation
"
).
button
().
click
(
...
...
dream/simulation/GUI/Default.py
View file @
5e72b0ff
...
...
@@ -151,6 +151,17 @@ schema = {
"_class"
:
"Dream.Property"
,
"_default"
:
""
,
},
"ke_url"
:
{
"id"
:
"ke_url"
,
"name"
:
"URL for Knowledge Extraction Spreadsheet"
,
"description"
:
"The URL for knowledge extraction to access its data"
" for example "
"http://git.erp5.org/gitweb/dream.git/blob_plain/HEAD:/dream/KnowledgeExtraction/Mockup_ProcessingTimes.xls"
,
"type"
:
"string"
,
"_class"
:
"Dream.Property"
,
"_default"
:
"http://git.erp5.org/gitweb/dream.git/blob_plain/HEAD:/dream/KnowledgeExtraction/Mockup_ProcessingTimes.xls"
,
},
"batchNumberOfUnits"
:
{
"id"
:
"batchNumberOfUnits"
,
"type"
:
"number"
,
...
...
@@ -319,6 +330,7 @@ class Simulation(object):
schema
[
"currentDate"
],
schema
[
"trace"
],
schema
[
"seed"
],
schema
[
"ke_url"
],
],
"gui"
:
{
'debug_json'
:
1
,
...
...
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