This is an automated email from the ASF dual-hosted git repository.

dimuthuupe pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/airavata.git


The following commit(s) were added to refs/heads/master by this push:
     new 0ea1aa7fce Improving error path handling of agent
0ea1aa7fce is described below

commit 0ea1aa7fce42f17e0947645d6fa9115b72f3e64b
Author: Dimuthu Wannipurage <[email protected]>
AuthorDate: Fri Sep 13 11:50:24 2024 -0400

    Improving error path handling of agent
---
 modules/agent-framework/.gitignore                 |  7 ++
 modules/agent-framework/airavata-agent/agent.go    | 98 +++++++++++++++++++++-
 .../airavata-agent/jupyter/Dockerfile              |  2 +-
 3 files changed, 104 insertions(+), 3 deletions(-)

diff --git a/modules/agent-framework/.gitignore 
b/modules/agent-framework/.gitignore
new file mode 100644
index 0000000000..89b80eb649
--- /dev/null
+++ b/modules/agent-framework/.gitignore
@@ -0,0 +1,7 @@
+airavata-fuse/bin
+airavata-fuse/data
+connection-service/target
+airavata-agent/jupyter/.ipynb_checkpoints
+airavata-agent/jupyter/venv
+airavata-agent/airavata-agent-linux
+airavata-agent/jupyter/extension/airavata_jupyter_magic/build
\ No newline at end of file
diff --git a/modules/agent-framework/airavata-agent/agent.go 
b/modules/agent-framework/airavata-agent/agent.go
index 75088578b8..172fd2d49d 100644
--- a/modules/agent-framework/airavata-agent/agent.go
+++ b/modules/agent-framework/airavata-agent/agent.go
@@ -144,16 +144,59 @@ func main() {
                                        req, err := http.NewRequest("GET", url, 
nil)
                                        if err != nil {
                                                log.Printf("Failed to create 
the request start jupyter kernel: %v", err)
+
+                                               jupyterResponse := "Failed 
while running the cell in remote. Please retry"
+                                               if err := 
stream.Send(&protos.AgentMessage{Message: 
+                                                       
&protos.AgentMessage_JupyterExecutionResponse{
+                                                               
JupyterExecutionResponse: &protos.JupyterExecutionResponse{ExecutionId: 
executionId, ResponseString: jupyterResponse, SessionId: sessionId}}}); err != 
nil {
+                                                       log.Printf("Failed to 
send jupyter execution result to server: %v", err)
+                                               }
+                                               return
+
                                        }
                                        resp, err := client.Do(req)
                                        if err != nil {
                                                log.Printf("Failed to send the 
request start jupyter kernel: %v", err)
+
+                                               jupyterResponse := "Failed 
while running the cell in remote. Please retry"
+                                               if err := 
stream.Send(&protos.AgentMessage{Message: 
+                                                       
&protos.AgentMessage_JupyterExecutionResponse{
+                                                               
JupyterExecutionResponse: &protos.JupyterExecutionResponse{ExecutionId: 
executionId, ResponseString: jupyterResponse, SessionId: sessionId}}}); err != 
nil {
+                                                       log.Printf("Failed to 
send jupyter execution result to server: %v", err)
+                                               }
+                                               return
+
                                        }
-                                       defer resp.Body.Close()
+
+
+                                       defer func() {
+                                               err := resp.Body.Close()
+                                               if err != nil {
+                                                       log.Printf("Failed to 
close the response body for kernel start: %v", err)
+
+                                                       jupyterResponse := 
"Failed while running the cell in remote. Please retry"
+                                                       if err := 
stream.Send(&protos.AgentMessage{Message: 
+                                                               
&protos.AgentMessage_JupyterExecutionResponse{
+                                                                       
JupyterExecutionResponse: &protos.JupyterExecutionResponse{ExecutionId: 
executionId, ResponseString: jupyterResponse, SessionId: sessionId}}}); err != 
nil {
+                                                               
log.Printf("Failed to send jupyter execution result to server: %v", err)
+                                                       }
+                                                       return
+
+                                               }
+                                       } ()
 
                                        body, err := ioutil.ReadAll(resp.Body)
                                        if err != nil {
                                                log.Printf("Failed to read 
response for start jupyter kernel: %v", err)
+
+                                               jupyterResponse := "Failed 
while running the cell in remote. Please retry"
+                                               if err := 
stream.Send(&protos.AgentMessage{Message: 
+                                                       
&protos.AgentMessage_JupyterExecutionResponse{
+                                                               
JupyterExecutionResponse: &protos.JupyterExecutionResponse{ExecutionId: 
executionId, ResponseString: jupyterResponse, SessionId: sessionId}}}); err != 
nil {
+                                                       log.Printf("Failed to 
send jupyter execution result to server: %v", err)
+                                               }
+                                               return
+
                                        }
 
                                        url = "http://127.0.0.1:15000/execute";
@@ -164,11 +207,29 @@ func main() {
 
                                        if err != nil {
                                                log.Fatalf("Failed to marshal 
JSON: %v", err)
+
+                                               jupyterResponse := "Failed 
while running the cell in remote. Please retry"
+                                               if err := 
stream.Send(&protos.AgentMessage{Message: 
+                                                       
&protos.AgentMessage_JupyterExecutionResponse{
+                                                               
JupyterExecutionResponse: &protos.JupyterExecutionResponse{ExecutionId: 
executionId, ResponseString: jupyterResponse, SessionId: sessionId}}}); err != 
nil {
+                                                       log.Printf("Failed to 
send jupyter execution result to server: %v", err)
+                                               }
+                                               return
+
                                        }
 
                                        req, err = http.NewRequest("POST", url, 
bytes.NewBuffer(jsonData))
                                        if err != nil {
                                                log.Printf("Failed to create 
the request run jupyter kernel: %v", err)
+
+                                               jupyterResponse := "Failed 
while running the cell in remote. Please retry"
+                                               if err := 
stream.Send(&protos.AgentMessage{Message: 
+                                                       
&protos.AgentMessage_JupyterExecutionResponse{
+                                                               
JupyterExecutionResponse: &protos.JupyterExecutionResponse{ExecutionId: 
executionId, ResponseString: jupyterResponse, SessionId: sessionId}}}); err != 
nil {
+                                                       log.Printf("Failed to 
send jupyter execution result to server: %v", err)
+                                               }
+                                               return
+
                                        }
                                        req.Header.Set("Content-Type", 
"application/json")
 
@@ -177,12 +238,45 @@ func main() {
                                        resp, err = client.Do(req)
                                        if err != nil {
                                                log.Printf("Failed to send the 
request run jupyter kernel: %v", err)
+
+                                               jupyterResponse := "Failed 
while running the cell in remote. Please retry"
+                                               if err := 
stream.Send(&protos.AgentMessage{Message: 
+                                                       
&protos.AgentMessage_JupyterExecutionResponse{
+                                                               
JupyterExecutionResponse: &protos.JupyterExecutionResponse{ExecutionId: 
executionId, ResponseString: jupyterResponse, SessionId: sessionId}}}); err != 
nil {
+                                                       log.Printf("Failed to 
send jupyter execution result to server: %v", err)
+                                               }
+                                               return
+
                                        }
-                                       defer resp.Body.Close()
+
+                                       defer func() {
+                                               err := resp.Body.Close()
+                                               if err != nil {
+                                                       log.Printf("Failed to 
close the response body for kernel execution: %v", err)
+
+                                                       jupyterResponse := 
"Failed while running the cell in remote. Please retry"
+                                                       if err := 
stream.Send(&protos.AgentMessage{Message: 
+                                                               
&protos.AgentMessage_JupyterExecutionResponse{
+                                                                       
JupyterExecutionResponse: &protos.JupyterExecutionResponse{ExecutionId: 
executionId, ResponseString: jupyterResponse, SessionId: sessionId}}}); err != 
nil {
+                                                               
log.Printf("Failed to send jupyter execution result to server: %v", err)
+                                                       }
+                                                       return
+
+                                               }
+                                       } ()
 
                                        body, err = ioutil.ReadAll(resp.Body)
                                        if err != nil {
                                                log.Printf("Failed to read 
response for run jupyter kernel: %v", err)
+
+                                               jupyterResponse := "Failed 
while running the cell in remote. Please retry"
+                                               if err := 
stream.Send(&protos.AgentMessage{Message: 
+                                                       
&protos.AgentMessage_JupyterExecutionResponse{
+                                                               
JupyterExecutionResponse: &protos.JupyterExecutionResponse{ExecutionId: 
executionId, ResponseString: jupyterResponse, SessionId: sessionId}}}); err != 
nil {
+                                                       log.Printf("Failed to 
send jupyter execution result to server: %v", err)
+                                               }
+                                               return
+                                               
                                        }
 
                                        
diff --git a/modules/agent-framework/airavata-agent/jupyter/Dockerfile 
b/modules/agent-framework/airavata-agent/jupyter/Dockerfile
index cd2f044471..a2bb2cf054 100644
--- a/modules/agent-framework/airavata-agent/jupyter/Dockerfile
+++ b/modules/agent-framework/airavata-agent/jupyter/Dockerfile
@@ -6,7 +6,7 @@ RUN pip install notebook
 RUN apt install kmod -y
 RUN apt install git -y
 RUN pip install PyJWT
-RUN pip install --upgrade cybershuttle-tune
+RUN pip install cybershuttle-tune==0.1.19
 RUN pip install scipy
 RUN pip install numpy
 RUN pip install matplotlib

Reply via email to