Skip to content

Commit

Permalink
Fix bugs
Browse files Browse the repository at this point in the history
Co-authored-by: Ayaka <[email protected]>
  • Loading branch information
yixiaoer and ayaka14732 committed Jun 15, 2024
1 parent 2b401f0 commit 386b41d
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 14 deletions.
11 changes: 11 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
# tpux

export PATH="$HOME/.local/bin:$PATH"

Use `podrun` to make all hosts purr like a kitty:
```sh
echo echo meow | podrun -i
Expand All @@ -9,3 +11,12 @@ echo echo meow | podrun -i

- [ ] `env['DEBIAN_FRONTEND'] = 'noninteractive'` for pod
- [ ] Create venv

## Example

```sh
touch ~/nfs_share/meow
echo ls ~/nfs_share/meow
echo ls -l ~/nfs_share/meow | podrun -i
```

11 changes: 6 additions & 5 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,12 @@ name = "tpux"
authors = [
{ name="Shin", email="[email protected]" },
]
# we cannot use `dynamic` here, because it doesn't work on Python 3.8
version = "0.1.0"
dependencies = [
"psutil",
"fabric",
]
description = "A set of Python scripts that makes your experience on TPU better"
readme = "README.md"
requires-python = ">=3.8"
Expand All @@ -19,16 +25,11 @@ classifiers = [
'Topic :: System :: Distributed Computing',
"Operating System :: POSIX :: Linux",
]
dynamic = ["dependencies", "version"]

[project.urls]
Homepage = "https://github.com/yixiaoer/tpux"
Issues = "https://github.com/yixiaoer/tpux/issues"

[tool.setuptools.dynamic]
dependencies = {file = ["requirements.txt"]}
version = {attr = "tpux.__version__"}

[project.scripts]
tpux = "tpux.cli:main"
podrun = "tpux.podrun:main"
16 changes: 7 additions & 9 deletions src/tpux/cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -233,8 +233,9 @@ def install_nfs_on_hosts():
def insert_exports_config():
hosts = get_podips()
export_file_name = '/etc/exports'
export_file_path = Path(export_file_name)

export_file = Path(export_file_name).read_text()
export_file = '' if not export_file_path.exists() else export_file_path.read_text()

new_entries = '\n'.join(f'/nfs_share {ip}(rw,sync,no_subtree_check)' for ip in hosts)
export_file_new = f'''
Expand All @@ -259,12 +260,9 @@ def config_nfs() -> None:
run_command_on_localhost('sudo exportfs -ra', check=True)
run_command_on_localhost('sudo systemctl restart nfs-kernel-server', check=True)

run_commands_on_all_hosts('sudo mkdir -p /nfs_share', include_local=False)
run_commands_on_all_hosts(f'sudo mount {ip_host0}:/nfs_share /nfs_share', include_local=False)
run_commands_on_all_hosts('ln -sf /nfs_share ~/nfs_share', include_local=True)

# run_command_on_localhost('touch ~/nfs_share/meow', include_local=True)
# run_commands_on_all_hosts('ls -la ~/nfs_share/meow', include_local=True)
run_command_on_all_hosts('sudo mkdir -p /nfs_share', include_local=False)
run_command_on_all_hosts(f'sudo mount {ip_host0}:/nfs_share /nfs_share', include_local=False)
run_command_on_all_hosts('ln -sf /nfs_share ~/nfs_share', include_local=True)

def setup_single_host() -> None:
check_is_not_root()
Expand All @@ -276,15 +274,15 @@ def setup_single_host() -> None:

def setup_tpu_pod() -> None:
check_is_not_root()
check_tpu_chip_exists()
# check_tpu_chip_exists()

config_podips()
generate_ssh_key()

update_apt_on_hosts()
install_packages_on_hosts()
install_oh_my_zsh_on_hosts()

install_nfs_on_hosts()
insert_exports_config()
config_nfs()

Expand Down

0 comments on commit 386b41d

Please sign in to comment.