Skip to content

Commit

Permalink
add scenery and node status view components (#261)
Browse files Browse the repository at this point in the history
* add scenery and node status view components

* update dependencies

* update import

* fix linting issue?

* fix style errors

* fix another style error

* attempt #2

* update pyproject.toml + Readme + License + tox (#264)

* update pyproject.toml + Readme + License + tox

* fix issue

* fix issue

* update the pyproject.toml

* fix code style issue

* add optislang-dash-lib package

---------

Co-authored-by: Jerfried Boly <[email protected]>
  • Loading branch information
ansRMorin and ansJBoly authored May 30, 2023
1 parent bb5f82c commit 35ee6bf
Show file tree
Hide file tree
Showing 5 changed files with 50 additions and 52 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@ ansys-solutions-products-ecosystem = {version = "0.1.dev0", source = "solutions-
ansys-solutions-optislang-parser = {version = "0.1.dev5", source = "solutions-private-pypi"}
ansys-solutions-optislang-wrapper = {version = "0.2.dev1", source = "solutions-private-pypi"}
ansys-solutions-optislang-frontend-components = {version = "0.1.dev3", source = "solutions-private-pypi"}
optislang-dash-lib = {version = "^0.0.1", source = "solutions-private-pypi"}
dash = {version = "^2.6"}
dash_bootstrap_components = {version = "^1.2"}
dash-extensions = {version = "^0.1"}
Expand Down Expand Up @@ -86,7 +87,7 @@ pytest-xdist = {version = "^3.0.2"}
pytest-mock = {version = "*"}
tox = {version = "^4.4.11"}

[tool.poetry.group.build] # Optional build requirements
[tool.poetry.group.build]
optional = true
[tool.poetry.group.build.dependencies]
build = {version = "^0.8.0"}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ class MonitoringStep(StepModel):
history: dict = None
parallel_coordinates: dict = None
status_overview: dict = None
project_state: dict = None

@transaction(
self=StepSpec(upload=["available_root_nodes", "available_system_nodes", "available_subsystem_nodes"]),
Expand Down Expand Up @@ -289,3 +290,20 @@ def get_status_overview(self, problem_setup_step):
self.status_overview = monitoring.get_status_overview(actor_name, to_dataframe=False)

monitoring.dispose()

@transaction(
self=StepSpec(upload=["project_state"]),
problem_setup_step=StepSpec(download=["project_file", "host", "port"]),
)
def get_project_state(self, problem_setup_step):
"""Get project state."""

monitoring = Monitoring(
project_file=problem_setup_step.project_file.path,
host=problem_setup_step.host,
port=problem_setup_step.port,
)

monitoring.initialize()
self.project_state = monitoring.get_scenery_and_node_status_view_data()
monitoring.dispose()
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
import time

from ansys.saf.glow.solution import StepModel, StepSpec, FileReference, transaction, long_running
from ansys.solutions.optislang.parser.placeholder import ProjectProperties
from ansys.solutions.optislang.parser.project_properties import ProjectProperties
from ansys.solutions.optislang.wrapper.monitoring import Monitoring
from ansys.solutions.optislang.wrapper.orchestrator import OptiSLangOrchestrator
from ansys.solutions.products_ecosystem.controller import AnsysProductsEcosystemController
Expand Down
Original file line number Diff line number Diff line change
@@ -1,25 +1,32 @@
# ©2023, ANSYS Inc. Unauthorized use, distribution or duplication is prohibited.

"""Frontend of the second step."""
"""Frontend of the scenery view tab."""

import dash_bootstrap_components as dbc
from dash_extensions.enrich import dcc, html
from dash_extensions.enrich import html
import optislang_dash_lib

from ansys.solutions.{{ cookiecutter.__solution_name_slug }}.solution.monitoring_step import MonitoringStep


def layout(monitoring_step: MonitoringStep):
"""Layout of the second step UI."""
# this page is used to display a diagram of system and node components of the project
# this diagram is generated with optislang and exists in the .opf file
# need pyoptislang commands to export this as a .png?
"""Layout of the scenery view tab."""

monitoring_step.get_project_state() # fetches data on page load

return html.Div(
[
html.Br(),
dbc.Row(
[
dcc.Markdown("**Scenery page: Under construction**", style={"font-size": "15px"}),
html.Div(
[
optislang_dash_lib.SceneryComponent(
id="input",
project_state=monitoring_step.project_state,
),
]
)
],
),
]
Expand Down
Original file line number Diff line number Diff line change
@@ -1,52 +1,24 @@
# ©2023, ANSYS Inc. Unauthorized use, distribution or duplication is prohibited.

"""Frontend of the second step."""
"""Frontend of the node status overview tab."""

from dash import dash_table
from dash_extensions.enrich import html
import pandas as pd
import optislang_dash_lib

from ansys.solutions.{{ cookiecutter.__solution_name_slug }}.solution.monitoring_step import MonitoringStep


class StatusOverviewTable(object):
""""""

def __init__(self, data):
"""Constructor."""

self.data = data

def render(self):
"""Generate table."""

if isinstance(self.data, pd.DataFrame):
return dash_table.DataTable(
data=self.data.to_dict("records"),
columns=[{"name": i, "id": i, "type": "text"} for i in self.data.columns],
fixed_rows={"headers": True},
sort_action="native",
row_selectable="multi",
page_action="native",
style_header={
"textAlign": "center",
"font_family": "Roboto",
"font_size": "15px",
"fontWeight": "bold",
},
style_cell={
"textAlign": "center",
"font_family": "Roboto",
"font_size": "15px",
},
)


def layout(monitoring_step: MonitoringStep):
"""Layout of the status overview tab UI."""

monitoring_step.get_status_overview()

status_overview_table = StatusOverviewTable(pd.DataFrame(monitoring_step.status_overview))

return html.Div([status_overview_table.render()])
"""Layout of the node status overview tab."""

monitoring_step.get_project_state() # fetches data on page load

return html.Div(
id="node-status-view",
children=[
optislang_dash_lib.Nodestatusviewcomponent(
id="node-status-view-component",
project_state=monitoring_step.project_state,
),
],
)

0 comments on commit 35ee6bf

Please sign in to comment.