Skip to content

Commit b96e2d6

Browse files
committed
Add more accessors in scenario API
1 parent 47ca4ec commit b96e2d6

File tree

1 file changed

+15
-0
lines changed

1 file changed

+15
-0
lines changed

dataikuapi/dss/scenario.py

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,16 @@ def get_last_runs(self, limit=10, only_finished_runs=False):
6363
})
6464
return [DSSScenarioRun(self.client, run) for run in runs]
6565

66+
def get_last_finished_run(self):
67+
"""
68+
Gets the last run that completed (either successfully or not)
69+
:return: A :class:`dataikuapi.dss.scenario.DSSScenarioRun`
70+
"""
71+
lr = self.get_last_runs(only_finished_runs=True)
72+
if len(lr) == 0:
73+
raise ValueError("No scenario run completed")
74+
return lr[0]
75+
6676
def get_current_run(self):
6777
"""
6878
Get the current run of the scenario, or None if it is not running at the moment
@@ -361,6 +371,11 @@ def __init__(self, client, run):
361371
self.client = client
362372
self.run = run
363373

374+
@property
375+
def id(self):
376+
"""The run id of this run"""
377+
return self.run["runId"]
378+
364379
def refresh(self):
365380
"""Refreshes the details (outcome, running, info, ...) from the scenario"""
366381
updated_run_details = self.client._perform_json("GET", "/projects/%s/scenarios/%s/%s/" % \

0 commit comments

Comments
 (0)