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 Apr 18, 2024
1 parent ff02514 commit 1d8ea61
Show file tree
Hide file tree
Showing 54 changed files with 22 additions and 22 deletions.
2 changes: 1 addition & 1 deletion milatools/cli/commands.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@
from ..utils.remote_v1 import RemoteV1
from .code_command import add_mila_code_arguments
from .common import forward, standard_server
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.
2 changes: 1 addition & 1 deletion milatools/utils/compute_node.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
import warnings

from milatools.cli import console
from milatools.cli.init_command import DRAC_CLUSTERS
from milatools.cli.init import DRAC_CLUSTERS
from milatools.cli.utils import get_hostname_to_use_for_compute_node
from milatools.utils.remote_v1 import Hide
from milatools.utils.remote_v2 import RemoteV2, logger, ssh_command
Expand Down
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
2 changes: 1 addition & 1 deletion tests/cli/test_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
yn,
)

from .test_init_command import PipeInput, input_pipe # noqa
from .test_init import PipeInput, input_pipe # noqa


def test_randname(file_regression):
Expand Down
8 changes: 4 additions & 4 deletions tests/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
import questionary
from fabric.connection import Connection

from milatools.cli.init_command import setup_ssh_config
from milatools.cli.init import setup_ssh_config
from milatools.utils.compute_node import get_queued_milatools_job_ids
from milatools.utils.remote_v1 import RemoteV1
from milatools.utils.remote_v2 import (
Expand Down Expand Up @@ -360,7 +360,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 @@ -381,9 +381,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 1d8ea61

Please sign in to comment.