'Is there a WebSocket command to execute the code blocks in a SageMaker notebook instance once there is a successful connection?

I have written a Lambda Function to start a SageMaker notebook instance, create a WebSocket connection, then execute the ipynb file inside the notebook instance, and then stop the notebook instance and close the WebSocket Connection.

So far I have successfully:

  • started the notebook instance
  • created a WebSocket connection
  • stopped the notebook instance
  • closed the WebSocket connection

I have not been find able to find a line of code or command that actually executes the ipynb file, as if it had been executed manually.

This is the line of code that I thought would execute the ipynb file, where 'test.ipynb' is the name of my file inside the notebook instance:

-> ws.send("""[ "stdin", "jupyter nbconvert --execute --to notebook --inplace /home/ec2-user/SageMaker/test.ipynb --ExecutePreprocessor.kernel_name=python3 --ExecutePreprocessor.timeout=1500\r" ]""")

Does anyone know or has used a command which is able to execute the ipynb file code blocks from a Lambda Function using a WebSocket connection?

Thanks, Yaviin



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source