gitarsenal-cli 1.9.75 → 1.9.76
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.venv_status.json +1 -1
- package/Step +0 -0
- package/package.json +1 -1
- package/python/__pycache__/credentials_manager.cpython-312.pyc +0 -0
- package/python/test_container_fail.py +239 -0
- package/python/test_container_pass.py +290 -0
- package/python/test_modalSandboxScript.py +408 -363
- package/python/test_container.py +0 -145
package/python/test_container.py
DELETED
|
@@ -1,145 +0,0 @@
|
|
|
1
|
-
import subprocess
|
|
2
|
-
import time
|
|
3
|
-
import secrets
|
|
4
|
-
import string
|
|
5
|
-
import modal
|
|
6
|
-
import sys
|
|
7
|
-
|
|
8
|
-
def generate_random_password(length=16):
|
|
9
|
-
"""Generate a random password for SSH access"""
|
|
10
|
-
print(f"[DEBUG] Generating random password of length {length}")
|
|
11
|
-
alphabet = string.ascii_letters + string.digits + "!@#$%^&*"
|
|
12
|
-
password = ''.join(secrets.choice(alphabet) for i in range(length))
|
|
13
|
-
print(f"[DEBUG] Password generated successfully (length: {len(password)})")
|
|
14
|
-
return password
|
|
15
|
-
|
|
16
|
-
print("[DEBUG] Starting container setup...")
|
|
17
|
-
|
|
18
|
-
image = (
|
|
19
|
-
modal.Image.from_registry("nvidia/cuda:12.2.0-devel-ubuntu22.04", add_python="3.11")
|
|
20
|
-
.apt_install("openssh-server", "sudo", "curl", "wget", "git", "vim", "htop", "tmux", "nvtop")
|
|
21
|
-
.pip_install("cupy-cuda12x", "torch", "transformers")
|
|
22
|
-
.run_commands(
|
|
23
|
-
"mkdir -p /var/run/sshd",
|
|
24
|
-
"ssh-keygen -A",
|
|
25
|
-
"sed -i 's/#PermitRootLogin prohibit-password/PermitRootLogin yes/' /etc/ssh/sshd_config",
|
|
26
|
-
"sed -i 's/#PasswordAuthentication yes/PasswordAuthentication yes/' /etc/ssh/sshd_config",
|
|
27
|
-
"echo 'export PATH=/usr/local/cuda/bin:$PATH' >> /root/.bashrc"
|
|
28
|
-
)
|
|
29
|
-
)
|
|
30
|
-
|
|
31
|
-
print("[DEBUG] Image configuration completed")
|
|
32
|
-
|
|
33
|
-
app = modal.App("cuda-ssh-container", image=image)
|
|
34
|
-
print("[DEBUG] Modal app created")
|
|
35
|
-
|
|
36
|
-
@app.function(gpu="A10G", timeout=3600)
|
|
37
|
-
def start_ssh():
|
|
38
|
-
print("[DEBUG] Starting SSH function...")
|
|
39
|
-
|
|
40
|
-
# Generate SSH password
|
|
41
|
-
print("[DEBUG] Step 1: Generating SSH password")
|
|
42
|
-
try:
|
|
43
|
-
password = generate_random_password()
|
|
44
|
-
print(f"[DEBUG] Password generation successful")
|
|
45
|
-
except Exception as e:
|
|
46
|
-
print(f"[ERROR] Failed to generate password: {e}")
|
|
47
|
-
return
|
|
48
|
-
|
|
49
|
-
# Set root password
|
|
50
|
-
print("[DEBUG] Step 2: Setting root password")
|
|
51
|
-
try:
|
|
52
|
-
result = subprocess.run(["bash", "-c", f"echo 'root:{password}' | chpasswd"],
|
|
53
|
-
check=True, capture_output=True, text=True)
|
|
54
|
-
print(f"[DEBUG] Password set successfully. Return code: {result.returncode}")
|
|
55
|
-
except subprocess.CalledProcessError as e:
|
|
56
|
-
print(f"[ERROR] Failed to set password: {e}")
|
|
57
|
-
print(f"[ERROR] stdout: {e.stdout}")
|
|
58
|
-
print(f"[ERROR] stderr: {e.stderr}")
|
|
59
|
-
return
|
|
60
|
-
except Exception as e:
|
|
61
|
-
print(f"[ERROR] Unexpected error setting password: {e}")
|
|
62
|
-
return
|
|
63
|
-
|
|
64
|
-
# Start SSH server
|
|
65
|
-
print("[DEBUG] Step 3: Starting SSH server")
|
|
66
|
-
try:
|
|
67
|
-
ssh_process = subprocess.Popen(["/usr/sbin/sshd", "-D"])
|
|
68
|
-
print(f"[DEBUG] SSH server started with PID: {ssh_process.pid}")
|
|
69
|
-
time.sleep(2)
|
|
70
|
-
print("[DEBUG] Waited 2 seconds for SSH server to initialize")
|
|
71
|
-
except Exception as e:
|
|
72
|
-
print(f"[ERROR] Failed to start SSH server: {e}")
|
|
73
|
-
return
|
|
74
|
-
|
|
75
|
-
# Test CUDA
|
|
76
|
-
print("[DEBUG] Step 4: Testing CUDA availability")
|
|
77
|
-
try:
|
|
78
|
-
print("[DEBUG] Running nvidia-smi...")
|
|
79
|
-
nvidia_result = subprocess.run(["nvidia-smi"], capture_output=True, text=True, timeout=30)
|
|
80
|
-
print(f"[DEBUG] nvidia-smi return code: {nvidia_result.returncode}")
|
|
81
|
-
if nvidia_result.stdout:
|
|
82
|
-
print(f"[DEBUG] nvidia-smi output:\n{nvidia_result.stdout}")
|
|
83
|
-
if nvidia_result.stderr:
|
|
84
|
-
print(f"[DEBUG] nvidia-smi stderr:\n{nvidia_result.stderr}")
|
|
85
|
-
except subprocess.TimeoutExpired:
|
|
86
|
-
print("[ERROR] nvidia-smi timed out")
|
|
87
|
-
except Exception as e:
|
|
88
|
-
print(f"[ERROR] nvidia-smi failed: {e}")
|
|
89
|
-
|
|
90
|
-
try:
|
|
91
|
-
print("[DEBUG] Running nvcc --version...")
|
|
92
|
-
nvcc_result = subprocess.run(["nvcc", "--version"], capture_output=True, text=True, timeout=30)
|
|
93
|
-
print(f"[DEBUG] nvcc return code: {nvcc_result.returncode}")
|
|
94
|
-
if nvcc_result.stdout:
|
|
95
|
-
print(f"[DEBUG] nvcc output:\n{nvcc_result.stdout}")
|
|
96
|
-
if nvcc_result.stderr:
|
|
97
|
-
print(f"[DEBUG] nvcc stderr:\n{nvcc_result.stderr}")
|
|
98
|
-
except subprocess.TimeoutExpired:
|
|
99
|
-
print("[ERROR] nvcc timed out")
|
|
100
|
-
except Exception as e:
|
|
101
|
-
print(f"[ERROR] nvcc failed: {e}")
|
|
102
|
-
|
|
103
|
-
# Forward SSH port
|
|
104
|
-
print("[DEBUG] Step 5: Setting up SSH port forwarding")
|
|
105
|
-
try:
|
|
106
|
-
with modal.forward(port=22, unencrypted=True) as tunnel:
|
|
107
|
-
hostname, port = tunnel.tcp_socket
|
|
108
|
-
print(f"[DEBUG] Tunnel established successfully")
|
|
109
|
-
print(f"[DEBUG] Hostname: {hostname}, Port: {port}")
|
|
110
|
-
print(f"\n" + "="*50)
|
|
111
|
-
print(f"SSH CONNECTION INFO:")
|
|
112
|
-
print(f"SSH: ssh -p {port} root@{hostname}")
|
|
113
|
-
print(f"Password: {password}")
|
|
114
|
-
print(f"="*50 + "\n")
|
|
115
|
-
|
|
116
|
-
# Keep alive with periodic status updates
|
|
117
|
-
print("[DEBUG] Starting keep-alive loop...")
|
|
118
|
-
counter = 0
|
|
119
|
-
while True:
|
|
120
|
-
counter += 1
|
|
121
|
-
print(f"[DEBUG] Keep-alive cycle {counter} - Container still running")
|
|
122
|
-
time.sleep(60)
|
|
123
|
-
|
|
124
|
-
except Exception as e:
|
|
125
|
-
print(f"[ERROR] Failed to set up port forwarding: {e}")
|
|
126
|
-
import traceback
|
|
127
|
-
traceback.print_exc()
|
|
128
|
-
return
|
|
129
|
-
|
|
130
|
-
if __name__ == "__main__":
|
|
131
|
-
print("[DEBUG] Script starting from main...")
|
|
132
|
-
print(f"[DEBUG] Python version: {sys.version}")
|
|
133
|
-
print(f"[DEBUG] Modal version: {modal.__version__}")
|
|
134
|
-
|
|
135
|
-
try:
|
|
136
|
-
print("[DEBUG] Starting modal app...")
|
|
137
|
-
with app.run():
|
|
138
|
-
print("[DEBUG] Modal app context established")
|
|
139
|
-
start_ssh.remote()
|
|
140
|
-
except Exception as e:
|
|
141
|
-
print(f"[ERROR] Failed to run modal app: {e}")
|
|
142
|
-
import traceback
|
|
143
|
-
traceback.print_exc()
|
|
144
|
-
|
|
145
|
-
print("[DEBUG] Script completed")
|