diff --git a/README.md b/README.md index be7694b..576e1ea 100644 --- a/README.md +++ b/README.md @@ -1,3 +1,4 @@ +
diff --git a/heimdallr/configuration/heimdallr_config.py b/heimdallr/configuration/heimdallr_config.py index c10b439..20ea398 100644 --- a/heimdallr/configuration/heimdallr_config.py +++ b/heimdallr/configuration/heimdallr_config.py @@ -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" diff --git a/heimdallr/entry_points/server.py b/heimdallr/entry_points/server.py index e6cb182..680d173 100644 --- a/heimdallr/entry_points/server.py +++ b/heimdallr/entry_points/server.py @@ -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) @@ -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() @@ -92,7 +96,7 @@ DEVELOPMENT = False DASH_APP.layout = get_root_layout(DEVELOPMENT) -LOG_WRITER: Writer = MockWriter() +#LOG_WRITER: Writer = MockWriter() @DASH_APP.callback( @@ -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", }, ) ) @@ -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) @@ -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}" ) @@ -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 @@ -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 @@ -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__": diff --git a/heimdallr/utilities/server/gpu_utilities.py b/heimdallr/utilities/server/gpu_utilities.py index 7ce22e8..d8b752b 100644 --- a/heimdallr/utilities/server/gpu_utilities.py +++ b/heimdallr/utilities/server/gpu_utilities.py @@ -8,6 +8,7 @@ Function to get GPU information. """ +import logging from typing import List, Mapping, Sequence import numpy @@ -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 @@ -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() @@ -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 diff --git a/requirements/requirements_server.txt b/requirements/requirements_server.txt index 31eef7e..381534d 100644 --- a/requirements/requirements_server.txt +++ b/requirements/requirements_server.txt @@ -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 \ No newline at end of file +waitress +dash-bootstrap-components \ No newline at end of file