Skip to main content

Client for the Turkle REST API

Project description

Turkle Client

This is a client for the Turkle annotation platform. It provides a commandline interface to create and work with users, groups, projects and batches.

Install

Install from pip:

pip install turkle-client

Usage

The commandline client works similar to tools like git where there is a hierarchy of commands. The top level commands are config, users, groups, projects, and batches. Each has sub-commands like retrieve, create, or update.

To get the top level documentation, pass the -h flag:

turkle-client -h

To get documentation on an individual command:

turkle-client batches -h

Configuration

Set the url of the Turkle site and your token:

turkle-client config url https://example.org/
turkle-client config token 41dcbb22264dd60c5232383fc844dbbab4839146

To view your configuration:

turkle-client config print

The token and url can also be specified on the command line:

turkle-client -u https://example.org -t abcdef users list

Users

To list current users:

turkle-client users list

To create users, create a CSV file like this:

username,password,first_name,last_name,email
smithgc1,p@ssw0rd,george,smith,gcs@mail.com
jonesrt1,12345678,roger,jones,jones@mail.com

and then pass it to the client::

turkle-client users create --file new_users.csv

The create command also accepts jsonl files.

Updating a user requires a json object with the id of the user and then any fields that you want to change:

{"id": 5, "email": "my_new_addr@example.org"}

and is passed to the command using the file argument:

turkle-client users update --file user_update.json

Groups

List groups with:

turkle-client groups list

Creating a group requires a jsonl or json file with the name and a list of user IDs:

{"name":"Spanish annotators","users":[3,7,54]}

and then passed to the command:

turkle-client groups create --file spanish.json

Adding users to a group requires a json file with the list of user IDs:

[2,4,17,34]

which is passed to the command with the group id:

turkle-client groups addusers --id 5 --file june_users.json

Projects

A project needs a template html file:

{
  "name": "Image Contains",
  "filename": "~/templates/image_contains.html"
}

and the json object can have additional optional fields such as allotted_assignment_time and assignments_per_task.

turkle-client projects create --file myproject.json

To get information about the batches that have been published for the project:

turkle-client projects batches --id 8

Batches

To create a batch, you will need the name, project id, and csv file:

{
  "name": "Bird Photos",
  "project": 20,
  "filename": "image_contains.csv",
}

The json object can have additional fields just like creating projects.

turkle-client batches create --file mybatch.json

Getting the progress, the input csv or the results csv all work the same way:

turkle-client batches progress --id 17
turkle-client batches input --id 17
turkle-client batches results --id 17

Adding tasks to a batch can be done by passing the path to a csv file:

turkle-client batches add_tasks --id 3 --file new_tasks.csv

Permissions

Projects and batches can be limited to certain users or groups. These permissions can be retrieved, added to, and replaced. The dictionary to add or replace permissions looks like this:

{"users": [2, 3], "groups": []}

All the methods require a project or batch id passed with --pid or --bid. The add and replace methods require an additional file argument:

turkle-client permissions replace --pid 4 --file new_perms.json

Developers

Installing

pip install -e .[dev]

Testing

pytest

Releasing

  1. Update the version in version.py
  2. Update the changelog
  3. Create git tag
  4. Upload to PyPI
    • rm -rf dist/ build/ *.egg-info/
    • python -m build
    • twine upload dist/*

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

turkle_client-0.3.0.tar.gz (14.0 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

turkle_client-0.3.0-py3-none-any.whl (12.3 kB view details)

Uploaded Python 3

File details

Details for the file turkle_client-0.3.0.tar.gz.

File metadata

  • Download URL: turkle_client-0.3.0.tar.gz
  • Upload date:
  • Size: 14.0 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.8.10

File hashes

Hashes for turkle_client-0.3.0.tar.gz
Algorithm Hash digest
SHA256 e1f8b644f474c4cc2b7f1134d43d087a4757ffeb4ab63d6242d3864adfb3585a
MD5 e4ca1d2eebedb272caea74103d7e55bd
BLAKE2b-256 4117a59e6495e90bc2c13cc02b1c15dc59864890246c6ff67056af08a2b56487

See more details on using hashes here.

File details

Details for the file turkle_client-0.3.0-py3-none-any.whl.

File metadata

  • Download URL: turkle_client-0.3.0-py3-none-any.whl
  • Upload date:
  • Size: 12.3 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.8.10

File hashes

Hashes for turkle_client-0.3.0-py3-none-any.whl
Algorithm Hash digest
SHA256 a829aca1ee157c51861a6af564cb1356832ab08961045a64980dac252df1cf00
MD5 3b19c86ef35efc16a8f817da15723b57
BLAKE2b-256 66e924793004abfaa3e766059d992d259212d9852f8d4511886b6b46425c8aeb

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page