Skip to content

Commit f0bcd44

Browse files
authored
Fixed job run opctl. (#242)
2 parents ecd2c34 + 5891b3f commit f0bcd44

File tree

2 files changed

+11
-13
lines changed

2 files changed

+11
-13
lines changed

ads/opctl/cli.py

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -388,6 +388,7 @@ def run(file, **kwargs):
388388
Jobs
389389
"""
390390
debug = kwargs["debug"]
391+
config = {}
391392
if file:
392393
if os.path.exists(file):
393394
auth = {}
@@ -400,9 +401,7 @@ def run(file, **kwargs):
400401
config = suppress_traceback(debug)(yaml.safe_load)(f.read())
401402
else:
402403
raise FileNotFoundError(f"{file} is not found")
403-
else:
404-
# If no yaml is provided, we assume there's cmdline args to define a job.
405-
config = {"kind": "job"}
404+
406405
suppress_traceback(debug)(run_cmd)(config, **kwargs)
407406

408407

ads/opctl/cmds.py

Lines changed: 9 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -154,7 +154,6 @@ def _save_yaml(yaml_content, **kwargs):
154154
f.write(yaml_content)
155155
print(f"Job run info saved to {yaml_path}")
156156

157-
158157
def run(config: Dict, **kwargs) -> Dict:
159158
"""
160159
Run a job given configuration and command line args passed in (kwargs).
@@ -171,7 +170,15 @@ def run(config: Dict, **kwargs) -> Dict:
171170
Dict
172171
dictionary of job id and run id in case of ML Job run, else empty if running locally
173172
"""
174-
p = ConfigProcessor(config).step(ConfigMerger, **kwargs)
173+
if config:
174+
p = ConfigProcessor(config).step(ConfigMerger, **kwargs)
175+
if p.config["kind"] != BACKEND_NAME.LOCAL.value and p.config["kind"] != "distributed":
176+
p.config["execution"]["backend"] = p.config["kind"]
177+
return _BackendFactory(p.config).backend.apply()
178+
else:
179+
# If no yaml is provided and config is empty, we assume there's cmdline args to define a job.
180+
config = {"kind": "job"}
181+
p = ConfigProcessor(config).step(ConfigMerger, **kwargs)
175182
if config.get("kind") == "distributed": # TODO: add kind factory
176183
print(
177184
"......................... Initializing the process ..................................."
@@ -243,14 +250,6 @@ def run(config: Dict, **kwargs) -> Dict:
243250
_save_yaml(yamlContent, **kwargs)
244251
return cluster_run_info
245252
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-
254253
if "ocid" in p.config["execution"]:
255254
resource_to_backend = {
256255
DataScienceResource.JOB: BACKEND_NAME.JOB,

0 commit comments

Comments
 (0)