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) –
Clientinstance that created this job instance
-
cancel()¶ Permanently
cancela Job, stopping any incoming judgments and refunding your account for unreceived judgments.
-
channels¶ List of enabled channels for this job.
-
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
Jobinstance 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
JudgmentAggregateinstances 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
Jobinstances are inspected withinspect.getmembers()or some such.
-
launch(units_count, channels=('on_demand', ))¶ Order job with
units_countatchannels.
-
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
pauseat any time.
-
units¶ List of
UnitPromiseinstances of thisJob.
-
update()¶ Send updates made to this instance to CrowdFlower. Note that
title,instructionsandcmlattributes 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,instructionsorcmlis 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 thefileis 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/csvandapplication/jsonfor.csvand.jsonrespectively.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