Skip to content

Commit 15f850f

Browse files
committed
Added distinctRecomms parameter to batch request
1 parent 9d39c31 commit 15f850f

File tree

8 files changed

+21
-9
lines changed

8 files changed

+21
-9
lines changed

recombee_api_client/api_requests/batch.py

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,11 +15,13 @@ class Batch(Request):
1515
- currently, batch size is limited to **10,000** requests; if you wish to execute even larger number of requests, please split the batch into multiple parts.
1616
"""
1717

18-
def __init__(self,requests):
18+
def __init__(self, requests, distinctRecomms=None):
1919
"""
20-
@param requests: List of Requests
20+
@param requests: List of Requests.
21+
@param distinctRecomms: Makes all the recommended items for a certain user distinct among multiple recommendation requests in the batch.
2122
"""
2223
self.requests = requests
24+
self.distinctRecomms = distinctRecomms
2325
self.timeout = sum([req.timeout for req in self.requests])
2426
self.ensure_https = True
2527
self.method = 'post'
@@ -32,7 +34,10 @@ def get_body_parameters(self):
3234
reqs = []
3335
for r in self.requests:
3436
reqs.append(self.__request_to_batch_dict(r))
35-
return {'requests': reqs}
37+
result = {'requests': reqs}
38+
if self.distinctRecomms is not None:
39+
result['distinctRecomms'] = self.distinctRecomms
40+
return result
3641

3742
def __request_to_batch_dict(self, req):
3843

recombee_api_client/api_requests/list_groups.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ class ListGroups(Request):
88
def __init__(self):
99
"""
1010
"""
11-
self.timeout = 1000
11+
self.timeout = 30000
1212
self.ensure_https = False
1313
self.method = 'get'
1414
self.path = "/{databaseId}/groups/list/" % ()

recombee_api_client/api_requests/list_items.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ def __init__(self,filter=None):
1313
1414
"""
1515
self.filter = filter
16-
self.timeout = 1000
16+
self.timeout = 30000
1717
self.ensure_https = False
1818
self.method = 'get'
1919
self.path = "/{databaseId}/items/list/" % ()

recombee_api_client/api_requests/list_series.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ class ListSeries(Request):
88
def __init__(self):
99
"""
1010
"""
11-
self.timeout = 1000
11+
self.timeout = 30000
1212
self.ensure_https = False
1313
self.method = 'get'
1414
self.path = "/{databaseId}/series/list/" % ()

recombee_api_client/api_requests/list_users.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ class ListUsers(Request):
88
def __init__(self):
99
"""
1010
"""
11-
self.timeout = 1000
11+
self.timeout = 30000
1212
self.ensure_https = False
1313
self.method = 'get'
1414
self.path = "/{databaseId}/users/list/" % ()

recombee_api_client/api_requests/merge_users.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ class MergeUsers(Request):
55
Merges purchases, ratings, bookmarks, and detail views of two different users under a single user ID. This is especially useful for online e-commerce applications working with anonymous users identified by unique tokens such as the session ID. In such applications, it may often happen that a user owns a persistent account, yet accesses the system anonymously while, e.g., putting items into a shopping cart. At some point in time, such as when the user wishes to confirm the purchase, (s)he logs into the system using his/her username and password. The interactions made under anonymous session ID then become connected with the persistent account, and merging these two together becomes desirable.
66
77
8-
Merging happens between two users referred to as the *source* and the *target*. After the merge, all the interactions of the source user are attributed to the target user, and the source user is **deleted** unless special parameter `keepSourceUser` is set `true`.
8+
Merging happens between two users referred to as the *target* and the *source*. After the merge, all the interactions of the source user are attributed to the target user, and the source user is **deleted** unless special parameter `keepSourceUser` is set `true`.
99
1010
"""
1111

setup.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
setup(
1212
name='recombee-api-client',
1313

14-
version='1.2.3',
14+
version='1.2.4',
1515

1616
description='Client for Recombee recommendation API',
1717
long_description=long_description,

tests/test_cases/add_interaction.py

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,13 @@ def test_add_interaction(self):
2323
req = self.create_request('entity_id','entity_id',timestamp='2013-10-29T09:38:41.341Z')
2424
resp = self.client.send(req)
2525
# it 'fails with nonexisting item id'
26+
req = self.create_request('entity_id','nonex_id')
27+
try:
28+
self.client.send(req)
29+
self.assertFail()
30+
except ResponseException as ex:
31+
self.assertEqual(ex.status_code, 404)
32+
# it 'fails with nonexisting user id'
2633
req = self.create_request('nonex_id','entity_id')
2734
try:
2835
self.client.send(req)

0 commit comments

Comments
 (0)