Skip to content
Snippets Groups Projects
Commit f9b73ba0 authored by Elbez Hammouda's avatar Elbez Hammouda
Browse files

Template updated

parent e9d36a7b
Branches
No related tags found
1 merge request!23V0.351
...@@ -142,8 +142,10 @@ class layout(): ...@@ -142,8 +142,10 @@ class layout():
# Layers filter # Layers filter
dcc.Dropdown( dcc.Dropdown(
id='GeneralLayerFilter', id='GeneralLayerFilter',
options=[{'label': str(i), 'value': str(i)} for i in (i for i in g.Layer_Neuron if i != "Input")], options=[{'label': str(i), 'value': str(i)} for i in (
value=[str(i) for i in (i for i in g.Layer_Neuron if i != "Input")], i for i in g.Layer_Neuron if i != "Input")],
value=[str(i) for i in (
i for i in g.Layer_Neuron if i != "Input")],
multi=True, multi=True,
style={"minWidth": "20%", "marginLeft": "15px", "textAlign": "start"})], className="row", style={"paddingLeft": "20px", 'width': '100%'}) style={"minWidth": "20%", "marginLeft": "15px", "textAlign": "start"})], className="row", style={"paddingLeft": "20px", 'width': '100%'})
], className="col-12") ], className="col-12")
...@@ -231,16 +233,20 @@ class layout(): ...@@ -231,16 +233,20 @@ class layout():
dbc.Button(">", id="btn-next", className="btn btn-default", style={"marginTop": "12px", "marginLeft": "5px", "fontWeight": "500", "backgroundColor": "rgb(68, 71, 99)"})], className="col-md-4 col-sm-12 col-lg-4"), dbc.Button(">", id="btn-next", className="btn btn-default", style={"marginTop": "12px", "marginLeft": "5px", "fontWeight": "500", "backgroundColor": "rgb(68, 71, 99)"})], className="col-md-4 col-sm-12 col-lg-4"),
html.Div([ html.Div([
html.Div([ html.Div([
html.Span("Update Speed (s)",className="input-group-text") html.Span("Update Speed (s)",
className="input-group-text")
], className="input-group-prepend"), ], className="input-group-prepend"),
dbc.Input(type="number", id="speed", value=1, min=0.25, max=5, step=0.25, style={"width": "30%", "textAlign": "center"}) dbc.Input(type="number", id="speed", value=1, min=0.25, max=5, step=0.25, style={
"width": "30%", "textAlign": "center"})
], className="input-group col-md-4 col-sm-7 col-lg-4", style={"height": "38px", "paddingTop": "12px"}), ], className="input-group col-md-4 col-sm-7 col-lg-4", style={"height": "38px", "paddingTop": "12px"}),
html.Div([ html.Div([
html.Div([ html.Div([
html.Span("Update Interval (s)",className="input-group-text") html.Span("Update Interval (s)",
className="input-group-text")
], className="input-group-prepend"), ], className="input-group-prepend"),
dbc.Input(type="number", id="interval", value=g.updateInterval, min=0.005, max=180, step=0.005, style={"width": "30%", "textAlign": "center"}) dbc.Input(type="number", id="interval", value=g.updateInterval, min=0.005,
max=180, step=0.005, style={"width": "30%", "textAlign": "center"})
], className="input-group col-md-4 col-sm-4 col-lg-4", style={"height": "38px", "paddingTop": "12px"}) ], className="input-group col-md-4 col-sm-4 col-lg-4", style={"height": "38px", "paddingTop": "12px"})
], className="d-flex justify-content-center"), dbc.Col( ], className="d-flex justify-content-center"), dbc.Col(
[ [
......
\ No newline at end of file
""" This class contains Dash callbacks
Dash callbacks are the responsible on updating graphs each step.
"""
class callbacks():
"""Callbacks class
"""
def init(self, super, app, g):
"""Initialize the callback .
Args:
app : Flask app
g (Global_Var): reference to access global variables
"""
# ------------------------------------------------------------
# Callbacks
# ------------------------------------------------------------
# to prevent creating duplicate callbacks next use
if not g.checkExistance(app, "name of one element from layout"):
# Add callbacks here
# Use Input("v-step", "children"),State("interval",
# "value") to keep track of time slider
try:
# @app.callback([Output()], [Input()])
# def NeuronSelection(input):
# do process here
# return output
print("Add Callbacks here")
try:
@app.callback([Output("display-Neuron", "children"), Output("clear-Neuron", "children")],
[Input("v-step", "children")], [State("interval", "value"), State("clear", "children"),
State("clear-Neuron", "children"), State("display-Neuron", "children")])
def display(value, step, clear, localClear, display):
if(localClear != clear):
super.clearData()
return [display, clear]
except Exception as e:
print("display:"+str(e))
except Exception as e:
print("CallbackName:" + str(e))
# ----------------------------------------------------------------
# Callback related Data retreiving functions
# ----------------------------------------------------------------
try:
print("Add functions here")
# ------------------------------------------------------------
# Data gethering (MongoDB operations)
# ------------------------------------------------------------
print("Add MongoDB functions here")
except Exception as e:
print("Data process loading:"+str(e))
\ No newline at end of file
"""Create a dash layout for the module
"""
from collections import deque
import dash_html_components as html
import dash_bootstrap_components as dbc
from .callbacks import callbacks
class layout():
""" Layout class
"""
# Needed variables for the graphs --------------------------------
#
xAxisGraphName = deque(maxlen=100)
#
# ----------------------------------------------------------------
def clearData(self):
""" Clear the data when moved forward or backward for more than one step
"""
self.xAxisGraphName.clear()
def Vis(self, app, g):
""" Create layer components
Args:
app : Flask app
g (Global_Var): reference to access global variables
Returns:
Dash app layer
"""
try:
layer = dbc.Card(
dbc.CardBody(
[
html.Div(id="neuron-vis", children=[
# Global show based on selected layer
html.H3("Your Layer here")
])
], style={"textAlign": "center", "padding": "10px"}
)
)
# load callbacks
callbacks().init(self, app, g)
# Return the Layer
return layer
except Exception as e:
print("MultiLayer:" + str(e))
\ No newline at end of file
""" Spark pre-processing operations .
"""
import traceback
def process(g):
""" Start processing and reduce module count .
Args:
g (Global_Var): reference to access global variables
"""
preProcessing(g)
g.modulesNbr = g.modulesNbr - 1
# Spark operations and pre-processing --------------------------------
def preProcessing(g):
"""Loads the GDD database into BDD .
Args:
g (Global_Var): reference to access global variables
"""
MODULE_NAME = ""
DOCUMENT_NAME = ""
OUTPUT_DOCUMENT_NAME = ""
MONGODBURL = g.MONGODBURL
try:
if (not (OUTPUT_DOCUMENT_NAME in g.db.list_collection_names())) and (DOCUMENT_NAME in g.db.list_collection_names()):
# Spark setup --------------------------------------------
if g.sparkSession == None:
g.createSparkSession()
# doing the heavy work -----------------------------------
# Save data into Mongo------------------------------------
#df.write.format("com.mongodb.spark.sql.DefaultSource") \
# .option("spark.mongodb.output.uri",
# MONGODBURL + g.name + "."+OUTPUT_DOCUMENT_NAME+"?authSource=admin&#readPreference=primaryPreferred").mode("overwrite").save()
#print("Saved to BDD")
# ------------------------------------------------------------
else:
if(not DOCUMENT_NAME in g.db.list_collection_names()):
print(DOCUMENT_NAME, "not found")
g.modules = [module for module in g.modules if module != MODULE_NAME]
print("done ", MODULE_NAME)
except Exception as e:
print("Error:" + str(e))
traceback.print_exc()
pass
\ No newline at end of file
...@@ -2,8 +2,6 @@ ...@@ -2,8 +2,6 @@
""" """
import traceback import traceback
from config import config
def process(g): def process(g):
""" Start processing and reduce module count . """ Start processing and reduce module count .
...@@ -24,9 +22,9 @@ def preProcessing(g): ...@@ -24,9 +22,9 @@ def preProcessing(g):
g (Global_Var): reference to access global variables g (Global_Var): reference to access global variables
""" """
MODULE_NAME = "" MODULE_NAME = ""
DOCUMENTNAME = "" DOCUMENT_NAME = ""
OUTPUTDOCUMENTNAME = "" OUTPUT_DOCUMENT_NAME = ""
MONGODBURL = config().MONGODBURL MONGODBURL = g.MONGODBURL
try: try:
if (not (OUTPUT_DOCUMENT_NAME in g.db.list_collection_names())) and (DOCUMENT_NAME in g.db.list_collection_names()): if (not (OUTPUT_DOCUMENT_NAME in g.db.list_collection_names())) and (DOCUMENT_NAME in g.db.list_collection_names()):
...@@ -39,11 +37,11 @@ def preProcessing(g): ...@@ -39,11 +37,11 @@ def preProcessing(g):
# Save data into Mongo------------------------------------ # Save data into Mongo------------------------------------
df.write.format("com.mongodb.spark.sql.DefaultSource") \ #df.write.format("com.mongodb.spark.sql.DefaultSource") \
.option("spark.mongodb.output.uri", # .option("spark.mongodb.output.uri",
MONGODBURL + g.name + "."+OUTPUTDOCUMENTNAME+"?authSource=admin&readPreference=primaryPreferred").mode("overwrite").save() # MONGODBURL + g.name + "."+OUTPUT_DOCUMENT_NAME+"?authSource=admin&readPreference=primaryPreferred").mode("overwrite").save()
print("Saved to BDD") #print("Saved to BDD")
# ------------------------------------------------------------ # ------------------------------------------------------------
else: else:
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment