Skip to main content

Python client library for Tutti.ai

Project description

Python client SDK for Tutti.ai

Installation

pip install tutti-client

Importing Module

from tutti_client import TuttiDuct
duct = TuttiDuct()

Usage

For example, to obtain a list of your Tutti projects:

import asyncio
from tutti_client import TuttiDuct

import logging
logger = logging.getLogger(__name__)

class MyPlayground:
    def __init__(self):
        self.tutti = TuttiDuct()

    async def catchall_event_handler(self, rid, eid, data):
        print(eid, data)

    async def on_open(self):
        await self.tutti.controllers["resource"].list_projects()

    async def main(self):
        self.tutti.add_onopen_handler(self.on_open)
        self.tutti.event_listeners["resource"].on("list_projects", self.on_list_projects)

        await self.tutti.open("http://localhost/ducts/wsd")

    async def on_list_projects(self, data, is_error):
        if is_error:
            # handle error here

            '''
            data = {
                Status: "Error",
                Reason: str,
                Timestamp: {
                  "Requested": int,
                  "Responded": int
                }
            }
            '''
        else:
            print(data)
            # do anything here

            '''
            data = {
              Contents: {
                 ...
              },
              Timestamp: {
                "Requested": int,
                "Responded": int
              }
            }
            '''


if __name__=="__main__":
    pg = MyPlayground()
    asyncio.run(pg.main())

Handling Events with Event Listeners

tutti.event_listeners["{source}"].on("{method}", handler_func)

Executing Methods with Controllers

tutti.controllers["{source}"].{method}([ ... args])

Sources

  • resource ... Tutti-relevant resources (projects, templates, nanotasks, answers, ...)
  • mturk ... Amazon Mechanical Turk-relevant operations (wrapper methods for Python Boto3 MTurk API)

Methods

Resource

get_event_history

  • Parameters: None
  • Gets all input parameter histories set by setEventHistory.

set_event_history

  • Parameters: eid, query
  • Sets input parameters to a history.

list_projects

  • Parameters: None
  • Lists Tutti projects.

create_project

  • Parameters: ProjectName
  • Creates a Tutti project.

list_templates

  • Parameters: ProjectName
  • Lists Tutti templates for the specified project.

get_responses_for_template

  • Parameters: ProjectName, TemplateName
  • Lists all worker responses for the specified template.

get_responses_for_nanotask

  • Parameters: NanotaskId

create_templates

  • Parameters: ProjectName, TemplateNames, PresetEnvName, PresetTemplateName

list_template_presets

  • Parameters: None

get_project_scheme

  • Parameters: ProjectName, Cached

get_nanotasks

  • Parameters: ProjectName, TemplateName

delete_nanotasks

  • Parameters: ProjectName, TemplateName, NanotaskIds

update_nanotask_num_assignable

  • Parameters: ProjectName, TemplateName, NanotaskId, NumAssignable

upload_nanotasks

  • Parameters: ProjectName, TemplateName, Nanotasks, NumAssignable, Priority, TagName

get_template_node

  • Parameters: Target, WorkSessionId, NodeSessionId

create_session

  • Parameters: ProjectName, PlatformWorkerId, ClientToken, Platform

set_response

  • Parameters: WorkSessionId, NodeSessionId, Answers

check_platform_worker_id_existence_for_project

  • Parameters: ProjectName, Platform, PlatformWorkerId

MTurk

get_credentials

  • Parameters: None

set_credentials

  • Parameters: AccessKeyId, SecretAccessKey

set_sandbox

  • Parameters: Enabled

clear_credentials

  • Parameters: None

delete_qualifications

  • Parameters: QualificationTypeIds

list_qualifications

  • Parameters: None

list_workers_with_qualification_type

  • Parameters: QualificationTypeId

create_qualification

  • Parameters: QualificationTypeParams

associate_qualifications_with_workers

  • Parameters: AssociateQualificationParams

list_workers

  • Parameters: None

notify_workers

  • Parameters: Subject, MessageText, SendEmailWorkerIds

create_hit_type

  • Parameters: CreateHITTypeParams, HITTypeQualificationTypeId

create_hits_with_hit_type

  • Parameters: ProjectName, NumHITs, CreateHITsWithHITTypeParams

get_hit_types

  • Parameters: HITTypeIds

expire_hits

  • Parameters: HITIds

delete_hits

  • Parameters: HITIds

list_hits

  • Parameters: Cached

list_hits_for_hit_type

  • Parameters: HITTypeId=null, Cached=true

list_assignments

  • Parameters: Cached

list_assignments_for_hits

  • Parameters: HITIds

approve_assignments

  • Parameters: AssignmentIds, RequesterFeedback

reject_assignments

  • Parameters: AssignmentIds, RequesterFeedback

get_assignments

  • Parameters: AssignmentIds

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

tutti-client-0.3.8.tar.gz (18.8 kB view details)

Uploaded Source

Built Distribution

tutti_client-0.3.8-py2.py3-none-any.whl (15.4 kB view details)

Uploaded Python 2 Python 3

File details

Details for the file tutti-client-0.3.8.tar.gz.

File metadata

  • Download URL: tutti-client-0.3.8.tar.gz
  • Upload date:
  • Size: 18.8 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.2 CPython/3.11.2

File hashes

Hashes for tutti-client-0.3.8.tar.gz
Algorithm Hash digest
SHA256 f27e7b6a7d330ca9b30465d3e4eedd584012fef9f23c504fdf398115baee4ca9
MD5 d87e2b37a0d83436792054aebf0efba9
BLAKE2b-256 8ce7a27b024d62ccc33711718b92d937f54605062d5fb60dca16b4a89101af37

See more details on using hashes here.

File details

Details for the file tutti_client-0.3.8-py2.py3-none-any.whl.

File metadata

File hashes

Hashes for tutti_client-0.3.8-py2.py3-none-any.whl
Algorithm Hash digest
SHA256 afa23d7e32bbae355603341d6e20b5297c51b019561ac7eed6ee73c2018cfe4d
MD5 f55a1f95c4a97bc60e0d356eacaecd72
BLAKE2b-256 1acb90595af4e97fc5bdf845e3d6dcce420930f68bcb29638b9c454c0fc9eaad

See more details on using hashes here.

Supported by

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