Skip to content

Commit d841e40

Browse files
committed
add datacollection
1 parent a727bf5 commit d841e40

File tree

3 files changed

+41
-2
lines changed

3 files changed

+41
-2
lines changed

README.rst

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -118,6 +118,23 @@ __ https://docs.scaleapi.com/#create-annotation-task-bounding-box
118118
objects_to_annotate=["baby cow", "big cow"]
119119
)
120120
121+
Create datacollection task
122+
=========================
123+
124+
Check `this`__ for further information.
125+
126+
__ https://docs.scaleapi.com/#create-data-collection-task
127+
128+
.. code-block:: python
129+
130+
task = client.create_datacollection_task(
131+
callback_url='http://www.example.com/callback',
132+
instruction='Find the URL for the hiring page for the company with attached website.',
133+
attachment_type='website',
134+
attachment='http://www.google.com/',
135+
fields={ 'hiring_page': 'Hiring Page URL' },
136+
)
137+
121138
Retrieve task
122139
=============
123140

scaleapi/__init__.py

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,8 @@
1212
'comparison': {'attachments', 'attachment_type',
1313
'fields', 'choices'},
1414
'annotation': {'attachment', 'attachment_type', 'instruction',
15-
'objects_to_annotate', 'with_labels'}}
15+
'objects_to_annotate', 'with_labels'},
16+
'datacollection': {'attachment', 'attachment_type', 'fields'}}
1617
SCALE_ENDPOINT = 'https://api.scaleapi.com/v1/'
1718

1819

@@ -128,3 +129,8 @@ def create_annotation_task(self, **kwargs):
128129
validate_payload('annotation', kwargs)
129130
taskdata = self._postrequest('task/annotation', payload=kwargs)
130131
return Task(taskdata, self)
132+
133+
def create_datacollection_task(self, **kwargs):
134+
validate_payload('datacollection', kwargs)
135+
taskdata = self._postrequest('task/datacollection', payload=kwargs)
136+
return Task(taskdata, self)

tests/test_client.py

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ def test_categorize_fail():
3939
categories=['public', 'private'])
4040

4141

42-
def test_transcrption_ok():
42+
def test_transcription_ok():
4343
task = client.create_transcription_task(
4444
callback_url='http://www.example.com/callback',
4545
instruction='Transcribe the given fields. Then for each news item on the page, transcribe the information for the row.',
@@ -118,6 +118,22 @@ def test_annotation_fail():
118118
attachment_type='image')
119119

120120

121+
def test_datacollection_ok():
122+
task = client.create_datacollection_task(
123+
callback_url='http://www.example.com/callback',
124+
instruction='Find the URL for the hiring page for the company with attached website.',
125+
attachment_type='website',
126+
attachment='http://www.google.com/',
127+
fields={ 'hiring_page': 'Hiring Page URL' })
128+
129+
130+
def test_datacollection_fail():
131+
with pytest.raises(scaleapi.ScaleInvalidRequest):
132+
client.create_datacollection_task(
133+
callback_url='http://www.example.com/callback',
134+
attachment_type='website')
135+
136+
121137
def test_cancel():
122138
task = make_a_task()
123139
# raises a scaleexception, because test tasks complete instantly

0 commit comments

Comments
 (0)