Skip to content

Commit 5e9a6bb

Browse files
feat: added model param and remove jobIdentifier params on jobHistory (#4)
1 parent 851a477 commit 5e9a6bb

File tree

2 files changed

+9
-21
lines changed

2 files changed

+9
-21
lines changed

modzy/jobs.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@ def get(self, job):
6161
json_obj = self._api_client.http.get('{}/{}'.format(self._base_route, identifier))
6262
return Job(json_obj, self._api_client)
6363

64-
def get_history(self, user=None, access_key=None, start_date=None, end_date=None, job_identifiers=None,
64+
def get_history(self, user=None, access_key=None, start_date=None, end_date=None, model=None,
6565
status='all', sort_by=None, direction=None, page=None, per_page=None):
6666
"""Gets a list of `Job` instances within a set of parameters.
6767
@@ -70,7 +70,7 @@ def get_history(self, user=None, access_key=None, start_date=None, end_date=None
7070
access_key (Optional[str]): Identifier of the access key to be assigned to the user
7171
start_date (Optional[datetime, str]): initial date to filter recods
7272
end_date (Optional[datetime, str]): final date to filter recods
73-
job_identifiers (Optional[Union[List[str], Tuple[str]]]): Array of unique job identifiers
73+
model (Optional[str]): Model name or version identifier
7474
status (Optional[str]): Status of the jobs (all, pending, terminated)
7575
sort_by (Optional[str]): attribute name to sort results
7676
direction (Optional[str]): Direction of the sorting algorithm (asc, desc)
@@ -99,8 +99,8 @@ def get_history(self, user=None, access_key=None, start_date=None, end_date=None
9999
raise TypeError("the end_date param should be a datetime or string")
100100
if status is not None and not isinstance(status, str):
101101
raise TypeError("the status param should be a string")
102-
if job_identifiers is not None and not isinstance(job_identifiers, (list, tuple)):
103-
raise TypeError("the job_identifiers param should be a list or tuple")
102+
if model is not None and not isinstance(model, str):
103+
raise TypeError("the model param should be a string")
104104
if sort_by is not None and not isinstance(sort_by, str):
105105
raise TypeError("the sort_by param should be a string")
106106
if direction is not None and not isinstance(direction, str):
@@ -120,7 +120,7 @@ def get_history(self, user=None, access_key=None, start_date=None, end_date=None
120120
"accessKey": access_key,
121121
"startDate": start_date,
122122
"endDate": end_date,
123-
"jobIdentifiers": job_identifiers,
123+
"model": model,
124124
"status": status,
125125
"sort-by": sort_by,
126126
"direction": direction,

tests/test_jobs.py

Lines changed: 4 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ def test_get_job_history(client, logger):
4242

4343

4444
def test_get_job_history_by_user(client, logger):
45-
params = {'user': API_KEY.split('.')[0]}
45+
params = {'user': 'a'}
4646
jobs = client.jobs.get_history(**params)
4747
logger.debug("jobs history: by %s %d", params, len(jobs))
4848
for job in jobs:
@@ -102,25 +102,13 @@ def test_get_job_history_by_date(client, logger):
102102
assert api_error
103103

104104

105-
def test_get_job_history_by_job_identifiers(client, logger):
106-
# by unexisting identifiers
107-
params = {'job_identifiers': ["a", "b", "c"]}
105+
def test_get_job_history_by_model(client, logger):
106+
# by model
107+
params = {'model': 'Sentiment Analysis'}
108108
jobs = client.jobs.get_history(**params)
109109
logger.debug("jobs history: by %s %d", params, len(jobs))
110-
assert len(jobs) == 0
111-
# by valid identificators
112-
job1 = client.jobs.submit_text(MODEL_ID, '0.0.27', {'input.txt': 'Modzy is great!'})
113-
job2 = client.jobs.submit_text(MODEL_ID, '0.0.27', {'input.txt': 'Modzy is great!'})
114-
params = {'job_identifiers': [job1.job_identifier, job2.job_identifier]}
115-
jobs = client.jobs.get_history(**params)
116110
logger.debug("jobs history: by %s %d", params, len(jobs))
117111
assert len(jobs)
118-
# by empty array
119-
params = {'job_identifiers': []}
120-
jobs = client.jobs.get_history(**params)
121-
logger.debug("jobs history: by %s %d", params, len(jobs))
122-
assert len(jobs)
123-
124112

125113
def test_get_job_history_by_status(client, logger):
126114
# by all

0 commit comments

Comments
 (0)