Skip to content

Commit

Permalink
linter formatting
Browse files Browse the repository at this point in the history
  • Loading branch information
brifordwylie committed May 19, 2024
1 parent f40b02c commit 48dd892
Show file tree
Hide file tree
Showing 7 changed files with 113 additions and 117 deletions.
3 changes: 2 additions & 1 deletion applications/aws_dashboard/pages/license/page.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
"""License: A SageWorks Web Interface to view License Details"""

from dash import register_page
from dash import html
from dash_bootstrap_templates import load_figure_template
Expand Down Expand Up @@ -41,5 +42,5 @@
html.H2("SageWorks: License"),
details_component,
],
style={"padding": "12px 30px 30px 30px"}
style={"padding": "12px 30px 30px 30px"},
)
10 changes: 8 additions & 2 deletions src/sageworks/core/artifacts/model_core.py
Original file line number Diff line number Diff line change
Expand Up @@ -520,8 +520,14 @@ def onboard(self, ask_everything=False) -> bool:
# Now that we have all the details, let's onboard the Model with all the args
return self.onboard_with_args(self.model_type, target_column, feature_columns, endpoints, owner)

def onboard_with_args(self, model_type: ModelType, target_column: str = None, feature_list: list = None,
endpoints: list = None, owner: str = None) -> bool:
def onboard_with_args(
self,
model_type: ModelType,
target_column: str = None,
feature_list: list = None,
endpoints: list = None,
owner: str = None,
) -> bool:
"""Onboard the Model with the given arguments
Args:
Expand Down
9 changes: 2 additions & 7 deletions src/sageworks/utils/license_manager.py
Original file line number Diff line number Diff line change
Expand Up @@ -142,13 +142,8 @@ def read_signature_public_key():
def contact_license_server(cls) -> requests.Response:
"""Contact the SageWorks License Server to verify the license."""
server_url = "https://sageworks-keyserver.com/decode-key"
headers = {
"Content-Type": "application/json",
"x-api-key": "Z3dDGm4392V3klijcBbT3ccEutwwWMp82IbYa5i0"
}
data = {
"api_key": cls.api_key
}
headers = {"Content-Type": "application/json", "x-api-key": "Z3dDGm4392V3klijcBbT3ccEutwwWMp82IbYa5i0"}
data = {"api_key": cls.api_key}
return requests.post(server_url, headers=headers, json=data)


Expand Down
5 changes: 2 additions & 3 deletions src/sageworks/web_components/plugins/license_details.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ def create_component(self, component_id: str) -> html.Div:
id=component_id,
children=[
html.H3(id=f"{component_id}-header", children="License: Loading..."),
dcc.Markdown(id=f"{component_id}-details", children="Waiting for Data...", dangerously_allow_html=True)
dcc.Markdown(id=f"{component_id}-details", children="Waiting for Data...", dangerously_allow_html=True),
],
)

Expand Down Expand Up @@ -72,7 +72,7 @@ def update_properties(self, license: dict, **kwargs) -> list:
details += f"**Expiration:** {license['expires']}<br>"
details += f"**License Tier:** {license.get('tier', 'Open Source')}<br>"
details += "**Features:**\n"
for feature, value in license['features'].items():
for feature, value in license["features"].items():
details += f" - **{feature}:** {value}\n"

# Return the updated property values for the plugin
Expand All @@ -84,7 +84,6 @@ def update_properties(self, license: dict, **kwargs) -> list:
import dash
from sageworks.utils.config_manager import ConfigManager


# Grab the API Key from the SageWorks ConfigManager
cm = ConfigManager()
api_key = cm.get_config("SAGEWORKS_API_KEY")
Expand Down
26 changes: 17 additions & 9 deletions ui_testing/table_comparison.py
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ def create_component(self, component_id: str, theme: str) -> AgGrid:
dashGridOptions={"rowSelection": "single"},
defaultColDef={"flex": 1, "filter": True},
style={"maxHeight": "200px", "overflow": "auto"},
dangerously_allow_code=True # to allow hyperlinks in dag
dangerously_allow_code=True, # to allow hyperlinks in dag
)

# Fill in plugin properties
Expand Down Expand Up @@ -78,11 +78,19 @@ def update_properties(self, table_df: pd.DataFrame, **kwargs) -> list:

# Define column definitions based on the DataFrame
column_defs = [
{"field": col, "valueFormatter": {"function": "d3.format(',')(params.value)"}} if col == 'Salary'
else {"field": col, "valueFormatter": {"function": "d3.format('.2f')(params.value)"}} if col == 'Bonus'
else {"field": col, "valueFormatter": {"function": "params.value.toUpperCase()"}} if col == 'Name'
else {"field": col, "cellRenderer": "markdown"} if col == 'Company'
else {"field": col}
(
{"field": col, "valueFormatter": {"function": "d3.format(',')(params.value)"}}
if col == "Salary"
else (
{"field": col, "valueFormatter": {"function": "d3.format('.2f')(params.value)"}}
if col == "Bonus"
else (
{"field": col, "valueFormatter": {"function": "params.value.toUpperCase()"}}
if col == "Name"
else {"field": col, "cellRenderer": "markdown"} if col == "Company" else {"field": col}
)
)
)
for col in table_df.columns
]

Expand Down Expand Up @@ -113,14 +121,14 @@ def update_properties(self, table_df: pd.DataFrame, **kwargs) -> list:
df["Company"] = df["Company"].map(lambda x: f"<a href='https://www.google.com' target='_blank'>{x}</a>")

# Create the new AG Table component
AG_grid_themes = ['alpine', 'balham', 'material', 'quartz']
AG_grid_themes = ["alpine", "balham", "material", "quartz"]
dag_tables = []

for ag_theme in AG_grid_themes:
dag_tables += [html.Hr(), html.Div(f"Dash AG Grid - {ag_theme}:")]
for light_dark in ['', '-dark']:
for light_dark in ["", "-dark"]:
ag_table = AGTable()
theme = f'ag-theme-{ag_theme + light_dark} ag-theme-custom{light_dark}'
theme = f"ag-theme-{ag_theme + light_dark} ag-theme-custom{light_dark}"
ag_table_component = ag_table.create_component(f"ag-table-{ag_theme}{light_dark}", theme)
# This would normally be a callback, but we're just testing
ag_table_component.columnDefs, ag_table_component.rowData, ag_table_component.selectedRows = (
Expand Down
96 changes: 45 additions & 51 deletions ui_testing/theme_switching.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,66 +5,60 @@
app = dash.Dash(__name__)

# Layout of the app
app.layout = html.Div([
dcc.Dropdown(
id='theme-selector',
options=[
{'label': 'Light Theme', 'value': 'scatter-plot-light'},
{'label': 'Dark Theme', 'value': 'scatter-plot-dark'}
],
value='scatter-plot-light' # Default value
),
dcc.Graph(
id='scatter-plot',
className='dash-graph scatter-plot-light', # Initial class name and theme
figure={
'data': [
{'x': [1, 2, 3], 'y': [4, 1, 2], 'type': 'scatter', 'name': 'SF'},
app.layout = html.Div(
[
dcc.Dropdown(
id="theme-selector",
options=[
{"label": "Light Theme", "value": "scatter-plot-light"},
{"label": "Dark Theme", "value": "scatter-plot-dark"},
],
'layout': {
'title': 'Scatter Plot Example',
'plot_bgcolor': '#ffffff',
'paper_bgcolor': '#ffffff',
'font': {
'color': '#000000'
}
}
}
)
])
value="scatter-plot-light", # Default value
),
dcc.Graph(
id="scatter-plot",
className="dash-graph scatter-plot-light", # Initial class name and theme
figure={
"data": [
{"x": [1, 2, 3], "y": [4, 1, 2], "type": "scatter", "name": "SF"},
],
"layout": {
"title": "Scatter Plot Example",
"plot_bgcolor": "#ffffff",
"paper_bgcolor": "#ffffff",
"font": {"color": "#000000"},
},
},
),
]
)


# Callback to update the figure based on theme selection
@app.callback(
Output('scatter-plot', 'figure'),
[Input('theme-selector', 'value')]
)
@app.callback(Output("scatter-plot", "figure"), [Input("theme-selector", "value")])
def update_scatter_plot_figure(selected_theme):
if selected_theme == 'scatter-plot-dark':
if selected_theme == "scatter-plot-dark":
return {
'data': [{'x': [1, 2, 3], 'y': [4, 1, 2], 'type': 'scatter', 'name': 'SF'}],
'layout': {
'title': 'Scatter Plot Example',
'plot_bgcolor': '#333333',
'paper_bgcolor': '#333333',
'font': {
'color': '#ffffff'
}
}
"data": [{"x": [1, 2, 3], "y": [4, 1, 2], "type": "scatter", "name": "SF"}],
"layout": {
"title": "Scatter Plot Example",
"plot_bgcolor": "#333333",
"paper_bgcolor": "#333333",
"font": {"color": "#ffffff"},
},
}
else:
return {
'data': [{'x': [1, 2, 3], 'y': [4, 1, 2], 'type': 'scatter', 'name': 'SF'}],
'layout': {
'title': 'Scatter Plot Example',
'plot_bgcolor': '#ffffff',
'paper_bgcolor': '#ffffff',
'font': {
'color': '#000000'
}
}
"data": [{"x": [1, 2, 3], "y": [4, 1, 2], "type": "scatter", "name": "SF"}],
"layout": {
"title": "Scatter Plot Example",
"plot_bgcolor": "#ffffff",
"paper_bgcolor": "#ffffff",
"font": {"color": "#000000"},
},
}


# Run the app
if __name__ == '__main__':
if __name__ == "__main__":
app.run_server(debug=True)

81 changes: 37 additions & 44 deletions ui_testing/theme_switching_2.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,60 +6,53 @@
app = dash.Dash(__name__, external_stylesheets=[dbc.themes.BOOTSTRAP])

# Layout of the app
app.layout = html.Div([
dbc.Button("Switch to Dark Theme", id="theme-button", color="primary"),
dcc.Graph(
id='scatter-plot',
figure={
'data': [
{'x': [1, 2, 3], 'y': [4, 1, 2], 'type': 'scatter', 'name': 'SF'},
],
'layout': {
'title': 'Scatter Plot Example',
'plot_bgcolor': '#ffffff',
'paper_bgcolor': '#ffffff',
'font': {
'color': '#000000'
}
}
}
)
])
app.layout = html.Div(
[
dbc.Button("Switch to Dark Theme", id="theme-button", color="primary"),
dcc.Graph(
id="scatter-plot",
figure={
"data": [
{"x": [1, 2, 3], "y": [4, 1, 2], "type": "scatter", "name": "SF"},
],
"layout": {
"title": "Scatter Plot Example",
"plot_bgcolor": "#ffffff",
"paper_bgcolor": "#ffffff",
"font": {"color": "#000000"},
},
},
),
]
)


# Callback to switch themes dynamically
@app.callback(
Output('scatter-plot', 'figure'),
[Input('theme-button', 'n_clicks')],
prevent_initial_call=True
)
@app.callback(Output("scatter-plot", "figure"), [Input("theme-button", "n_clicks")], prevent_initial_call=True)
def switch_theme(n_clicks):
dark_mode = n_clicks % 2 != 0
if dark_mode:
return {
'data': [{'x': [1, 2, 3], 'y': [4, 1, 2], 'type': 'scatter', 'name': 'SF'}],
'layout': {
'title': 'Scatter Plot Example',
'plot_bgcolor': '#333333',
'paper_bgcolor': '#333333',
'font': {
'color': '#ffffff'
}
}
"data": [{"x": [1, 2, 3], "y": [4, 1, 2], "type": "scatter", "name": "SF"}],
"layout": {
"title": "Scatter Plot Example",
"plot_bgcolor": "#333333",
"paper_bgcolor": "#333333",
"font": {"color": "#ffffff"},
},
}
else:
return {
'data': [{'x': [1, 2, 3], 'y': [4, 1, 2], 'type': 'scatter', 'name': 'SF'}],
'layout': {
'title': 'Scatter Plot Example',
'plot_bgcolor': '#ffffff',
'paper_bgcolor': '#ffffff',
'font': {
'color': '#000000'
}
}
"data": [{"x": [1, 2, 3], "y": [4, 1, 2], "type": "scatter", "name": "SF"}],
"layout": {
"title": "Scatter Plot Example",
"plot_bgcolor": "#ffffff",
"paper_bgcolor": "#ffffff",
"font": {"color": "#000000"},
},
}


# Run the app
if __name__ == '__main__':
if __name__ == "__main__":
app.run_server(debug=True)

0 comments on commit 48dd892

Please sign in to comment.