Skip to content

Commit

Permalink
minor modifications to gcp_auth
Browse files Browse the repository at this point in the history
  • Loading branch information
Aarsh2001 committed Oct 6, 2023
1 parent 5372b9d commit bd59d21
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 14 deletions.
28 changes: 15 additions & 13 deletions .github/auth/vm_auth.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,14 +17,16 @@ def _start_ssh_session(response, creds, username, passphrase):
ssh = paramiko.SSHClient()
ssh.set_missing_host_key_policy(paramiko.AutoAddPolicy())

ssh.connect(
external_ip,
username=username,
key_filename=creds,
passphrase=passphrase,
)

print("Successfully started an SSH session into the VM !")
try:
ssh.connect(
external_ip,
username=username,
key_filename=creds,
passphrase=passphrase,
)
print("SSH session successful !")
except Exception as e:
print(e)

# Open an SSH session
transport = ssh.get_transport()
Expand Down Expand Up @@ -70,18 +72,19 @@ def start_runner(
if waited_time >= max_wait_time:
raise Exception(f"Instance {instance} did not start within the expected time.")

print("Successfully started the VM !")
print("Startup Successful (VM ON)")

# Once the instance is running, start the SSH session
_start_ssh_session(response, ssh_creds, ssh_user, key_passphrase)


def stop_runner(creds):
compute = authenticate_vm(creds)
request = compute.instances().stop(
compute.instances().stop(
project="gpu-insatnce", zone="us-central1-a", instance="demos-tests"
)
request.execute()
).execute()

print("Cleanup Successful (VM OFF)")


if __name__ == "__main__":
Expand All @@ -95,5 +98,4 @@ def stop_runner(creds):
else:
# Start the instance
ssh_key_path = os.path.expanduser(ssh_credentials)
print(ssh_key_path)
start_runner(gcp_credentials, ssh_key_path, ssh_user, key_passphrase)
3 changes: 2 additions & 1 deletion .github/workflows/gcp-test.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -49,11 +49,12 @@ jobs:
- name: Run Demo Testing
run: |
cd demos
docker run -v `pwd`:/ivy/demos unifyai/multicuda:base_and_requirements tests/test_demos.sh ${{ secrets.USER_API_KEY }} alexnet_demo.ipynb "examples"
docker run -v `pwd`:/ivy/demos unifyai/multicuda:base_and_requirements demos/tests/test_demos.sh ${{ secrets.USER_API_KEY }} alexnet_demo.ipynb "examples"
deactivate-vm:
needs: run-test
runs-on: ubuntu-latest
if: always() # Run this job always, regardless of the status of run-test
steps:
- name: Checkout Demos🛎
uses: actions/checkout@v2
Expand Down

0 comments on commit bd59d21

Please sign in to comment.