11use std:: collections:: HashMap ;
22
33use hyperlight_javascript_sandbox:: HyperlightJs ;
4- use hyperlight_sandbox:: { DirPerms , FilePerms , HttpMethod , Sandbox , SandboxConfig } ;
4+ use hyperlight_sandbox:: { DEFAULT_HEAP_SIZE , DEFAULT_STACK_SIZE , DirPerms , FilePerms , HttpMethod , Sandbox , SandboxConfig } ;
55use hyperlight_sandbox_pyo3_common:: {
66 PyExecutionResult , PySnapshot , build_tool_registry, parse_size, parse_tool_registration,
77} ;
@@ -22,14 +22,14 @@ pub struct JSSandbox {
2222#[ pymethods]
2323impl JSSandbox {
2424 #[ new]
25- #[ pyo3( signature = ( input_dir=None , output_dir=None , temp_output=false , module_path="" , heap_size="200Mi" , stack_size="100Mi" ) ) ]
25+ #[ pyo3( signature = ( input_dir=None , output_dir=None , temp_output=false , module_path="" , heap_size=None , stack_size=None ) ) ]
2626 fn new (
2727 input_dir : Option < & str > ,
2828 output_dir : Option < & str > ,
2929 temp_output : bool ,
3030 module_path : & str ,
31- heap_size : & str ,
32- stack_size : & str ,
31+ heap_size : Option < & str > ,
32+ stack_size : Option < & str > ,
3333 ) -> PyResult < Self > {
3434 if !module_path. is_empty ( ) {
3535 return Err ( PyRuntimeError :: new_err (
@@ -43,8 +43,14 @@ impl JSSandbox {
4343 pending_networks : Vec :: new ( ) ,
4444 config : SandboxConfig {
4545 module_path : String :: new ( ) ,
46- heap_size : parse_size ( heap_size) ?,
47- stack_size : parse_size ( stack_size) ?,
46+ heap_size : match heap_size {
47+ Some ( s) => parse_size ( s) ?,
48+ None => DEFAULT_HEAP_SIZE ,
49+ } ,
50+ stack_size : match stack_size {
51+ Some ( s) => parse_size ( s) ?,
52+ None => DEFAULT_STACK_SIZE ,
53+ } ,
4854 } ,
4955 input_dir : input_dir. map ( |s| s. to_string ( ) ) ,
5056 output_dir : output_dir. map ( |s| s. to_string ( ) ) ,
0 commit comments