@@ -155,6 +155,25 @@ def _save_yaml(yaml_content, **kwargs):
155155 print (f"Job run info saved to { yaml_path } " )
156156
157157
158+ def apply (config : Dict , ** kwargs ) -> Dict :
159+ """Creates a Job, DataFlow, Pipeline or Model Deployment from YAML.
160+
161+ Parameters
162+ ----------
163+ config: dict
164+ dictionary of configurations
165+ kwargs: dict
166+ keyword arguments, stores configuration from command line args
167+
168+ Returns
169+ -------
170+ Dict
171+ dictionary of service id and service run id if not running locally, else empty.
172+ """
173+ p = ConfigProcessor (config ).step (ConfigMerger , ** kwargs )
174+ p .config ["execution" ]["backend" ] = p .config ["kind" ]
175+ return _BackendFactory (p .config ).backend .apply ()
176+
158177def run (config : Dict , ** kwargs ) -> Dict :
159178 """
160179 Run a job given configuration and command line args passed in (kwargs).
@@ -243,14 +262,6 @@ def run(config: Dict, **kwargs) -> Dict:
243262 _save_yaml (yamlContent , ** kwargs )
244263 return cluster_run_info
245264 else :
246- if (
247- "kind" in p .config
248- and p .config ["execution" ].get ("backend" , None ) != BACKEND_NAME .LOCAL .value
249- and "ocid" not in p .config ["execution" ]
250- ):
251- p .config ["execution" ]["backend" ] = p .config ["kind" ]
252- return _BackendFactory (p .config ).backend .apply ()
253-
254265 if "ocid" in p .config ["execution" ]:
255266 resource_to_backend = {
256267 DataScienceResource .JOB : BACKEND_NAME .JOB ,
0 commit comments