crowdflower.job¶
-
class
crowdflower.job.
Job
(client=None, **data)¶ CrowdFlower Job.
Documentation for attributes can be found at https://success.crowdflower.com/hc/en-us/articles/202703435-CrowdFlower-API-Jobs-Resource-Attributes.
Parameters: - data (dict) – Job JSON dictionary
- client (crowdflower.client.Client) –
Client
instance that created this job instance
-
add_tag
(tag)¶ Add tag.
-
cancel
()¶ Permanently
cancel
a Job, stopping any incoming judgments and refunding your account for unreceived judgments.
-
channels
¶ List of enabled channels for this job.
-
convert_test_questions
()¶ Convert uploaded golden units to test questions.
-
copy
(all_units=False, gold=False)¶ Create a new job that is a copy of this job.
Parameters: - all_units – If true, all of this job’s units will be copied to the new job.
- gold – If true, only golden units will be copied to the new job.
Returns: crowdflower.job.Job
-
delete
()¶ Delete this job, removing it from CrowdFlower. Calling
Job
instance will be invalid after deletion and must not be used anymore.
-
get_results_report
()¶ Download and parse JSON report containing aggregates and individual judgments as a list of
Units
. :returns: list of crowdflower.unit.Unit
-
judgment_aggregates
¶ List of
JudgmentAggregate
instances of thisJob
.Warning
Judgments are paged with a maximum of 100 items per page. If your job has a lot of judgments – thousands or more – this will take a very VERY long time to finish when accessed for the first time. This might produce some nasty surprises, if
Job
instances are inspected withinspect.getmembers()
or some such.
-
launch
(units_count, channels=('on_demand', ))¶ Order job with
units_count
atchannels
.
-
legend
()¶ Display generated keys submitted with the form.
-
pause
()¶ Temporarily stop judgments from coming in. A paused Job may
resume
.
-
ping
()¶ Check the status/progress of Job.
-
resume
()¶ Resume a Job from
pause
at any time.
List of tags.
-
units
¶ List of
UnitPromise
instances of thisJob
.
-
update
()¶ Send updates made to this instance to CrowdFlower. Note that
title
,instructions
andcml
attributes must exist (either in the update or in the job already) for any changes to really persist, and so this method raises aRuntimeError
, if any of them is missing.“At minimum, your job must have a valid title, instructions, and one required CML form element to be saved successfully.” [1]Warning
The API will happily return a “valid” response when sent only the ‘instructions’, but nothing will change on the server side without all three. The caller is responsible for providing valid CML.
[1] https://success.crowdflower.com/hc/en-us/articles/202703435-CrowdFlower-API-Jobs-Resource-Attributes (Tue Jun 30 07:31:00 UTC 2015) Raises: RuntimeError – if title
,instructions
orcml
is missing
-
upload
(data, force=False)¶ Upload given data as JSON.
Parameters: - data (collections.abc.Iterable) – Iterable of JSON serializable objects
- force (bool) – If True force adding units even if the columns do not match existing data
-
upload_file
(file, type_=None, force=False)¶ Upload a file like object or open a file for reading and upload.
Caller is responsible for handling context on file like objects. Type must be provided with data as there is no information to make a guess from. If file like object provides text (unicode) data, it will be encoded to UTF-8 bytes.
If explicit
type_
is not provided and thefile
is a string containing a filename to open, will make a guess with mimetypes.If type information is not given and guessing did not work, will raise a
ValueError
.Valid types are
text/csv
andapplication/json
for.csv
and.json
respectively.Parameters: - file (str or file) – A file like object or a filename string, contains UTF-8 encoded data
- type (str) – Explicit type, required for file like objects
- force (bool) – If True force adding units even if the columns do not match existing data
Raises: ValueError – if type information isn’t provided and cannot guess