Skip to content

Commit

Permalink
modified
Browse files Browse the repository at this point in the history
  • Loading branch information
cnheider committed May 28, 2024
1 parent 83f8ff3 commit 85384eb
Show file tree
Hide file tree
Showing 5 changed files with 45 additions and 34 deletions.
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@

<!--![horn](.github/images/horn.svg "horn")-->

<p align="center">
Expand Down
12 changes: 6 additions & 6 deletions heimdallr/configuration/heimdallr_config.py
Original file line number Diff line number Diff line change
Expand Up @@ -46,12 +46,12 @@
CALENDAR_INTERVAL_MS = 1000 * 60 * 60

BUILD_STATUS_MAPPING = NOD(
streamserver="https://travis-ci.org/aivclab/streamserver.svg?branch=master",
dlcourse="https://github.com/aivclab/dlcourse.svg?branch=master",
poserecorder="https://github.com/aivclab/pose-recorder.svg",
vision="https://travis-ci.com/aivclab/vision.svg?branch=master",
RayKarsten="https://github.com/aivclab/RayKarstenWebAsm.svg",
dmr="https://github.com/aivclab/dmr.svg",
#streamserver="https://travis-ci.org/aivclab/streamserver.svg?branch=master",
#dlcourse="https://github.com/aivclab/dlcourse.svg?branch=master",
#poserecorder="https://github.com/aivclab/pose-recorder.svg",
#vision="https://travis-ci.com/aivclab/vision.svg?branch=master",
#RayKarsten="https://github.com/aivclab/RayKarstenWebAsm.svg",
#dmr="https://github.com/aivclab/dmr.svg",
) # .as_dict()
BUILD_STATUS_INTERVAL = "build-status-interval"

Expand Down
52 changes: 28 additions & 24 deletions heimdallr/entry_points/server.py
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,9 @@

from heimdallr.utilities.server.du_utilities import to_overall_du_process_df
from heimdallr.utilities.server.teams_status import team_members_status
import dash_bootstrap_components

logger = logging.getLogger(__name__)

log = logging.getLogger("werkzeug")
log.setLevel(logging.ERROR)
Expand All @@ -63,12 +66,13 @@
# external CSS stylesheets
external_stylesheets = [
"https://codepen.io/chriddyp/pen/bWLwgP.css",
{
"href": "https://stackpath.bootstrapcdn.com/bootstrap/4.1.3/css/bootstrap.min.css",
"rel": "stylesheet",
"integrity": "sha384-MCw98/SFnGE8fJT3GXwEOngsV7Zt27NXFoaoApmYm81iuXoPkFOJwJ8ERdknLPMO",
"crossorigin": "anonymous",
},
#{
# "href": "https://stackpath.bootstrapcdn.com/bootstrap/4.1.3/css/bootstrap.min.css",
# "rel": "stylesheet",
# "integrity": "sha384-MCw98/SFnGE8fJT3GXwEOngsV7Zt27NXFoaoApmYm81iuXoPkFOJwJ8ERdknLPMO",
# "crossorigin": "anonymous",
#},
dash_bootstrap_components.themes.DARKLY
]

GPU_STATS = NOD()
Expand All @@ -92,7 +96,7 @@

DEVELOPMENT = False
DASH_APP.layout = get_root_layout(DEVELOPMENT)
LOG_WRITER: Writer = MockWriter()
#LOG_WRITER: Writer = MockWriter()


@DASH_APP.callback(
Expand Down Expand Up @@ -203,11 +207,10 @@ def update_table(n: int) -> Div:
page_size=ALL_CONSTANTS.TABLE_PAGE_SIZE,
# style_as_list_view=True,
style_data_conditional=[
{"if": {"row_index": "odd"}, "backgroundColor": "rgb(248, 248, 248)"}
#{"if": {"row_index": "odd"}, "backgroundColor": "rgb(248, 248, 248)"}
],
style_header={
"backgroundColor": "rgb(230, 230, 230)",
"fontWeight": "bold",
#"backgroundColor": "rgb(230, 230, 230)", "fontWeight": "bold",
},
)
)
Expand Down Expand Up @@ -287,7 +290,6 @@ def on_post_config() -> Response:

