Skip to content
Snippets Groups Projects
Commit a5244e4a authored by las1g21's avatar las1g21
Browse files

Remote Completion

parent c16ac615
No related branches found
No related tags found
1 merge request!9GDP 4.4.5
......@@ -3,6 +3,7 @@ from dotenv import load_dotenv
from scp import SCPClient
import os
import subprocess
import time
load_dotenv()
hostname = os.getenv("HOSTNAME")
......@@ -10,6 +11,8 @@ username = os.getenv("USERNAME")
password = os.getenv("PASSWORD")
def send_files(shifted_disparity_path, shifted_t_path):
# sends two files needed to iridis
# files keep their names. NAMES MUST BE shifted_disparity.png AND shifted_t.png
command = [
"scp",
......@@ -44,25 +47,76 @@ def get_completed_scene(shifted_disparity_path, shifted_t_path):
client.set_missing_host_key_policy(paramiko.AutoAddPolicy())
# Connect to the server
client.connect(hostname, username=username, password=password)
# Execute commands on the server
stdin, stdout, stderr = client.exec_command("cd mona/MDBNet360_GDP/")
stdin, stdout, stderr = client.exec_command("module load conda")
stdin, stdout, stderr = client.exec_command("source activate")
stdin, stdout, stderr = client.exec_command("conda activate sscenv")
stdin, stdout, stderr = client.exec_command("cd mona/MDBNet360_GDP/sbatch --partition=ecsstudents --account=ecsstudents run_obj_job.sh")
try:
client.connect(hostname, username=username, password=password)
print("SSH connection established.")
# Check if the connection is active
if client.get_transport().is_active():
print("Connection is active.")
else:
print("Connection is not active.")
exit(1) # Exit the script if the connection is not active
except Exception as e:
print(f"Failed to connect to {hostname}: {e}")
exit(1)
stdin, stdout, stderr = client.exec_command(
"cd mona/MDBNet360_GDP/" +
" && module load conda" +
" && source activate" +
" && conda activate ssc_env" +
" && sbatch --partition=ecsstudents --account=ecsstudents run_enhance360_job.sh"
)
output = stdout.read().decode()
print(output)
stdin, stdout, stderr = client.exec_command("squeue -lu kproject")
output = stdout.read().decode()
print(output)
time.sleep(30)
while "RUNNING" in output:
print("Sleeping for 30")
time.sleep(30)
stdin, stdout, stderr = client.exec_command("squeue -lu kproject")
output = stdout.read().decode()
print(output)
# Print the output of the command
print(stdout.read())
print("Finish Enhancing")
stdin, stdout, stderr = client.exec_command(
"cd mona/MDBNet360_GDP/ && ls" +
" && module load conda" +
" && source activate" +
" && conda activate ssc_env" +
" && sbatch --partition=ecsstudents --account=ecsstudents run_obj_job.sh"
)
output = stdout.read().decode()
print(output)
stdin, stdout, stderr = client.exec_command("squeue -lu kproject")
output = stdout.read().decode()
print(output)
time.sleep(30)
while "RUNNING" in output:
print("Sleeping for 30")
time.sleep(30)
stdin, stdout, stderr = client.exec_command("squeue -lu kproject")
output = stdout.read().decode()
print(output)
print("CLOSING")
# Close the SSH connection
client.close()
return True
else:
return False
out = send_files("C:\\Project\\AVVR-Pipeline-GDP4\\edgenet-360\\Data\\Listening\\shifted-disparity.png", "C:\\Project\\AVVR-Pipeline-GDP4\\edgenet-360\\Data\\Listening\\shifted_t.png")
out = get_completed_scene("C:\\Project\\AVVR-Pipeline-GDP4\\edgenet-360\\Data\\Courtyard\\shifted-disparity.png", "C:\\Project\\AVVR-Pipeline-GDP4\\edgenet-360\\Data\\Courtyard\\shifted_t.png")
print(out)
\ No newline at end of file
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment