11//! Demonstration: RLM running locally (LocalExecutor) and via Docker (DockerExecutor).
22//! Run: cargo test -p terraphim_rlm --test backend_demo -- --nocapture
33
4- use terraphim_rlm:: config:: { BackendType , RlmConfig } ;
54use terraphim_rlm:: TerraphimRlm ;
5+ use terraphim_rlm:: config:: { BackendType , RlmConfig } ;
66
77#[ tokio:: test]
88async fn demo_local_executor ( ) {
@@ -19,11 +19,22 @@ async fn demo_local_executor() {
1919
2020 // Python
2121 let r = rlm. execute_code ( & session. id , "print(2+2)" ) . await . unwrap ( ) ;
22- println ! ( " [Python] 2+2 = {} (exit {})" , r. stdout. trim( ) , r. exit_code) ;
22+ println ! (
23+ " [Python] 2+2 = {} (exit {})" ,
24+ r. stdout. trim( ) ,
25+ r. exit_code
26+ ) ;
2327
2428 // Bash
25- let r = rlm. execute_command ( & session. id , "echo hello-from-local" ) . await . unwrap ( ) ;
26- println ! ( " [Bash] echo = {} (exit {})" , r. stdout. trim( ) , r. exit_code) ;
29+ let r = rlm
30+ . execute_command ( & session. id , "echo hello-from-local" )
31+ . await
32+ . unwrap ( ) ;
33+ println ! (
34+ " [Bash] echo = {} (exit {})" ,
35+ r. stdout. trim( ) ,
36+ r. exit_code
37+ ) ;
2738
2839 // Show backend type
2940 let status = rlm. get_session_status ( & session. id , false ) . await . unwrap ( ) ;
@@ -55,11 +66,22 @@ async fn demo_docker_executor() {
5566
5667 // Python
5768 let r = rlm. execute_code ( & session. id , "print(2+2)" ) . await . unwrap ( ) ;
58- println ! ( " [Python] 2+2 = {} (exit {})" , r. stdout. trim( ) , r. exit_code) ;
69+ println ! (
70+ " [Python] 2+2 = {} (exit {})" ,
71+ r. stdout. trim( ) ,
72+ r. exit_code
73+ ) ;
5974
6075 // Bash
61- let r = rlm. execute_command ( & session. id , "echo hello-from-docker" ) . await . unwrap ( ) ;
62- println ! ( " [Bash] echo = {} (exit {})" , r. stdout. trim( ) , r. exit_code) ;
76+ let r = rlm
77+ . execute_command ( & session. id , "echo hello-from-docker" )
78+ . await
79+ . unwrap ( ) ;
80+ println ! (
81+ " [Bash] echo = {} (exit {})" ,
82+ r. stdout. trim( ) ,
83+ r. exit_code
84+ ) ;
6385
6486 // Show backend type
6587 let status = rlm. get_session_status ( & session. id , false ) . await . unwrap ( ) ;
@@ -73,11 +95,17 @@ async fn demo_docker_executor() {
7395 println ! ( " [Container hostname] {}" , r. stdout. trim( ) ) ;
7496
7597 // Show Python version inside container
76- let r = rlm. execute_code ( & session. id , "import sys; print(sys.version)" ) . await . unwrap ( ) ;
98+ let r = rlm
99+ . execute_code ( & session. id , "import sys; print(sys.version)" )
100+ . await
101+ . unwrap ( ) ;
77102 println ! ( " [Python version] {}" , r. stdout. trim( ) ) ;
78103
79104 // Show container filesystem
80- let r = rlm. execute_command ( & session. id , "ls / | head -5" ) . await . unwrap ( ) ;
105+ let r = rlm
106+ . execute_command ( & session. id , "ls / | head -5" )
107+ . await
108+ . unwrap ( ) ;
81109 println ! ( " [Container root]\n {}" , r. stdout) ;
82110
83111 rlm. destroy_session ( & session. id ) . await . unwrap ( ) ;
0 commit comments