Skip to content

Commit 55de913

Browse files
committed
Set object_type for all computable types in DSSRecipe.run method
1 parent a9c7d74 commit 55de913

File tree

1 file changed

+15
-8
lines changed

1 file changed

+15
-8
lines changed

dataikuapi/dss/recipe.py

Lines changed: 15 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -76,18 +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-
if isinstance(settings, TrainingRecipeSettings):
88-
jd.with_output(output_refs[0], object_type="SAVED_MODEL", 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)
8996
else:
90-
jd.with_output(output_refs[0], partition=partitions)
97+
raise Exception("recipe has unsuported output type {}, can't run it".format(first_output["type"]))
9198

9299
if wait:
93100
return jd.start_and_wait()

0 commit comments

Comments
 (0)