Skip to content

Commit

Permalink
Create local cluster with tmux sessions
Browse files Browse the repository at this point in the history
  • Loading branch information
kartik4949 committed Apr 15, 2024
1 parent 7ed99f8 commit bb94295
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 30 deletions.
2 changes: 1 addition & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
- Add model dict output indexing in graph
- Make lance upsert for added vectors
- Make vectors normalized in inmemory vector database for cosine measure.
- Add local cluster as tmux sessions
- Add local cluster as tmux session

#### New Features & Functionality
- Add nightly image for pre-release testing in the cloud environment
Expand Down
54 changes: 25 additions & 29 deletions superduperdb/server/cluster.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,47 +2,43 @@
import time


def subprocess_run(cmds):
print(' '.join(cmds))
subprocess.run(cmds)


def create_tmux_session(session_name, commands):
'''
Create a tmux local cluster
'''

window_name = f'{session_name}:0'
for ix, cmd in enumerate(commands, start=1):
if ix == 1:
subprocess_run(
[
'tmux',
'new-session',
'-d',
'-s',
session_name,
'-n',
'shell0',
'-d',
cmd,
]
)
else:
subprocess_run(['tmux', 'split-window', '-t', window_name, cmd])

if ix % 4 == 0:
subprocess_run(['tmux', 'select-layout', '-t', window_name, 'tiled'])

time.sleep(2)
subprocess_run(['tmux', 'attach-session', '-t', session_name])
for ix, cmd in enumerate(commands, start=0):
window_name = f'{session_name}:0.{ix}'
run_tmux_command(['send-keys', '-t', window_name, cmd, 'C-m'])
time.sleep(1)

run_tmux_command(['attach-session', '-t', session_name])


def run_tmux_command(command):
print('tmux ' + ' '.join(command))
subprocess.run(["tmux"] + command, check=True)


def local_cluster():
print('Starting the local cluster...')
session_name = 'superduperdb-localcluster-session'

CFG = 'deploy/testenv/env/smoke/debug.yaml'
run_tmux_command(
[
'new-session',
'-d',
'-s',
session_name,
]
)

run_tmux_command(["split-window", "-h"])
run_tmux_command(["split-window", "-v"])
run_tmux_command(["select-pane", "-t", "0"])
run_tmux_command(["split-window", "-v"])

services = [
f"SUPERDUPERDB_CONFIG={CFG} PYTHONPATH=$(pwd):. "
"ray start --head --dashboard-host=0.0.0.0 --disable-usage-stats --block",
Expand Down

0 comments on commit bb94295

Please sign in to comment.