Skip to content

Commit b6ed6c5

Browse files
Merge pull request #106 from dataiku/fix/dss80-run-training-recipe
Set output type to correct value when running training recipe
2 parents 38aaddb + 092b46c commit b6ed6c5

File tree

1 file changed

+16
-6
lines changed

1 file changed

+16
-6
lines changed

dataikuapi/dss/recipe.py

Lines changed: 16 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -76,15 +76,25 @@ def run(self, job_type="NON_RECURSIVE_FORCED_BUILD", partitions=None, wait=True,
7676
:return: the :class:`dataikuapi.dss.job.DSSJob` job handle corresponding to the built job
7777
:rtype: :class:`dataikuapi.dss.job.DSSJob`
7878
"""
79+
project = self.client.get_project(self.project_key)
80+
outputs = project.get_flow().get_graph().get_successor_computables(self)
7981

80-
settings = self.get_settings()
81-
output_refs = settings.get_flat_output_refs()
82-
83-
if len(output_refs) == 0:
82+
if len(outputs) == 0:
8483
raise Exception("recipe has no outputs, can't run it")
8584

86-
jd = self.client.get_project(self.project_key).new_job(job_type)
87-
jd.with_output(output_refs[0], partition=partitions)
85+
first_output = outputs[0]
86+
87+
object_type_map = {
88+
"COMPUTABLE_DATASET": "DATASET",
89+
"COMPUTABLE_FOLDER": "MANAGED_FOLDER",
90+
"COMPUTABLE_SAVED_MODEL": "SAVED_MODEL",
91+
"COMPUTABLE_STREAMING_ENDPOINT": "STREAMING_ENDPOINT",
92+
}
93+
if first_output["type"] in object_type_map:
94+
jd = project.new_job(job_type)
95+
jd.with_output(first_output["ref"], object_type=object_type_map[first_output["type"]], partition=partitions)
96+
else:
97+
raise Exception("Recipe has unsupported output type {}, can't run it".format(first_output["type"]))
8898

8999
if wait:
90100
return jd.start_and_wait()

0 commit comments

Comments
 (0)