def on_message(client: Any, userdata: Any, result: mqtt.client.MQTTMessage) -> None:
"""description"""
global LOG_WRITER
global GPU_STATS
global KEEP_ALIVE
d = json.loads(result.payload)
Expand All @@ -300,7 +302,7 @@ def on_message(client: Any, userdata: Any, result: mqtt.client.MQTTMessage) -> N
GPU_STATS[key] = d[key] # ["gpu_stats"]
DU_STATS[key] = {}
KEEP_ALIVE[key] = 0
LOG_WRITER(
logger.info(
f"received payload for {keys}, retain:{result.retain}, timestamp:{result.timestamp}"
)

Expand Down Expand Up @@ -338,7 +340,7 @@ def setup_mqtt_connection(settings) -> None:
)
MQTT_CLIENT.subscribe(ALL_CONSTANTS.MQTT_TOPIC, ALL_CONSTANTS.MQTT_QOS)
except Exception as e:
LOG_WRITER(f"MQTT connection error: {e}")
logger.error(f"MQTT connection error: {e}")
# raise e


Expand All @@ -349,18 +351,20 @@ def main(
**kwargs,
) -> None:
"""description"""
global LOG_WRITER, DEVELOPMENT
global DEVELOPMENT

if setting_scope == SettingScopeEnum.user:
LOG_WRITER = LogWriter(
ensure_existence(PROJECT_APP_PATH.user_log) / f"{PROJECT_NAME}_server.log"
)
else:
LOG_WRITER = LogWriter(
ensure_existence(PROJECT_APP_PATH.site_log) / f"{PROJECT_NAME}_server.log"
)
if False:
if setting_scope == SettingScopeEnum.user:
LOG_WRITER = LogWriter(
ensure_existence(PROJECT_APP_PATH.user_log) / f"{PROJECT_NAME}_server.log"
)
else:
LOG_WRITER = LogWriter(
ensure_existence(PROJECT_APP_PATH.site_log) / f"{PROJECT_NAME}_server.log"
)

LOG_WRITER.open()

LOG_WRITER.open()
MQTT_CLIENT.on_message = on_message
# MQTT_CLIENT.on_disconnect = on_disconnect

Expand Down Expand Up @@ -393,7 +397,7 @@ def main(
# DASH_APP.run_server(host=host, port=port)
serve(DASH_APP.server, **kwargs)

LOG_WRITER.close()
#LOG_WRITER.close()


if __name__ == "__main__":
Expand Down
11 changes: 8 additions & 3 deletions heimdallr/utilities/server/gpu_utilities.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
Function to get GPU information.
"""

import logging
from typing import List, Mapping, Sequence

import numpy
Expand All @@ -28,16 +29,18 @@
from heimdallr.utilities.date_tools import timestamp_to_datetime
from heimdallr.utilities.publisher.unpacking import pull_gpu_info

MB_DIVISOR = int(1024**2)
MB_DIVISOR = int(1024 ** 2)

__all__ = [
"to_overall_gpu_process_df",
"per_machine_per_device_pie_charts",
]

logger = logging.getLogger(__name__)


def to_overall_gpu_process_df(
gpu_stats: Mapping, sort_by_key="used_gpu_mem"
gpu_stats: Mapping, sort_by_key="used_gpu_mem"
) -> DataFrame:
"""
to overall gpu usage process df
Expand All @@ -59,6 +62,8 @@ def to_overall_gpu_process_df(

if sort_by_key in out_df.columns:
out_df.sort_values(by=sort_by_key, axis=0, ascending=False, inplace=True)
else:
logger.warning(f"{sort_by_key} was not found in {out_df.columns}")

if len(out_df) == 0:
return pandas.DataFrame()
Expand All @@ -82,7 +87,7 @@ def to_overall_gpu_process_df(


def per_machine_per_device_pie_charts(
gpu_stats: Mapping, keep_alive: Sequence[Number]
gpu_stats: Mapping, keep_alive: Sequence[Number]
) -> List[html.Div]:
"""
per machine per device pie charts
Expand Down
3 changes: 2 additions & 1 deletion requirements/requirements_server.txt
Original file line number Diff line number Diff line change
Expand Up @@ -23,4 +23,5 @@ msal
pillow>=10.0.1 # not directly required, pinned by Snyk to avoid a vulnerability
requests>=2.32.0 # not directly required, pinned by Snyk to avoid a vulnerability
wheel>=0.38.0 # not directly required, pinned by Snyk to avoid a vulnerability
waitress
waitress
dash-bootstrap-components

0 comments on commit 85384eb

Please sign in to comment.