Skip to content

Commit 965c33b

Browse files
committed
Fixed job run opctl.
1 parent 7f49d7e commit 965c33b

File tree

2 files changed

+26
-8
lines changed

2 files changed

+26
-8
lines changed

ads/opctl/cli.py

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717
import ads.opctl.spark.cli
1818
from ads.common import auth as authutil
1919
from ads.common.auth import AuthType
20+
from ads.opctl.cmds import apply as apply_cmd
2021
from ads.opctl.cmds import activate as activate_cmd
2122
from ads.opctl.cmds import cancel as cancel_cmd
2223
from ads.opctl.cmds import configure as configure_cmd
@@ -400,6 +401,12 @@ def run(file, **kwargs):
400401
config = suppress_traceback(debug)(yaml.safe_load)(f.read())
401402
else:
402403
raise FileNotFoundError(f"{file} is not found")
404+
405+
if (
406+
"kind" in config
407+
and config["execution"].get("backend", None) != BACKEND_NAME.LOCAL.value
408+
):
409+
return suppress_traceback(debug)(apply_cmd)(config, **kwargs)
403410
else:
404411
# If no yaml is provided, we assume there's cmdline args to define a job.
405412
config = {"kind": "job"}

ads/opctl/cmds.py

Lines changed: 19 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -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+
158177
def 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

Comments
 (0)