Skip to content

Commit

Permalink
Rename init_command.py -> init.py (consistency)
Browse files Browse the repository at this point in the history
Signed-off-by: Fabrice Normandin <normandf@mila.quebec>
  • Loading branch information
lebrice committed May 16, 2024
1 parent a7bba8e commit 982e67b
Show file tree
Hide file tree
Showing 52 changed files with 20 additions and 20 deletions.
2 changes: 1 addition & 1 deletion milatools/cli/commands.py
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@
)

from ..__version__ import __version__
from .init_command import (
from .init import (
print_welcome_message,
setup_keys_on_login_node,
setup_passwordless_ssh_access,
Expand Down
File renamed without changes.
30 changes: 15 additions & 15 deletions tests/cli/test_init_command.py → tests/cli/test_init.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,8 @@
from prompt_toolkit.input import PipeInput, create_pipe_input
from pytest_regressions.file_regression import FileRegressionFixture

from milatools.cli import init_command
from milatools.cli.init_command import (
from milatools.cli import init
from milatools.cli.init import (
DRAC_CLUSTERS,
_get_drac_username,
_get_mila_username,
Expand Down Expand Up @@ -845,12 +845,12 @@ def test_setup_windows_ssh_config_from_wsl(
windows_ssh_config_path = windows_home / ".ssh" / "config"

monkeypatch.setattr(
init_command,
init,
running_inside_WSL.__name__,
Mock(spec=running_inside_WSL, return_value=True),
)
monkeypatch.setattr(
init_command,
init,
get_windows_home_path_in_wsl.__name__,
Mock(spec=get_windows_home_path_in_wsl, return_value=windows_home),
)
Expand Down Expand Up @@ -921,15 +921,15 @@ def test_setup_vscode_settings(
json.dump(initial_settings, f, indent=4)

monkeypatch.setattr(
init_command,
init_command.vscode_installed.__name__,
Mock(spec=init_command.vscode_installed, return_value=True),
init,
init.vscode_installed.__name__,
Mock(spec=init.vscode_installed, return_value=True),
)
monkeypatch.setattr(
init_command,
init_command.get_expected_vscode_settings_json_path.__name__,
init,
init.get_expected_vscode_settings_json_path.__name__,
Mock(
spec=init_command.get_expected_vscode_settings_json_path,
spec=init.get_expected_vscode_settings_json_path,
return_value=vscode_settings_json_path,
),
)
Expand Down Expand Up @@ -1005,12 +1005,12 @@ def test_setup_windows_ssh_config_from_wsl_copies_keys(
monkeypatch.setattr(Path, "home", Mock(spec=Path.home, return_value=linux_home))

monkeypatch.setattr(
init_command,
init,
running_inside_WSL.__name__,
Mock(spec=running_inside_WSL, return_value=True),
)
monkeypatch.setattr(
init_command,
init,
get_windows_home_path_in_wsl.__name__,
Mock(spec=get_windows_home_path_in_wsl, return_value=windows_home),
)
Expand Down Expand Up @@ -1570,16 +1570,16 @@ def test_setup_passwordless_ssh_access(
spec=setup_passwordless_ssh_access_to_cluster,
side_effect=[accept_mila, *(accept_drac for _ in drac_clusters_in_ssh_config)],
)
import milatools.cli.init_command
import milatools.cli.init

monkeypatch.setattr(
milatools.cli.init_command,
milatools.cli.init,
setup_passwordless_ssh_access_to_cluster.__name__,
mock_setup_passwordless_ssh_access_to_cluster,
)

monkeypatch.setattr(
milatools.cli.init_command,
milatools.cli.init,
setup_keys_on_login_node.__name__,
Mock(spec=setup_keys_on_login_node),
)
Expand Down
8 changes: 4 additions & 4 deletions tests/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
import milatools.utils.parallel_progress
import milatools.utils.remote_v2
from milatools.cli import console
from milatools.cli.init_command import setup_ssh_config
from milatools.cli.init import setup_ssh_config
from milatools.cli.utils import SSH_CONFIG_FILE
from milatools.utils.compute_node import get_queued_milatools_job_ids
from milatools.utils.remote_v1 import RemoteV1
Expand Down Expand Up @@ -379,7 +379,7 @@ def ssh_config_file(
monkeypatch: pytest.MonkeyPatch,
) -> Path:
"""Fixture that creates the SSH config as setup by `mila init`."""
from milatools.cli.init_command import yn
from milatools.cli.init import yn

# NOTE: might want to put this in a fixture if we wanted the "real" mila / drac
# usernames in the config.
Expand All @@ -400,9 +400,9 @@ def _yn(question: str) -> bool:

mock_yn = Mock(spec=yn, side_effect=_yn)

import milatools.cli.init_command
import milatools.cli.init

monkeypatch.setattr(milatools.cli.init_command, yn.__name__, mock_yn)
monkeypatch.setattr(milatools.cli.init, yn.__name__, mock_yn)

def _mock_unsafe_ask(question: str, *args, **kwargs) -> str:
question = question.strip()
Expand Down

0 comments on commit 982e67b

Please sign in to comment.