{"id":26671142,"url":"https://github.com/scaleapi/scaleapi-python-client","last_synced_at":"2025-05-16T07:05:15.090Z","repository":{"id":12192398,"uuid":"69317217","full_name":"scaleapi/scaleapi-python-client","owner":"scaleapi","description":"The official Python SDK for Scale API, the Data Platform for AI","archived":false,"fork":false,"pushed_at":"2025-02-24T19:17:38.000Z","size":713,"stargazers_count":62,"open_issues_count":3,"forks_count":32,"subscribers_count":61,"default_branch":"master","last_synced_at":"2025-04-09T03:12:34.994Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"https://www.scale.com","language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/scaleapi.png","metadata":{"files":{"readme":"README.rst","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2016-09-27T03:51:40.000Z","updated_at":"2025-03-25T22:44:16.000Z","dependencies_parsed_at":"2023-01-13T16:49:34.450Z","dependency_job_id":"9ab832e8-ed3b-4519-80c1-207830c2d0cb","html_url":"https://github.com/scaleapi/scaleapi-python-client","commit_stats":{"total_commits":143,"total_committers":35,"mean_commits":4.085714285714285,"dds":0.7902097902097902,"last_synced_commit":"64b9ed156742f3c0677cbf086df2637920cdfbd4"},"previous_names":[],"tags_count":53,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/scaleapi%2Fscaleapi-python-client","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/scaleapi%2Fscaleapi-python-client/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/scaleapi%2Fscaleapi-python-client/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/scaleapi%2Fscaleapi-python-client/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/scaleapi","download_url":"https://codeload.github.com/scaleapi/scaleapi-python-client/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":254485057,"owners_count":22078767,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2025-03-25T23:43:59.478Z","updated_at":"2025-05-16T07:05:15.049Z","avatar_url":"https://github.com/scaleapi.png","language":"Python","readme":"*********************\nScale AI | Python SDK\n*********************\n\nIf you use earlier versions of the SDK, please refer to `v1.0.4 documentation \u003chttps://github.com/scaleapi/scaleapi-python-client/blob/release-1.0.4/README.rst\u003e`_.\n\nIf you are migrating from earlier versions to v2,  please refer to `Migration Guide to v2 \u003chttps://github.com/scaleapi/scaleapi-python-client/blob/master/docs/migration_guide.md\u003e`_.\n\n|pic1| |pic2| |pic3|\n\n.. |pic1| image:: https://pepy.tech/badge/scaleapi/month\n  :alt: Downloads\n  :target: https://pepy.tech/project/scaleapi\n.. |pic2| image:: https://img.shields.io/pypi/pyversions/scaleapi.svg\n  :alt: Supported Versions\n  :target: https://pypi.org/project/scaleapi\n.. |pic3| image:: https://img.shields.io/github/contributors/scaleapi/scaleapi-python-client.svg\n  :alt: Contributors\n  :target: https://github.com/scaleapi/scaleapi-python-client/graphs/contributors\n\nInstallation\n____________\n\nInstall with PyPI (pip)\n\n.. code-block:: bash\n\n    $ pip install --upgrade scaleapi\n\nor install with Anaconda (conda)\n\n.. code-block:: bash\n\n    $ conda install -c conda-forge scaleapi\n\nUsage\n_____\n\n.. code-block:: python\n\n    import scaleapi\n\n    client = scaleapi.ScaleClient(\"YOUR_API_KEY_HERE\")\n\nIf you need to use a proxy to connect Scale API, you can feed ``proxies``, ``cert`` and ``verify`` attributes of the python ``requests`` package during the client initialization.\nProxy support is available with SDK version 2.14.0 and beyond.\n\n`Documentation of Proxies usage in requests package`__\n\n__ https://requests.readthedocs.io/en/latest/user/advanced/#proxies\n\n.. code-block:: python\n\n    proxies = { 'https': 'http://10.10.1.10:1080' }\n\n    client = scaleapi.ScaleClient(\n                api_key=\"YOUR_API_KEY_HERE\",\n                proxies=proxies,\n                cert='/path/client.cert',\n                verify=True\n            )\n\nTasks\n_____\n\nMost of these methods will return a `scaleapi.Task` object, which will contain information\nabout the json response (task_id, status, params, response, etc.).\n\nAny parameter available in `Scale's API documentation`__ can be passed as an argument option with the corresponding type.\n\n__ https://scale.com/docs/api-reference/data-engine-reference#tasks-object-overview\n\nThe following endpoints for tasks are available:\n\nCreate Task\n^^^^^^^^^^^\n\nThis method can be used for any Scale supported task type using the following format:\n\n.. code-block:: python\n\n    client.create_task(TaskType, ...task parameters...)\n\nPassing in the applicable values into the function definition. The applicable fields and further information for each task type can be found in `Scale's API documentation`__.\n\n__ https://scale.com/docs/api-reference\n\n.. code-block:: python\n\n    from scaleapi.tasks import TaskType\n    from scaleapi.exceptions import ScaleDuplicateResource\n\n    payload = dict(\n        project = \"test_project\",\n        callback_url = \"http://www.example.com/callback\",\n        instruction = \"Draw a box around each baby cow and big cow.\",\n        attachment_type = \"image\",\n        attachment = \"http://i.imgur.com/v4cBreD.jpg\",\n        unique_id = \"c235d023af73\",\n        geometries = {\n            \"box\": {\n                \"objects_to_annotate\": [\"Baby Cow\", \"Big Cow\"],\n                \"min_height\": 10,\n                \"min_width\": 10,\n            }\n        },\n    )\n\n    try:\n        client.create_task(TaskType.ImageAnnotation, **payload)\n    except ScaleDuplicateResource as err:\n        print(err.message)  # If unique_id is already used for a different task\n\n\nRetrieve a task\n^^^^^^^^^^^^^^^\n\nRetrieve a task given its id. Check out `Scale's API documentation`__ for more information.\n\n__ https://scale.com/docs/api-reference/tasks#retrieve-a-task\n\n.. code-block :: python\n\n    task = client.get_task(\"30553edd0b6a93f8f05f0fee\")\n    print(task.status)  # Task status (\"pending\", \"completed\", \"error\", \"canceled\")\n    print(task.response) # If task is complete\n\n\nTask Attributes\n^^^^^^^^^^^^^^^\n\nThe older ``param_dict`` attribute is now replaced with a method ``as_dict()`` to return a task's all attributes as a dictionary (JSON).\n\n.. code-block :: python\n\n    task.as_dict()\n\n    # {\n    #  'task_id': '30553edd0b6a93f8f05f0fee',\n    #  'created_at': '2021-06-17T21:46:36.359Z',\n    #  'type': 'imageannotation',\n    #  'status': 'pending',\n    #   ....\n    #  'params': {\n    #   'attachment': 'http://i.imgur.com/v4cBreD.jpg',\n    #   'attachment_type': 'image',\n    #   'geometries': {\n    #    'box': {\n    #     'objects_to_annotate': ['Baby Cow', 'Big Cow'],\n    #     'min_height': 10,\n    #     'min_width': 10,\n    #     ...\n    #   },\n    #  'project': 'My Project',\n    #  ...\n    # }\n\nFirst-level attributes of Task are also accessible with ``.`` annotation as the following:\n\n.. code-block :: python\n\n    task.status                   # same as task.as_dict()[\"status\"]\n    task.params[\"geometries\"]     # same as task.as_dict()[\"params\"][\"geometries\"]\n    task.response[\"annotations\"]  # same as task.as_dict()[\"response\"][\"annotations\"]\n\n\nAccessing ``task.params`` child objects directly at task level is **deprecated**. Instead of ``task.attribute``, you should use ``task.params[\"attribute\"]`` for accessing objects under `params`.\n\n.. code-block :: python\n\n    task.params[\"geometries\"]   # task.geometries is DEPRECATED\n    task.params[\"attachment\"]   # task.attachment is DEPRECATED\n\nIf you use the ``limited_response = True`` filter in ``get_tasks()``, you will only receive the following attributes: ``task_id``, ``status``, ``metadata``, ``project`` and ``otherVersion``.\n\nRetrieve List of Tasks\n^^^^^^^^^^^^^^^^^^^^^^\n\nRetrieve a list of `Task` objects, with filters for: ``project_name``, ``batch_name``, ``type``, ``status``,\n``review_status``, ``unique_id``, ``completed_after``, ``completed_before``, ``updated_after``, ``updated_before``,\n``created_after``, ``created_before``, ``tags``, ``limited_response`` and ``limit``.\n\n``get_tasks()`` is a **generator** method and yields ``Task`` objects.\n\n*A generator is another type of function, returns an iterable that you can loop over like a list.\nHowever, unlike lists, generators do not store the content in the memory.\nThat helps you to process a large number of objects without increasing memory usage.*\n\nIf you will iterate through the tasks and process them once, using a generator is the most efficient method.\nHowever, if you need to process the list of tasks multiple times, you can wrap the generator in a ``list(...)``\nstatement, which returns a list of Tasks by loading them into the memory.\n\nCheck out `Scale's API documentation`__ for more information.\n\n__ https://scale.com/docs/api-reference/tasks#retrieve-multiple-tasks\n\n.. code-block :: python\n\n    from scaleapi.tasks import TaskReviewStatus, TaskStatus\n\n    tasks = client.get_tasks(\n        project_name = \"My Project\",\n        created_after = \"2020-09-08\",\n        completed_before = \"2021-04-01\",\n        status = TaskStatus.Completed,\n        review_status = TaskReviewStatus.Accepted\n    )\n\n    # Iterating through the generator\n    for task in tasks:\n        # Download task or do something!\n        print(task.task_id)\n\n    # For retrieving results as a Task list\n    task_list = list(tasks)\n    print(f\"{len(task_list)} tasks retrieved\")\n\nGet Tasks Count\n^^^^^^^^^^^^^^^\n\n``get_tasks_count()`` method returns the number of tasks with the given optional parameters for: ``project_name``, ``batch_name``, ``type``, ``status``,\n``review_status``, ``unique_id``, ``completed_after``, ``completed_before``, ``updated_after``, ``updated_before``,\n``created_after``, ``created_before`` and ``tags``.\n\n.. code-block :: python\n\n    from scaleapi.tasks import TaskReviewStatus, TaskStatus\n\n    task_count = client.get_tasks_count(\n        project_name = \"My Project\",\n        created_after = \"2020-09-08\",\n        completed_before = \"2021-04-01\",\n        status = TaskStatus.Completed,\n        review_status = TaskReviewStatus.Accepted\n    )\n\n    print(task_count)  # 1923\n\n\nCancel Task\n^^^^^^^^^^^\n\nCancel a task given its id if work has not started on the task (task status is ``Queued`` in the UI). Check out `Scale's API documentation`__ for more information.\n\n__ https://scale.com/docs/api-reference/tasks#cancel-task\n\n.. code-block :: python\n\n    task = client.cancel_task('30553edd0b6a93f8f05f0fee')\n\n    # If you also want to clear 'unique_id' of a task while canceling\n    task = client.cancel_task('30553edd0b6a93f8f05f0fee', clear_unique_id=True)\n\n    # cancel() is also available on task object\n    task = client.get_task('30553edd0b6a93f8f05f0fee')\n    task.cancel()\n\n    # If you also want to clear 'unique_id' of a task while canceling\n    task.cancel(clear_unique_id=True)\n\n\nAudit a Task\n^^^^^^^^^^^^\n\nThis method allows you to ``accept`` or ``reject`` completed tasks, along with support for adding comments about the reason for the given audit status, mirroring our Audit UI.\nCheck out `Scale's API documentation`__ for more information.\n\n__ https://docs.scale.com/reference/audit-a-task\n\n.. code-block :: python\n\n    # Accept a completed task by submitting an audit\n    client.audit_task('30553edd0b6a93f8f05f0fee', True)\n\n    # Reject a completed task by submitting a comment with the audit\n    client.audit_task('30553edd0b6a93f8f05f0fee', False, 'Rejected due to quality')\n\n    # audit() is also available on Task object\n    task = client.get_task('30553edd0b6a93f8f05f0fee')\n    task.audit(True)\n\n\nUpdate A Task's Unique Id\n^^^^^^^^^^^^^^^^^^^^^^^^^\n\nUpdate a given task's unique_id. Check out `Scale's API documentation`__ for more information.\n\n__ https://scale.com/docs/api-reference/tasks#update-unique_id\n\n.. code-block :: python\n\n    task = client.update_task_unique_id('30553edd0b6a93f8f05f0fee', \"new_unique_id\")\n\n    # update_unique_id() is also available on task object\n    task = client.get_task('30553edd0b6a93f8f05f0fee')\n    task.update_unique_id(\"new_unique_id\")\n\n\nClear A Task's Unique Id\n^^^^^^^^^^^^^^^^^^^^^^^^^\n\nClear a given task's unique_id. Check out `Scale's API documentation`__ for more information.\n\n__ https://scale.com/docs/api-reference/tasks#delete-unique_id\n\n.. code-block :: python\n\n    task = client.clear_task_unique_id('30553edd0b6a93f8f05f0fee')\n\n    # clear_unique_id() is also available on task object\n    task = client.get_task('30553edd0b6a93f8f05f0fee')\n    task.clear_unique_id()\n\n\nSet A Task's Metadata\n^^^^^^^^^^^^^^^^^^^^^^^^^\n\nSet a given task's ``metadata``. Check out `Scale's API documentation`__ for more information.\n\n__ https://scale.com/docs/api-reference/tasks#set-task-metadata\n\n.. code-block :: python\n\n    # set metadata on a task by specifying task id\n    new_metadata = {'myKey': 'myValue'}\n    task = client.set_task_metadata('30553edd0b6a93f8f05f0fee', new_metadata)\n\n    # set metadata on a task object\n    task = client.get_task('30553edd0b6a93f8f05f0fee')\n    new_metadata = {'myKey': 'myValue'}\n    task.set_metadata(new_metadata)\n\nSet A Task's Tags\n^^^^^^^^^^^^^^^^^^^^^^^^^\n\nSet a given task's ``tags``. This will replace all existing tags on a task. Check out `Scale's API documentation`__ for more information.\n\n__ https://scale.com/docs/api-reference/tasks#set-task-tag\n\n.. code-block :: python\n\n    # set a list of tags on a task by specifying task id\n    new_tags = [\"tag1\", \"tag2\", \"tag3\"]\n    task = client.set_task_tags('30553edd0b6a93f8f05f0fee', new_tags)\n\n    # set a list of tags on a task object\n    task = client.get_task('30553edd0b6a93f8f05f0fee')\n    new_tags = [\"tag1\", \"tag2\", \"tag3\"]\n    task.set_tags(new_tags)\n\nAdd Tags to A Task\n^^^^^^^^^^^^^^^^^^^^^^^^^\n\nAdd ``tags`` to a given task. Check out `Scale's API documentation`__ for more information.\n\n__ https://scale.com/docs/api-reference/tasks#delete-task-tag\n\n.. code-block :: python\n\n    # add a list of tags on a task by specifying task id\n    tags_to_add = [\"tag4\", \"tag5\"]\n    task = client.add_task_tags('30553edd0b6a93f8f05f0fee', tags_to_add)\n\n    # add a list of tags on a task object\n    task = client.get_task('30553edd0b6a93f8f05f0fee')\n    tags_to_add = [\"tag4\", \"tag5\"]\n    task.add_tags(tags_to_add)\n\nDelete Tags from A Task\n^^^^^^^^^^^^^^^^^^^^^^^^^\n\nDelete ``tags`` from a given task. Check out `Scale's API documentation`__ for more information.\n\n__ https://scale.com/docs/api-reference/tasks#delete-task-tag\n\n.. code-block :: python\n\n    # delete a list of tags on a task by specifying task id\n    tags_to_delete = [\"tag1\", \"tag2\"]\n    task = client.delete_task_tags('30553edd0b6a93f8f05f0fee', tags_to_delete)\n\n    # delete a list of tags on a task object\n    task = client.get_task('30553edd0b6a93f8f05f0fee')\n    tags_to_delete = [\"tag1\", \"tag2\"]\n    task.delete_tags(tags_to_delete)\n\nBatches\n_______\n\nCreate Batch\n^^^^^^^^^^^^\n\nCreate a new Batch. Check out `Scale's API documentation`__ for more information.\n\n__ https://scale.com/docs/api-reference/batches#create-a-batch\n\n.. code-block:: python\n\n    batch = client.create_batch(\n        project = \"test_project\",\n        callback = \"http://www.example.com/callback\",\n        batch_name = \"batch_name_01_07_2021\"\n    )\n\n    print(batch.name)  # batch_name_01_07_2021\n\nThrows ``ScaleDuplicateResource`` exception if a batch with the same name already exists.\n\nFinalize Batch\n^^^^^^^^^^^^^^^\n\nFinalize a Batch. Check out `Scale's API documentation`__ for more information.\n\n__ https://scale.com/docs/api-reference/batches#finalize-batch\n\n.. code-block:: python\n\n    client.finalize_batch(batch_name=\"batch_name_01_07_2021\")\n\n    # Alternative method\n    batch = client.get_batch(batch_name=\"batch_name_01_07_2021\")\n    batch.finalize()\n\nCheck Batch Status\n^^^^^^^^^^^^^^^^^^\n\nGet the status of a Batch. Check out `Scale's API documentation`__ for more information.\n\n__ https://scale.com/docs/api-reference/batches#batch-status\n\n.. code-block:: python\n\n    client.batch_status(batch_name = \"batch_name_01_07_2021\")\n\n    # Alternative via Batch.get_status()\n    batch = client.get_batch(\"batch_name_01_07_2021\")\n    batch.get_status() # Refreshes tasks_{status} attributes of Batch\n    print(batch.tasks_pending, batch.tasks_completed)\n\nRetrieve A Batch\n^^^^^^^^^^^^^^^^\n\nRetrieve a single Batch. Check out `Scale's API documentation`__ for more information.\n\n__ https://scale.com/docs/api-reference/batches#batch-retrieval\n\n.. code-block:: python\n\n    batch = client.get_batch(batch_name = \"batch_name_01_07_2021\")\n\nThe older ``param_dict`` attribute is now replaced with a method ``batch.as_dict()`` to return a batch's all attributes as a dictionary (JSON).\n\nList Batches\n^^^^^^^^^^^^\n\nRetrieve a list of Batches. Optional parameters are ``project_name``, ``batch_status``, ``exclude_archived``, ``created_after`` and ``created_before``.\n\n``get_batches()`` is a **generator** method and yields ``Batch`` objects.\n\n*A generator is another type of function, returns an iterable that you can loop over like a list.\nHowever, unlike lists, generators do not store the content in the memory.\nThat helps you to process a large number of objects without increasing memory usage.*\n\nWhen wrapped in a ``list(...)`` statement, it returns a list of Batches by loading them into the memory.\n\nCheck out `Scale's API documentation`__ for more information.\n\n__ https://scale.com/docs/api-reference/batches#list-all-batches\n\n.. code-block :: python\n\n    from scaleapi.batches import BatchStatus\n\n    batches = client.get_batches(\n        batch_status=BatchStatus.Completed,\n        created_after = \"2020-09-08\"\n    )\n\n    counter = 0\n    for batch in batches:\n        counter += 1\n        print(f\"Downloading batch {counter} | {batch.name} | {batch.project}\")\n\n    # Alternative for accessing as a Batch list\n    batch_list = list(batches)\n    print(f\"{len(batch_list))} batches retrieved\")\n\nProjects\n________\n\nCreate Project\n^^^^^^^^^^^^^^\n\nCreate a new Project. Check out `Scale's API documentation`__ for more information.\n\n__ https://scale.com/docs/api-reference/projects#create-project\n\n.. code-block:: python\n\n    from scaleapi.tasks import TaskType\n\n    project = client.create_project(\n        project_name = \"Test_Project\",\n        task_type = TaskType.ImageAnnotation,\n        params = {\"instruction\": \"Please label the kittens\"},\n    )\n\n    print(project.name)  # Test_Project\n\nSpecify ``rapid=true`` for Rapid projects and ``studio=true`` for Studio projects. Throws ``ScaleDuplicateResource`` exception if a project with the same name already exists.\n\nRetrieve Project\n^^^^^^^^^^^^^^^^\n\nRetrieve a single Project. Check out `Scale's API documentation`__ for more information.\n\n__ https://scale.com/docs/api-reference/projects#project-retrieval\n\n.. code-block:: python\n\n    project = client.get_project(project_name = \"test_project\")\n\nThe older ``param_dict`` attribute is now replaced with a method ``project.as_dict()`` to return a project's all attributes as a dictionary (JSON).\n\nList Projects\n^^^^^^^^^^^^^\n\nThis function does not take any arguments. Retrieve a list of every Project.\nCheck out `Scale's API documentation`__ for more information.\n\n__ https://scale.com/docs/api-reference/projects#list-all-projects\n\n.. code-block :: python\n\n    counter = 0\n    projects = client.projects()\n    for project in projects:\n        counter += 1\n        print(f'Downloading project {counter} | {project.name} | {project.type}')\n\nUpdate Project\n^^^^^^^^^^^^^^\n\nCreates a new version of the Project. Check out `Scale's API documentation`__ for more information.\n\n__ https://scale.com/docs/api-reference/projects#update-project-parameters\n\n.. code-block :: python\n\n    data = client.update_project(\n        project_name=\"test_project\",\n        patch=False,\n        instruction=\"update: Please label all the stuff\",\n    )\n\nFiles\n________\n\nFiles are a way of uploading local files directly to Scale storage or importing files before creating tasks.\n\n\nUpload Files\n^^^^^^^^^^^^^^\n\nUpload a file. Check out `Scale's API documentation`__ for more information.\n\n__ https://scale.com/docs/api-reference/file-endpoints#file-upload\n\n.. code-block:: python\n\n    with open(file_name, 'rb') as f:\n        my_file = client.upload_file(\n            file=f,\n            project_name = \"test_project\",\n        )\n\nThe ``file.attachment_url`` can be used in place of attachments in task payload.\n\n\n.. code-block:: python\n\n    my_file.as_dict()\n\n    # {\n    #  'attachment_url': 'scaledata://606e2a0a46102303a130949/8ac09a90-c143-4154-9a9b-6c35121396d1f',\n    #  'created_at': '2021-06-17T21:56:53.825Z',\n    #  'id': '8ac09d70-ca43-4354-9a4b-6c3591396d1f',\n    #  'mime_type': 'image/png',\n    #  'project_names': ['test_project'],\n    #  'size': 340714,\n    #  'updated_at': '2021-06-17T21:56:53.825Z'\n    # }\n\nImport Files\n^^^^^^^^^^^^^^\n\nImport a file from a URL. Check out `Scale's API documentation`__ for more information.\n\n__ https://scale.com/docs/api-reference/file-endpoints#file-import\n\n.. code-block:: python\n\n    my_file = client.import_file(\n        file_url=\"http://i.imgur.com/v4cBreD.jpg\",\n        project_name = \"test_project\",\n    )\n\n\nAfter the files are successfully uploaded to Scale's storage, you can access the URL as ``my_file.attachment_url``, which will have a prefix like ``scaledata://``.\n\nThe attribute can be passed to the task payloads, in the ``attachment`` parameter.\n\n.. code-block:: python\n\n  task_payload = dict(\n      ...\n      ...\n      attachment_type = \"image\",\n      attachment = my_file.attachment_url,  # scaledata://606e2a30949/89a90-c143-4154-9a9b-6c36d1f\n      ...\n      ...\n  )\n\nManage Teammates\n________________\n\nManage the members of your Scale team via API. Check out `Scale Team API Documentation`__ for more information.\n\n__ https://scale.com/docs/team-getting-started\n\nList Teammates\n^^^^^^^^^^^^^^\n\nLists all teammates in your Scale team.\nReturns all teammates in a List of Teammate objects.\n\n.. code-block:: python\n\n    teammates = client.list_teammates()\n\nInvite Teammate\n^^^^^^^^^^^^^^^\n\nInvites a list of email strings to your team with the provided role.\nThe available teammate roles are: 'labeler', 'member', or 'manager'.\nReturns all teammates in a List of Teammate objects.\n\n.. code-block:: python\n\n    from scaleapi import TeammateRole\n\n    teammates = client.invite_teammates(['email1@example.com', 'email2@example.com'], TeammateRole.Member)\n\nUpdate Teammate Role\n^^^^^^^^^^^^^^^^^^^^^\n\nUpdates a list of emails of your Scale team members with the new role.\nThe available teammate roles are: 'labeler', 'member', or 'manager'.\nReturns all teammates in a List of Teammate objects.\n\n.. code-block python\n\n    from scaleapi import TeammateRole\n\n    teammates = client.update_teammates_role(['email1@example.com', 'email2@example.com'], TeammateRole.Manager)\n\nExample Scripts\n_______________\n\nA list of examples scripts for use.\n\n* `cancel_batch.py`__ to concurrently cancel tasks in batches\n\n__ https://github.com/scaleapi/scaleapi-python-client/blob/master/examples/cancel_batch.py\n\nEvaluation tasks (For Scale Rapid projects only)\n________________________________________________\n\nEvaluation tasks are tasks that we know the answer to and are used to measure workers' performance internally to ensure the quality\n\nCreate Evaluation Task\n^^^^^^^^^^^^^^^^^^^^^^\n\nCreate an evaluation task.\n\n.. code-block:: python\n\n    client.create_evaluation_task(TaskType, ...task parameters...)\n\nPassing in the applicable values into the function definition. The applicable fields are the same as for create_task. Applicable fields for each task type can be found in `Scale's API documentation`__. Additionally an expected_response is required. An optional initial_response can be provided if it's for a review phase evaluation task.\n\n__ https://scale.com/docs/api-reference\n\n.. code-block:: python\n\n    from scaleapi.tasks import TaskType\n\n    expected_response = {\n        \"annotations\": {\n            \"answer_reasonable\": {\n                \"type\": \"category\",\n                \"field_id\": \"answer_reasonable\",\n                \"response\": [\n                    [\n                        \"no\"\n                    ]\n                ]\n            }\n        }\n    }\n\n    initial_response = {\n        \"annotations\": {\n            \"answer_reasonable\": {\n                \"type\": \"category\",\n                \"field_id\": \"answer_reasonable\",\n                \"response\": [\n                    [\n                        \"yes\"\n                    ]\n                ]\n            }\n        }\n    }\n\n    attachments = [\n        {\"type\": \"image\", \"content\": \"https://i.imgur.com/bGjrNzl.jpeg\"}\n    ]\n\n    payload = dict(\n        project = \"test_project\",\n        attachments,\n        initial_response=initial_response,\n        expected_response=expected_response,\n    )\n\n    client.create_evaluation_task(TaskType.TextCollection, **payload)\n\nTraining tasks (For Scale Rapid projects only)\n________________________________________________\n\nTraining tasks are used to onboard taskers onto your project\n\nCreate Training Task\n^^^^^^^^^^^^^^^^^^^^^^\n\nCreate a training task.\n\n.. code-block:: python\n\n    client.create_training_task(TaskType, ...task parameters...)\n\nStudio Assignments (For Scale Studio only)\n__________________________________________\n\nManage project assignments for your labelers.\n\nList All Assignments\n^^^^^^^^^^^^^^^^^^^^\n\nLists all your Scale team members and the projects they are assigned to.\nReturns a dictionary of all teammate assignments with keys as 'emails' of each teammate, and values as a list of project names the teammate are assigned to.\n\n.. code-block:: python\n\n    assignments = client.list_studio_assignments()\n    my_assignment = assignments.get('my-email@example.com')\n\nAdd Studio Assignment\n^^^^^^^^^^^^^^^^^^^^^\n\nAssigns provided projects to specified teammate emails.\n\nAccepts a list of emails and a list of projects.\n\nReturns a dictionary of all teammate assignments with keys as 'emails' of each teammate, and values as a list of project names the teammate are assigned to.\n\n.. code-block:: python\n\n    assignments = client.add_studio_assignments(['email1@example.com', 'email2@example.com'], ['project 1', 'project 2'])\n\n\nRemove Studio Assignment\n^^^^^^^^^^^^^^^^^^^^^^^^\n\nRemoves provided projects from specified teammate emails.\n\nAccepts a list of emails and a list of projects.\n\nReturns a dictionary of all teammate assignments with keys as 'emails' of each teammate, and values as a list of project names the teammate are assigned to.\n\n.. code-block:: python\n\n    assignments = client.remove_studio_assignments(['email1@example.com', 'email2@example.com'], ['project 1', 'project 2'])\n\nStudio Project Groups (For Scale Studio Only)\n_____________________________________________\n\nManage groups of labelers in our project by using Studio Project Groups.\n\nList Studio Project Groups\n^^^^^^^^^^^^^^^^^^^^^^^^^^^\n\nReturns all labeler groups for the specified project.\n\n.. code-block:: python\n\n    list_project_group = client.list_project_groups('project_name')\n\nAdd Studio Project Group\n^^^^^^^^^^^^^^^^^^^^^^^^\n\nCreates a project group with the provided group_name for the specified project and adds the provided teammate emails to the new project group. The team members must be assigned to the specified project in order to be added to the new group.\n\nReturns the created StudioProjectGroup object.\n\n.. code-block:: python\n\n    added_project_group = client.create_project_group(\n        'project_name', ['email1@example.com'], 'project_group_name'\n    )\n\nUpdate Studio Project Group\n^^^^^^^^^^^^^^^^^^^^^^^^^^^\n\nAssign or remove teammates from a project group.\n\nReturns the updated StudioProjectGroup object.\n\n.. code-block:: python\n\n    updated_project_group = client.update_project_group(\n        'project_name', 'project_group_name', ['emails_to_add'], ['emails_to_remove']\n    )\n\nStudio Batches (For Scale Studio Only)\n_______________________________________\n\nGet information about your pending Studio batches.\n\nList Studio Batches\n^^^^^^^^^^^^^^^^^^^\n\nReturns a list of StudioBatch objects for all pending Studio batches.\n\n.. code-block:: python\n\n    studio_batches = client.list_studio_batches()\n\nAssign Studio Batches\n^^^^^^^^^^^^^^^^^^^^^^\n\nSets labeler group assignment for the specified batch.\n\nReturns a StudioBatch object for the specified batch.\n\n.. code-block:: python\n\n    assigned_studio_batch = client.assign_studio_batches('batch_name', ['project_group_name'])\n\nSet Studio Batches Priority\n^^^^^^^^^^^^^^^^^^^^^^^^^^^^\n\nSets the order to prioritize your pending Studio batches. You must include all pending studio batches in the List.\n\nReturns a List of StudioBatch objects in the new order.\n\n.. code-block:: python\n\n    studio_batch_priority = client.set_studio_batches_priorities(\n        ['pending_batch_1', 'pending_batch_2', 'pending_batch_3']\n    )\n\nReset Studio Batches Priority\n^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^\n\nResets the order of your Studio batches to the default order, which prioritizes older batches first.\n\nReturns a List of StudioBatch objects in the new order.\n\n.. code-block:: python\n\n    reset_studio_batch_prioprity = client.reset_studio_batches_priorities()\n\n\nError handling\n______________\n\nIf something went wrong while making API calls, then exceptions will be raised automatically\nas a `ScaleException` parent type and child exceptions:\n\n- ``ScaleInvalidRequest``: 400 - Bad Request -- The request was unacceptable, often due to missing a required parameter.\n- ``ScaleUnauthorized``: 401 - Unauthorized -- No valid API key provided.\n- ``ScaleNotEnabled``: 402 - Not enabled -- Please contact sales@scaleapi.com before creating this type of task.\n- ``ScaleResourceNotFound``: 404 - Not Found -- The requested resource doesn't exist.\n- ``ScaleDuplicateResource``: 409 - Conflict -- Object already exists with same name, idempotency key or unique_id.\n- ``ScaleTooManyRequests``: 429 - Too Many Requests -- Too many requests hit the API too quickly.\n- ``ScaleInternalError``: 500 - Internal Server Error -- We had a problem with our server. Try again later.\n- ``ScaleServiceUnavailable``: 503 - Server Timeout From Request Queueing -- Try again later.\n- ``ScaleTimeoutError``: 504 - Server Timeout Error -- Try again later.\n\nCheck out `Scale's API documentation \u003chttps://scale.com/docs/api-reference/errors\u003e`_ for more details.\n\nFor example:\n\n.. code-block:: python\n\n    from scaleapi.exceptions import ScaleException\n\n    try:\n        client.create_task(TaskType.TextCollection, attachment=\"Some parameters are missing.\")\n    except ScaleException as err:\n        print(err.code)  # 400\n        print(err.message)  # Parameter is invalid, reason: \"attachments\" is required\n\n\nV2 API\n______\n\nIf your project is using V2 API, you can use the ``.v2`` API client and also ``v2_get_tasks()`` to retrieve tasks in the V2 API format. See our `V2 API documentation`__.\n\n__ https://docs.genai.scale.com/get-started/quickstart\n\n.. list-table::\n   :widths: 25 25 50\n   :header-rows: 1\n\n   * - Method\n     - HTTP request\n     - Description\n   * - **get_task**\n     - **GET** /v2/task\n     - Get a Task\n   * - **get_tasks**\n     - **GET** /v2/tasks\n     - Get Multiple Tasks\n   * - **get_deliveries**\n     - **GET** /v2/deliveries\n     - List All Deliveries\n   * - **get_delivery**\n     - **GET** /v2/delivery\n     - Get Tasks in a Delivery\n   * - **get_annotation**\n     - **GET** /v2/annotation\n     - Get an Annotation\n\nFor example:\n\n.. code-block:: python\n\n    # Get a task with the V2 format\n    task = client.v2.get_task('30553edd0b6a93f8f05f0fee')\n\n    # Get tasks in the V2 format (paged)\n    tasks = client.v2.get_tasks(\n        project_name = \"My Project\"\n    )\n\n    # Get tasks in the V2 format (generator)\n    tasks = client.v2_get_tasks(\n        project_name = \"My Project\"\n    )\n\n    # Iterating through the generator\n    for task in tasks:\n        # Download task or do something!\n        print(task.task_id)\n\n\nTroubleshooting\n_______________\n\nIf you notice any problems, please contact our support via Intercom by logging into your dashboard, or, if you are Enterprise, by contacting your Engagement Manager.\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fscaleapi%2Fscaleapi-python-client","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fscaleapi%2Fscaleapi-python-client","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fscaleapi%2Fscaleapi-python-client/lists"}