Skip to content

Commit

Permalink
Fix bug
Browse files Browse the repository at this point in the history
  • Loading branch information
yixiaoer committed Jun 16, 2024
1 parent 1b40997 commit 02cf0b9
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 10 deletions.
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ authors = [
{ name="Shin", email="[email protected]" },
]
# we cannot use `dynamic` here, because it doesn't work on Python 3.8
version = "0.1.0"
version = "0.1.1"
dependencies = [
"psutil",
"fabric",
Expand Down
2 changes: 1 addition & 1 deletion src/tpux/__init__.py
Original file line number Diff line number Diff line change
@@ -1 +1 @@
__version__ = '0.1.0'
__version__ = '0.1.1'
21 changes: 13 additions & 8 deletions src/tpux/cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -51,14 +51,17 @@ def input_bool(prompt: str, *, default: Optional[Union[Literal['y'], Literal['n'
else:
print('Please answer "y" or "n".')

def input_priv_ipv4_addrs(prompt: str, default: Optional[List[IPv4Address]] = None) -> List[IPv4Address]:
def input_priv_ipv4_addrs(prompt: str, note: Optional[str] = None, default: Optional[List[IPv4Address]] = None) -> List[IPv4Address]:
if default is None:
default_str = ': '
else:
ip_str = ','.join(str(ip_addr) for ip_addr in default)
default_str = f' (default: {ip_str}): '
actual_prompt = f'{prompt}{default_str}'

if note is not None:
print(note)

while True:
s = input(actual_prompt)
if not s and default is not None:
Expand All @@ -74,12 +77,7 @@ def input_priv_ipv4_addrs(prompt: str, default: Optional[List[IPv4Address]] = No
except AddressValueError:
pass
ip_host0 = get_priv_ipv4_addr()
print(f'''Please input a list of valid private IPv4 addresses (comma-separated).
{YELLOW_START}To find the IPv4 addresses:
1. Open https://console.cloud.google.com/compute/tpus
2. Click on the node name of the TPU pod you're using in the current project
3. In the details, find the External IP addresses
4. Do NOT include the IP address of the current host: {ip_host0}{COLOR_RESET}''')
print(f'Please input a list of valid private IPv4 addresses (comma-separated).')

def get_priv_ipv4_addr(*, interface_prefix: str = 'ens') -> IPv4Address:
addrs = psutil.net_if_addrs()
Expand Down Expand Up @@ -226,7 +224,14 @@ def install_oh_my_zsh_on_hosts() -> None:
run_commands_on_all_hosts(install_oh_my_zsh_commands, include_local=True)

def config_podips() -> None:
ip_host_others = input_priv_ipv4_addrs('Input the private (internal) IPv4 address of the other hosts, comma separated')
note = f'''
{YELLOW_START}To find the IPv4 addresses,
1. Open https://console.cloud.google.com/compute/tpus
2. Click on the node name of the TPU pod you're using in the current project
3. In the details, find the External IP addresses
4. Do NOT include the IP address of the current host: {ip_host0}{COLOR_RESET}
'''
ip_host_others = input_priv_ipv4_addrs('Input the private (internal) IPv4 address of the other hosts, comma separated', note)
insert_ssh_config(ip_host_others=ip_host_others)
write_podips_config(ip_host_others=ip_host_others) # TODO: do we need to add host0 ip here?

Expand Down

0 comments on commit 02cf0b9

Please sign in to comment.