From bd59d215cfae31a945ae65c555dfd8c931319dd4 Mon Sep 17 00:00:00 2001 From: Aarsh2001 Date: Fri, 6 Oct 2023 21:18:08 +0100 Subject: [PATCH] minor modifications to gcp_auth --- .github/auth/vm_auth.py | 28 +++++++++++++++------------- .github/workflows/gcp-test.yaml | 3 ++- 2 files changed, 17 insertions(+), 14 deletions(-) diff --git a/.github/auth/vm_auth.py b/.github/auth/vm_auth.py index 2f03d429..06631aa8 100644 --- a/.github/auth/vm_auth.py +++ b/.github/auth/vm_auth.py @@ -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() @@ -70,7 +72,7 @@ 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) @@ -78,10 +80,11 @@ def start_runner( 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__": @@ -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) diff --git a/.github/workflows/gcp-test.yaml b/.github/workflows/gcp-test.yaml index aa63c576..73c584de 100644 --- a/.github/workflows/gcp-test.yaml +++ b/.github/workflows/gcp-test.yaml @@ -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