Skip to content

Commit

Permalink
Replace usage of deprecated on_start method in monitor stage
Browse files Browse the repository at this point in the history
  • Loading branch information
dagardner-nv committed Jan 11, 2024
1 parent a29cece commit 5154135
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 8 deletions.
4 changes: 2 additions & 2 deletions morpheus/stages/general/monitor_stage.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# Copyright (c) 2021-2023, NVIDIA CORPORATION.
# Copyright (c) 2021-2024, NVIDIA CORPORATION.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
Expand Down Expand Up @@ -99,7 +99,7 @@ def accepted_types(self) -> typing.Tuple:
def supports_cpp_node(self):
return False

def on_start(self):
async def start_async(self):
"""
Starts the pipeline stage's progress bar.
"""
Expand Down
13 changes: 7 additions & 6 deletions tests/test_monitor_stage.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#!/usr/bin/env python
# SPDX-FileCopyrightText: Copyright (c) 2022-2023, NVIDIA CORPORATION & AFFILIATES. All rights reserved.
# SPDX-FileCopyrightText: Copyright (c) 2022-2024, NVIDIA CORPORATION & AFFILIATES. All rights reserved.
# SPDX-License-Identifier: Apache-2.0
#
# Licensed under the Apache License, Version 2.0 (the "License");
Expand All @@ -14,6 +14,7 @@
# See the License for the specific language governing permissions and
# limitations under the License.

import asyncio
import inspect
import logging
import os
Expand Down Expand Up @@ -59,13 +60,13 @@ def two_x(x):


@mock.patch('morpheus.controllers.monitor_controller.MorpheusTqdm')
def test_on_start(mock_morph_tqdm: mock.MagicMock, config: Config):
def test_start_async(mock_morph_tqdm: mock.MagicMock, config: Config):
mock_morph_tqdm.return_value = mock_morph_tqdm

stage = MonitorStage(config, log_level=logging.WARNING)
assert stage._mc._progress is None

stage.on_start()
asyncio.run(stage.start_async())
mock_morph_tqdm.assert_called_once()
mock_morph_tqdm.reset.assert_called_once()
assert stage._mc._progress is mock_morph_tqdm
Expand All @@ -82,7 +83,7 @@ def test_stop(mock_morph_tqdm: mock.MagicMock, config: Config):
stage.stop()
mock_morph_tqdm.assert_not_called()

stage.on_start()
asyncio.run(stage.start_async())
stage.stop()
mock_morph_tqdm.close.assert_called_once()

Expand All @@ -94,7 +95,7 @@ def test_refresh(mock_morph_tqdm: mock.MagicMock, config: Config):
stage = MonitorStage(config, log_level=logging.WARNING)
assert stage._mc._progress is None

stage.on_start()
asyncio.run(stage.start_async())
stage._mc.refresh_progress(None)
mock_morph_tqdm.refresh.assert_called_once()

Expand Down Expand Up @@ -138,7 +139,7 @@ def test_progress_sink(mock_morph_tqdm: mock.MagicMock, config: Config):
mock_morph_tqdm.return_value = mock_morph_tqdm

stage = MonitorStage(config, log_level=logging.WARNING)
stage.on_start()
asyncio.run(stage.start_async())

stage._mc.progress_sink(None)
assert stage._mc._determine_count_fn is None
Expand Down

0 comments on commit 5154135

Please sign in to comment.