Skip to content

Commit 3aa3533

Browse files
committed
wrap the get-runs-by-date call
1 parent 2495802 commit 3aa3533

File tree

1 file changed

+22
-0
lines changed

1 file changed

+22
-0
lines changed

dataikuapi/dss/scenario.py

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,28 @@ 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_runs_by_date(self, from_date, to_date=datetime.now()):
67+
"""
68+
Get the list of the runs of the scenario in a given datetime range
69+
70+
:param datetime from_date: start of the time range to retrieve runs for
71+
:param datetime to_date: end of the time range to retrieve runs for, or now()
72+
73+
:return: A list of :class:`dataikuapi.dss.scenario.DSSScenarioRun`
74+
"""
75+
def as_date(d):
76+
if isinstance(d, datetime):
77+
return d.strftime("%Y-%m-%d")
78+
else:
79+
return d
80+
81+
runs = self.client._perform_json(
82+
"GET", "/projects/%s/scenarios/%s/get-runs-by-date" % (self.project_key, self.id), params={
83+
'fromDate' : as_date(from_date),
84+
'toDate' : as_date(to_date)
85+
})
86+
return [DSSScenarioRun(self.client, run) for run in runs]
87+
6688
def get_last_finished_run(self):
6789
"""
6890
Gets the last run that completed (successfully or not)

0 commit comments

Comments
 (0)