This is an automated email from the ASF dual-hosted git repository. dimuthuupe pushed a commit to branch Agent-HTML-Support in repository https://gitbox.apache.org/repos/asf/airavata.git
commit 6acef072af56b25a0e6e2a05bf3122a72503b4f6 Author: DImuthuUpe <[email protected]> AuthorDate: Wed Apr 9 07:08:07 2025 -0400 Support for HTML and JS support for magic output --- .../airavata_jupyter_magic/__init__.py | 10 ++++++++-- .../agent-service/src/main/resources/application.yml | 1 + modules/agent-framework/airavata-agent/agent.go | 15 ++++++++++++++- 3 files changed, 23 insertions(+), 3 deletions(-) diff --git a/airavata-api/airavata-client-sdks/airavata-python-sdk/airavata_jupyter_magic/__init__.py b/airavata-api/airavata-client-sdks/airavata-python-sdk/airavata_jupyter_magic/__init__.py index 8a40ca4e8d..5d4de58ae8 100644 --- a/airavata-api/airavata-client-sdks/airavata-python-sdk/airavata_jupyter_magic/__init__.py +++ b/airavata-api/airavata-client-sdks/airavata-python-sdk/airavata_jupyter_magic/__init__.py @@ -16,7 +16,7 @@ import yaml from IPython.core.getipython import get_ipython from IPython.core.interactiveshell import ExecutionResult from IPython.core.magic import register_cell_magic, register_line_magic -from IPython.display import HTML, Image, display +from IPython.display import HTML, Image, display, Javascript, HTML from rich.console import Console from .device_auth import DeviceFlowAuthenticator @@ -538,6 +538,12 @@ def run_on_runtime(rt_name: str, code_obj: str, result: ExecutionResult) -> bool result.error_in_exec = Exception( f"Failed to decode image data: {e}") return False + elif 'text/html' in data_obj: + html_data = data_obj['text/html'] + display(HTML(html_data)) + elif 'application/javascript' in data_obj: + js_data = data_obj['application/javascript'] + display(Javascript(js_data)) elif output_type == 'stream': stream_name = output.get('name', 'stdout') @@ -558,7 +564,7 @@ def run_on_runtime(rt_name: str, code_obj: str, result: ExecutionResult) -> bool """ display(HTML(error_html)) result.error_in_exec = Exception(stream_text) - return False + #return False This prevents rest of the message not getting rendered else: print(stream_text) diff --git a/modules/agent-framework/agent-service/src/main/resources/application.yml b/modules/agent-framework/agent-service/src/main/resources/application.yml index cca313f82f..3ffce48f7a 100644 --- a/modules/agent-framework/agent-service/src/main/resources/application.yml +++ b/modules/agent-framework/agent-service/src/main/resources/application.yml @@ -1,6 +1,7 @@ grpc: server: port: 19900 + max-inbound-message-size: 20971520 server: port: 18880 diff --git a/modules/agent-framework/airavata-agent/agent.go b/modules/agent-framework/airavata-agent/agent.go index bd6461b801..973ed9f510 100644 --- a/modules/agent-framework/airavata-agent/agent.go +++ b/modules/agent-framework/airavata-agent/agent.go @@ -51,7 +51,18 @@ func main() { log.Fatalf("[agent.go] main() Error: --agent flag is required.\n") } - conn, err := grpc.NewClient(*serverUrl, grpc.WithTransportCredentials(insecure.NewCredentials())) + ctx := context.Background() + conn, err := grpc.DialContext( + ctx, + *serverUrl, + grpc.WithTransportCredentials(insecure.NewCredentials()), + grpc.WithDefaultCallOptions( + grpc.MaxCallRecvMsgSize(20*1024*1024), // 10MB for incoming messages + grpc.MaxCallSendMsgSize(20*1024*1024), // 10MB for outgoing messages (if needed) + ), + ) // Enable large message support + + //conn, err := grpc.NewClient(*serverUrl, grpc.WithTransportCredentials(insecure.NewCredentials())) if err != nil { log.Fatalf("[agent.go] main() Did not connect to %s: %v\n", *serverUrl, err) } @@ -426,6 +437,8 @@ func executeJupyter(stream Stream, executionId string, envName string, code stri } jupyterResponse := string(bodyBytes) log.Printf("[agent.go] executeJupyter() id: %s response: %s\n", executionId, jupyterResponse) + fmt.Printf("Response size: %d bytes\n", len(jupyterResponse)) + sendResponse(jupyterResponse, nil) }
