Skip to content

Commit

Permalink
plugin updates
Browse files Browse the repository at this point in the history
  • Loading branch information
brifordwylie committed Mar 31, 2024
1 parent 5a646a7 commit 50b07e9
Show file tree
Hide file tree
Showing 5 changed files with 80 additions and 59 deletions.
24 changes: 24 additions & 0 deletions examples/ag-grid/hello_world.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
from dash import Dash, html
import dash_ag_grid as dag
import pandas as pd

df = pd.read_csv("https://raw.githubusercontent.com/plotly/datasets/master/wind_dataset.csv")

app = Dash(__name__)

columnDefs = [
{ 'field': 'direction' },
{ 'field': 'strength' },
{ 'field': 'frequency'},
]

grid = dag.AgGrid(
id="get-started-example-basic",
rowData=df.to_dict("records"),
columnDefs=columnDefs,
)

app.layout = html.Div([grid])

if __name__ == "__main__":
app.run(debug=True)
9 changes: 6 additions & 3 deletions examples/plugins/pages/my_plugin_page.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,9 @@
import dash_bootstrap_components as dbc
import logging
import plotly.graph_objs as go
from dash_bootstrap_templates import load_figure_template

# SageWorks Imports
from sageworks.utils.plugin_manager import PluginManager


class MyPluginPage:
Expand All @@ -18,8 +20,9 @@ def __init__(self):
self.graph_1 = None
self.graph_2 = None

# Put the components into 'dark' mode (this doesn't seems to work for some reason)
load_figure_template("darkly")
# Get our view from the PluginManager
pm = PluginManager()
self.my_view = pm.get_view("MyViewPlugin")

def page_setup(self, app: dash.Dash):
"""Required function to set up the page"""
Expand Down
54 changes: 0 additions & 54 deletions examples/plugins/views/model_plugin_view.py

This file was deleted.

48 changes: 48 additions & 0 deletions examples/plugins/views/my_view_plugin.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
"""MyViewPlugin is a tailored view of the Model Summary data + Details"""

import pandas as pd

# SageWorks Imports
from sageworks.views.view import View
from sageworks.api import Meta


class MyViewPlugin(View):
def __init__(self):
"""MyViewPlugin pulls Model metadata"""

# Call SuperClass Initialization
super().__init__()

# We're using the SageWorks Meta class to get information about models
self.meta = Meta()

def refresh(self):
"""Refresh our data (for this example, we don't need to)"""
pass

def view_data(self) -> pd.DataFrame:
"""Get all the data that's useful for this view
Returns:
pd.DataFrame: DataFrame of the Models Data
"""
models = self.meta.models()
models["uuid"] = models["Model Group"] # uuid is needed for identifying the model
return models


if __name__ == "__main__":
# Exercising the MyViewPlugin
import pandas as pd

pd.options.display.max_columns = None
pd.options.display.width = 1000

# Create the class and get the AWS Model details
model_view = MyViewPlugin()

# List the Models
print("ModelsSummary:")
summary = model_view.view_data()
print(summary.head())
4 changes: 2 additions & 2 deletions examples/plugins/web_components/model_plugin.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ def create_component(self, component_id: str) -> dcc.Graph:
def update_contents(self, model: Model) -> go.Figure:
"""Create a Figure for the plugin.
Args:
model (Model): An instantiated Endpoint object
model (Model): An instantiated Model object
Returns:
go.Figure: A Plotly Figure object
"""
Expand All @@ -47,7 +47,7 @@ def update_contents(self, model: Model) -> go.Figure:


if __name__ == "__main__":
# This class takes in model details and generates a EndpointTurbo
# This class takes in model details and generates a pie chart
from sageworks.api.model import Model

# Instantiate an Endpoint
Expand Down

0 comments on commit 50b07e9

Please sign in to comment.