1- use crate :: app:: ContainerRunSpec ;
1+ use camino:: { Utf8Path , Utf8PathBuf } ;
2+
3+ use crate :: {
4+ app:: { ContainerRunSpec , NativeRunSpec } ,
5+ util:: include_asset,
6+ } ;
27
38pub fn container_spec ( app_args : Vec < String > ) -> ContainerRunSpec {
49 ContainerRunSpec :: with_prefixed_args (
@@ -8,3 +13,47 @@ pub fn container_spec(app_args: Vec<String>) -> ContainerRunSpec {
813 )
914 . working_dir ( "/w" )
1015}
16+
17+ fn map_input_and_output_options ( mut app_args : Vec < String > , working_dir : & Utf8Path ) -> Vec < String > {
18+ const OPTIONS : [ & str ; 2 ] = [ "--pdb_path" , "--out_folder" ] ;
19+ const OUTPUT_OPTION : & str = OPTIONS [ 1 ] ;
20+
21+ let mut output_option_present = false ;
22+
23+ fn make_absolute ( working_dir : & Utf8Path , path_str : & str ) -> Utf8PathBuf {
24+ let path = Utf8PathBuf :: from ( path_str) ;
25+ if path. is_absolute ( ) {
26+ path
27+ } else {
28+ working_dir. join ( path)
29+ }
30+ }
31+
32+ for i in 1 ..app_args. len ( ) {
33+ for option in OPTIONS {
34+ if app_args[ i - 1 ] == option {
35+ app_args[ i] = make_absolute ( working_dir, & app_args[ i] ) . into ( ) ;
36+ if option == OUTPUT_OPTION {
37+ output_option_present = true ;
38+ }
39+ break ;
40+ }
41+ }
42+ }
43+
44+ if !output_option_present {
45+ app_args. extend ( [ OUTPUT_OPTION . into ( ) , working_dir. to_string ( ) ] ) ;
46+ }
47+ app_args
48+ }
49+
50+ pub fn native_spec ( app_args : Vec < String > , working_dir : & Utf8Path ) -> super :: NativeRunSpec {
51+ let app_args = map_input_and_output_options ( app_args, working_dir) ;
52+
53+ let app_args = app_args
54+ . into_iter ( )
55+ . map ( |arg| shell_escape:: escape ( arg. into ( ) ) . into ( ) )
56+ . collect :: < Vec < _ > > ( ) ;
57+
58+ NativeRunSpec :: new ( include_asset ! ( "pixi/proteinmpnn.toml" ) , app_args)
59+ }
0 commit comments