Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove redundant copy of the load_labels_file method #1901

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ from morpheus.config import Config
from morpheus.config import ConfigAutoEncoder
from morpheus.config import CppConfig
from morpheus.cli.utils import get_package_relative_file
from morpheus.cli.utils import load_labels_file
from morpheus.utils.file_utils import load_labels_file
```
```python
CppConfig.set_should_use_cpp(False)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,6 @@

from morpheus.cli.utils import get_log_levels
from morpheus.cli.utils import get_package_relative_file
from morpheus.cli.utils import load_labels_file
from morpheus.cli.utils import parse_log_level
from morpheus.common import FileTypes
from morpheus.common import FilterSource
Expand All @@ -60,6 +59,7 @@
from morpheus.utils.column_info import RenameColumn
from morpheus.utils.column_info import StringCatColumn
from morpheus.utils.file_utils import date_extractor
from morpheus.utils.file_utils import load_labels_file
from morpheus.utils.logger import configure_logging


Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,11 +21,11 @@
from dfp.utils.schema_utils import Schema

from morpheus.cli.utils import get_package_relative_file
from morpheus.cli.utils import load_labels_file
from morpheus.config import Config
from morpheus.config import ConfigAutoEncoder
from morpheus.config import CppConfig
from morpheus.messages import ControlMessage
from morpheus.utils.file_utils import load_labels_file
from morpheus.utils.module_ids import MORPHEUS_MODULE_NAMESPACE


Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,6 @@

from morpheus.cli.utils import get_log_levels
from morpheus.cli.utils import get_package_relative_file
from morpheus.cli.utils import load_labels_file
from morpheus.cli.utils import parse_log_level
from morpheus.common import FileTypes
from morpheus.common import FilterSource
Expand All @@ -58,6 +57,7 @@
from morpheus.utils.column_info import RenameColumn
from morpheus.utils.column_info import StringCatColumn
from morpheus.utils.file_utils import date_extractor
from morpheus.utils.file_utils import load_labels_file
from morpheus.utils.logger import configure_logging


Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,6 @@

from morpheus.cli.utils import get_log_levels
from morpheus.cli.utils import get_package_relative_file
from morpheus.cli.utils import load_labels_file
from morpheus.cli.utils import parse_log_level
from morpheus.common import FileTypes
from morpheus.common import FilterSource
Expand All @@ -59,6 +58,7 @@
from morpheus.utils.column_info import RenameColumn
from morpheus.utils.column_info import StringCatColumn
from morpheus.utils.file_utils import date_extractor
from morpheus.utils.file_utils import load_labels_file
from morpheus.utils.logger import configure_logging


Expand Down

Large diffs are not rendered by default.

Large diffs are not rendered by default.

Large diffs are not rendered by default.

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,6 @@

from morpheus.cli.utils import get_log_levels
from morpheus.cli.utils import get_package_relative_file
from morpheus.cli.utils import load_labels_file
from morpheus.cli.utils import parse_log_level
from morpheus.common import FileTypes
from morpheus.config import Config
Expand All @@ -53,6 +52,7 @@
from morpheus.utils.column_info import RenameColumn
from morpheus.utils.column_info import StringCatColumn
from morpheus.utils.file_utils import date_extractor
from morpheus.utils.file_utils import load_labels_file
from morpheus.utils.logger import configure_logging


Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,6 @@

from morpheus.cli.utils import get_log_levels
from morpheus.cli.utils import get_package_relative_file
from morpheus.cli.utils import load_labels_file
from morpheus.cli.utils import parse_log_level
from morpheus.common import FileTypes
from morpheus.config import Config
Expand All @@ -54,6 +53,7 @@
from morpheus.utils.column_info import RenameColumn
from morpheus.utils.column_info import StringCatColumn
from morpheus.utils.file_utils import date_extractor
from morpheus.utils.file_utils import load_labels_file
from morpheus.utils.logger import configure_logging


Expand Down
2 changes: 1 addition & 1 deletion python/morpheus/morpheus/cli/commands.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,6 @@
from morpheus.cli.utils import get_enum_keys
from morpheus.cli.utils import get_log_levels
from morpheus.cli.utils import get_pipeline_from_ctx
from morpheus.cli.utils import load_labels_file
from morpheus.cli.utils import parse_enum
from morpheus.cli.utils import parse_log_level
from morpheus.cli.utils import prepare_command
Expand All @@ -39,6 +38,7 @@
from morpheus.config import ConfigOnnxToTRT
from morpheus.config import CppConfig
from morpheus.config import PipelineModes
from morpheus.utils.file_utils import load_labels_file
from morpheus.utils.logger import configure_logging

# pylint: disable=line-too-long, import-outside-toplevel, invalid-name, global-at-module-level, unused-argument
Expand Down
8 changes: 2 additions & 6 deletions python/morpheus/morpheus/cli/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,8 @@
import morpheus
from morpheus.config import Config
from morpheus.config import ConfigBase
# For backwards compatibility
from morpheus.utils.file_utils import load_labels_file # pylint: disable=unused-import # noqa: F401

# Ignore pipeline unless we are typechecking since it takes a while to import
if (typing.TYPE_CHECKING):
Expand Down Expand Up @@ -193,12 +195,6 @@ def parse_enum(_: click.Context, _2: click.Parameter, value: str, enum_class: ty
return result


def load_labels_file(labels_file: str) -> typing.List[str]:
"""Returns a list of labels from the given file, where each line is a label."""
with open(labels_file, "r", encoding='UTF-8') as fh:
return [x.strip() for x in fh.readlines()]


def get_package_relative_file(filename: str):
"""
If `filename` is a relative path, and does not exist, attempt to locate the file relative to the directory of the
Expand Down
5 changes: 2 additions & 3 deletions python/morpheus/morpheus/utils/file_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@

import os
import re
import typing
from datetime import datetime
from datetime import timezone

Expand Down Expand Up @@ -60,7 +59,7 @@ def get_data_file_path(data_filename: str) -> str:
return data_filename


def load_labels_file(labels_filename: str) -> typing.List[str]:
def load_labels_file(labels_filename: str) -> list[str]:
"""
Get list of labels from file.

Expand All @@ -71,7 +70,7 @@ def load_labels_file(labels_filename: str) -> typing.List[str]:

Returns
-------
typing.List[str]
list[str]
List of labels
"""
with open(labels_filename, "r", encoding='UTF-8') as fh:
Expand Down
Loading