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

Add a --manual_seed flag to the CLI #1445

Merged
Merged
Changes from 1 commit
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
Prev Previous commit
Add unittest for manual_seed
  • Loading branch information
dagardner-nv committed Dec 19, 2023
commit 77a223d8def8bf710d14f72560ef1074a9ff5fe5
19 changes: 19 additions & 0 deletions tests/test_cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@

import os
import shutil
from unittest import mock

import click
import mlflow
Expand Down Expand Up @@ -157,6 +158,24 @@ def test_autocomplete(self, tmp_path):
env={'HOME': str(tmp_path)})
assert result.exit_code == 0, result.output

@pytest.mark.usefixtures("restore_environ")
@pytest.mark.parametrize('use_environ', [True, False])
@pytest.mark.parametrize('value', [1, 13, 33])
@mock.patch('morpheus.utils.seed.manual_seed')
def test_manual_seed(self, mock_manual_seed: mock.MagicMock, value: int, use_environ: bool):
flags = ['run']
if use_environ:
os.environ['MORPHEUS_MANUAL_SEED'] = str(value)
else:
flags.append(f'--manual_seed={value}')

flags.append('pipeline-other')

runner = CliRunner()
result = runner.invoke(commands.cli, flags)
assert result.exit_code == 0, result.output
mock_manual_seed.assert_called_once_with(value)

@pytest.mark.replace_callback('pipeline_ae')
def test_pipeline_ae(self, config, callback_values):
"""
Expand Down