@@ -54,6 +54,14 @@ def remote_run(self_module, i):
5454 'alias' , '' ), meta .get (
5555 'uid' , '' )
5656
57+ #Update meta for selected variation and input
58+ r = update_meta_for_selected_variations (self_module , script , i )
59+ if r ['return' ] > 0 :
60+ return r
61+
62+ remote_run_settings = r ['remote_run_settings' ]
63+ env = r ['env' ]
64+
5765 # Execute the experiment script
5866 mlc_script_input = {
5967 'action' : 'run' , 'target' : 'script'
@@ -65,6 +73,12 @@ def remote_run(self_module, i):
6573 if i .get ('remote_pull_mlc_repos' , False ):
6674 run_cmds .append ("mlc pull repo" )
6775
76+ files_to_copy = []
77+ env_keys_to_copy = remote_run_settings .get ('env_keys_to_copy' )
78+ for key in env_keys_to_copy :
79+ if key in env and os .path .exists (env [key ]):
80+ files_to_copy .append (env [key ])
81+
6882 script_run_cmd = " " .join (mlc_run_cmd .split (" " )[1 :])
6983 run_cmds .append (f"mlcr { script_run_cmd } " )
7084
@@ -73,6 +87,10 @@ def remote_run(self_module, i):
7387 "password" , "skip_host_verify" , "ssh_key_file" ]:
7488 if i .get (f"remote_{ key } " ):
7589 remote_inputs [key ] = i [f"remote_{ key } " ]
90+
91+ if files_to_copy :
92+ remote_inputs ['files_to_copy' ] = files_to_copy
93+
7694
7795 # Execute the remote command
7896 mlc_remote_input = {
@@ -86,3 +104,68 @@ def remote_run(self_module, i):
86104 return r
87105
88106 return {'return' : 0 }
107+
108+ def update_meta_for_selected_variations (self_module , script , input_params ):
109+ metadata = script .meta
110+ script_directory = script .path
111+ script_tags = metadata .get ("tags" , [])
112+ script_alias = metadata .get ('alias' , '' )
113+ script_uid = metadata .get ('uid' , '' )
114+ tag_values = input_params .get ('tags' , '' ).split ("," )
115+ variation_tags = [tag [1 :] for tag in tag_values if tag .startswith ("_" )]
116+
117+ run_state = {
118+ 'deps' : [],
119+ 'fake_deps' : [],
120+ 'parent' : None ,
121+ 'script_id' : f"{ script_alias } ,{ script_uid } " ,
122+ 'script_variation_tags' : variation_tags
123+ }
124+ state_data = {}
125+ env = input_params .get ('env' , {})
126+ constant_vars = input_params .get ('const' , {})
127+ constant_state = input_params .get ('const_state' , {})
128+
129+ remote_run_settings = metadata .get ('remote_run' , {})
130+ remote_run_settings_default_env = remote_run_settings .get ('default_env' , {})
131+ for key in remote_run_settings_default_env :
132+ env .setdefault (key , remote_run_settings_default_env [key ])
133+
134+ state_data ['remote_run' ] = remote_run_settings
135+ add_deps_recursive = input_params .get ('add_deps_recursive' , {})
136+
137+ # Update state with metadata and variations
138+ update_state_result = self_module .update_state_from_meta (
139+ metadata , env , state_data , constant_vars , constant_state ,
140+ deps = [],
141+ post_deps = [],
142+ prehook_deps = [],
143+ posthook_deps = [],
144+ new_env_keys = [],
145+ new_state_keys = [],
146+ run_state = run_state ,
147+ i = input_params
148+ )
149+ if update_state_result ['return' ] > 0 :
150+ return update_state_result
151+
152+ update_variations_result = self_module ._update_state_from_variations (
153+ input_params , metadata , variation_tags , metadata .get (
154+ 'variations' , {}),
155+ env , state_data , constant_vars , constant_state ,
156+ deps = [], # Add your dependencies if needed
157+ post_deps = [], # Add post dependencies if needed
158+ prehook_deps = [], # Add prehook dependencies if needed
159+ posthook_deps = [], # Add posthook dependencies if needed
160+ new_env_keys_from_meta = [], # Add keys from meta if needed
161+ new_state_keys_from_meta = [], # Add state keys from meta if needed
162+ add_deps_recursive = add_deps_recursive ,
163+ run_state = run_state ,
164+ recursion_spaces = ''
165+ )
166+ if update_variations_result ['return' ] > 0 :
167+ return update_variations_result
168+
169+ # Set Docker-specific configurations
170+ remote_run_settings = state_data ['remote_run' ]
171+ return {'return' : 0 , 'remote_run_settings' : remote_run_settings , 'env' : env , 'state' : state_data }
0 commit comments