Skip to content

Commit c347525

Browse files
authored
Merge pull request #34 from crowdresearch/develop
channel connections and task rejection
2 parents 4b5f918 + 8215d4c commit c347525

File tree

7 files changed

+26
-15
lines changed

7 files changed

+26
-15
lines changed

.travis.yml

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,5 @@ deploy:
2727
secure: E7fKfKDm9DbxoRWxNr6fDnjQpfQxNeTAAt1JFpjJQRdaYpN2a92JR8s8MAIWsekcSpAmNlFTWN/dnPXzy1yQEEOdAKscvkRqLkp9c15oDiHII+vSec56tgedHQt8H51EVEH73E056TrklLAU+O7Uxw4JD5+gxgxwQQSm+u+0ne7QgzTJk03YmnsSj7/89ab3JwCL1wQAdHYiU7B7BCcsQS/5yV1I2m60Q/hEJqE3Y79iVz9NSBu+BwXBOr07kTHQl2t/pXiB7rOhaWLW2+ypB0Gwtkqz2me1ymw84dKJgN1hqAhurkjdQ5Hj9NIFfvDdjpxKbMzZ1cQK1wItUGyiupYyu900BCPf1FGle6yNiIlCrtmjuEuZmF8EHVjgsp2mLidY6Wwl9f/LuR0GOgHkMx6G5a4D5xvuDWZaUGXeF0iaPMZ9XwPBzMeclFwMLmLybpFktJrJl/6DUlRZVP0Xgul5DK3IUfA3tKaZ1yOa7o4lUnZlJoluPNlNvby0JzJy5YW3d7+YGAtC1zplUuHN9qQwK3bKsk5YYSOOKq/UdMqDUAsOJH881KJSK7bz4zqCh/sPgFgf0gp8yh8VXP+Kby60OcZkeIAvahXbu2Yh2wBRV6F0wFRNfEE/UcjpPlhQ8N4UgtCttB/MA7+fYncpFNFHKaNHI63qpIQKu0TGZzI=
2828
on:
2929
branch: master
30-
tags: true
31-
distributions: "sdist bdist_wheel"
30+
distributions: "bdist_wheel"
3231
repo: crowdresearch/daemo-api-client

daemo/client.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -667,7 +667,8 @@ def _on_batch_complete(self, batch_index, approve, completed):
667667
self.store.mark_task_incomplete(
668668
batch_index,
669669
task_data.get("task_id"),
670-
task_data.get("task_group_id")
670+
task_data.get("task_group_id"),
671+
task_data.get("taskworker_id")
671672
)
672673
self.store.mark_batch_incomplete(batch_index)
673674

daemo/protocol.py

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,12 +11,14 @@ class ClientProtocol(WebSocketClientProtocol):
1111
lost = False
1212

1313
def connectionMade(self):
14+
log.info("channel connection initiated")
15+
super(ClientProtocol, self).connectionMade()
16+
17+
def onConnect(self, response):
1418
log.info("channel connected")
19+
super(ClientProtocol, self).onConnect(response)
1520
self.factory.resetDelay()
1621

17-
# def onConnect(self, response):
18-
# log.info("channel connected")
19-
2022
def onOpen(self):
2123
log.info("channel opened")
2224

daemo/storage.py

Lines changed: 15 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -59,25 +59,33 @@ def mark_task_completed(self, batch_index, task_id, task_group_id):
5959
self.batches[batch_index]["status"][task_group_id] = True
6060
log.debug(msg="task %d is complete" % task_group_id)
6161

62-
def mark_task_incomplete(self, batch_index, task_id, task_group_id):
62+
def mark_task_incomplete(self, batch_index, task_id, task_group_id, taskworker_id):
6363
if task_group_id in self.batches[batch_index]["status"]:
64-
self.batches[batch_index]["submissions"][task_group_id] = self.batches[batch_index]["submissions"][
65-
task_group_id] - 1
64+
self.batches[batch_index]["submissions"][task_group_id] = self.batches[batch_index]["submissions"][task_group_id] - 1
6665
self.batches[batch_index]["status"][task_group_id] = False
6766
log.debug(msg="task %d is NOT complete" % task_group_id)
6867

68+
data = self.batches[batch_index]["aggregated_data"]
69+
70+
aggregate = []
71+
for taskworker in data:
72+
if taskworker["data"]["taskworker_id"] != taskworker_id:
73+
aggregate.append(taskworker)
74+
75+
self.batches[batch_index]["aggregated_data"] = aggregate
76+
6977
def is_batch_complete(self, batch_index):
7078
is_complete = all(self.batches[batch_index]["status"].values())
71-
log.debug(msg="batch %d is %s complete" % (batch_index, ''if is_complete else 'NOT'))
79+
log.debug(msg="batch %d is %s complete" % (batch_index + 1, '' if is_complete else 'NOT'))
7280
return is_complete
7381

7482
def mark_batch_completed(self, batch_index):
75-
log.debug(msg="batch %d is complete" % batch_index)
83+
# log.debug(msg="batch %d is complete" % batch_index)
7684

7785
self.batches[batch_index]["is_complete"] = True
7886

7987
def mark_batch_incomplete(self, batch_index):
80-
log.debug(msg="batch %d is NOT complete" % batch_index)
88+
# log.debug(msg="batch %d is NOT complete" % batch_index)
8189

8290
self.batches[batch_index]["is_complete"] = False
8391

@@ -94,6 +102,7 @@ def all_reviews_complete(self):
94102

95103
def aggregate(self, batch_index, task_id, task_group_id, taskworker_id, task_data):
96104
task_data["taskworker_id"] = taskworker_id
105+
97106
self.batches[batch_index]["aggregated_data"].append({
98107
"task_id": task_id,
99108
"task_group_id": task_group_id,

docs/conf.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,7 @@
7070
# The short X.Y version.
7171
version = u'1.0'
7272
# The full version, including alpha/beta/rc tags.
73-
release = u'1.0.10'
73+
release = u'1.0.11'
7474

7575
# The language for content autogenerated by Sphinx. Refer to documentation
7676
# for a list of supported languages.

samples/logging.conf

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,8 @@ handlers:
1313
formatter: simple
1414
stream: ext://sys.stderr
1515
color_asctime:
16-
- black
1716
- white
17+
- black
1818
- True
1919
color_name:
2020
- cyan

setup.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@
2020

2121
setup(
2222
name='daemo-api-client',
23-
version='1.0.10',
23+
version='1.0.11',
2424
packages=find_packages(exclude=['samples']),
2525
package_data={'daemo': ['logging.conf']},
2626
install_requires=install_requires,

0 commit comments

Comments
 (0)