-
Notifications
You must be signed in to change notification settings - Fork 161
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Serialize datetime objects into the module config (#1592)
* Fixes an issue where the `--start_time` flag was being ignored * Prior to nv-morpheus/MRC#451 the `datetime` objects being stored in the config were being serialized to json null, after that change an exception was raised. Closes #1590 ## By Submitting this PR I confirm: - I am familiar with the [Contributing Guidelines](https://github.com/nv-morpheus/Morpheus/blob/main/docs/source/developer_guide/contributing.md). - When the PR is ready for review, new or existing tests cover these changes. - When the PR is ready for review, the documentation is up to date with these changes. Authors: - David Gardner (https://github.com/dagardner-nv) Approvers: - Michael Demoret (https://github.com/mdemoret-nv) URL: #1592
- Loading branch information
1 parent
10922a4
commit eaba5bb
Showing
4 changed files
with
70 additions
and
8 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
60 changes: 60 additions & 0 deletions
60
tests/examples/digital_fingerprinting/utils/test_config_generator.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,60 @@ | ||
# SPDX-FileCopyrightText: Copyright (c) 2024, NVIDIA CORPORATION & AFFILIATES. All rights reserved. | ||
# SPDX-License-Identifier: Apache-2.0 | ||
# | ||
# Licensed under the Apache License, Version 2.0 (the "License"); | ||
# you may not use this file except in compliance with the License. | ||
# You may obtain a copy of the License at | ||
# | ||
# http://www.apache.org/licenses/LICENSE-2.0 | ||
# | ||
# Unless required by applicable law or agreed to in writing, software | ||
# distributed under the License is distributed on an "AS IS" BASIS, | ||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
# See the License for the specific language governing permissions and | ||
# limitations under the License. | ||
|
||
import logging | ||
from datetime import datetime | ||
|
||
import pytest | ||
|
||
from morpheus.config import Config | ||
|
||
|
||
@pytest.fixture(name="dfp_arg_parser") | ||
def dfp_arg_parser_fixture(): | ||
from dfp.utils.dfp_arg_parser import DFPArgParser | ||
dfp_arg_parser = DFPArgParser(skip_user=["unittest-skip-user"], | ||
only_user=["unittest-only-user"], | ||
start_time=datetime(1993, 4, 5, 6, 7, 8), | ||
log_level=logging.DEBUG, | ||
cache_dir=".cache", | ||
sample_rate_s="20", | ||
duration="2days", | ||
source="unittest", | ||
tracking_uri="http://unittest", | ||
silence_monitors=False, | ||
mlflow_experiment_name_formatter="unittest-experiment", | ||
mlflow_model_name_formatter="unittest-model", | ||
train_users="unittest-train-users") | ||
dfp_arg_parser.init() | ||
yield dfp_arg_parser | ||
|
||
|
||
@pytest.fixture(name="schema") | ||
def schema_fixture(config: Config): | ||
from dfp.utils.schema_utils import SchemaBuilder | ||
schema_builder = SchemaBuilder(config, "duo") | ||
yield schema_builder.build_schema() | ||
|
||
|
||
def test_constructor(config: Config, dfp_arg_parser: "DFPArgParser", schema: "Schema"): # noqa: F821 | ||
from dfp.utils.config_generator import ConfigGenerator | ||
|
||
config_generator = ConfigGenerator(config=config, dfp_arg_parser=dfp_arg_parser, schema=schema, encoding="latin1") | ||
|
||
assert config_generator._config is config | ||
assert config_generator._dfp_arg_parser is dfp_arg_parser | ||
assert config_generator._encoding == "latin1" | ||
assert config_generator._start_time_str == "1993-04-05T06:07:08+00:00" | ||
assert config_generator._end_time_str == "1993-04-07T06:07:08+00:00" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters