Skip to content
4 changes: 4 additions & 0 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,10 @@ repos:
rev: 3.8.4
hooks:
- id: flake8
# - repo: https://github.com/pycqa/flake8
# rev: 3.9.2
# hooks:
# - id: flake8
- repo: local
hooks:
- id: pylint
Expand Down
40 changes: 38 additions & 2 deletions README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -533,6 +533,27 @@ __ https://docs.scale.com/reference#project-update-parameters
instruction="update: Please label all the stuff",
)

Update Ontology
^^^^^^^^^^^^^^^
Creates a new version of the Project Ontology. Check out `Scale's API documentation`__ for more information.

__ https://docs.scale.com/reference#project-update-ontology

.. code-block :: python

data = client.update_ontology(
project_name="test_project",
project_ontology=[
"Road",
{
"choice": "Vehicle",
"description": "a means of carrying or transporting material",
"subchoices": ["Car", "Truck", "Train", "Motorcycle"]
},
],
ontology_name="test_ontology",
)

Files
________

Expand Down Expand Up @@ -630,7 +651,7 @@ Returns all teammates in a List of Teammate objects.
from scaleapi import TeammateRole

teammates = client.invite_teammates(['email1@example.com', 'email2@example.com'], TeammateRole.Member)

Update Teammate Role
^^^^^^^^^^^^^^^^^^^^^

Expand Down Expand Up @@ -731,6 +752,22 @@ Create a training task.
client.create_training_task(TaskType, ...task parameters...)

Studio Assignments (For Scale Studio only)

List Training Attempts
^^^^^^^^^^^^^^^^^^^^^^^

Retrieves a list of training attempts by labelers.

.. code-block:: python

client.get_labeler_attempts(
quality_task_ids: Optional[List[str]] = None,
labeler_emails: Optional[List[str]] = None,
next_token: Optional[str] = None,
limit: Optional[int] = None,
)


__________________________________________

Manage project assignments for your labelers.
Expand Down Expand Up @@ -862,7 +899,6 @@ Returns a List of StudioBatch objects in the new order.

reset_studio_batch_prioprity = client.reset_studio_batches_priorities()


Error handling
______________

Expand Down
69 changes: 69 additions & 0 deletions scaleapi/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -1245,3 +1245,72 @@ def reset_studio_batches_priorities(self) -> List[StudioBatch]:
endpoint = "studio/batches/reset_priorities"
batches = self.api.post_request(endpoint)
return [StudioBatch(batch, self) for batch in batches]

def update_ontology(
self,
project_name: str,
project_ontology: List[Union[str, object]],
ontology_name: str,
) -> Project:
"""You can set ontologies on a project.
Ontologies will be referenced by the tasks of a project.
Projects keep a history of the ontologies they were set with.
The ontology can be a list of strings or objects.
choices and their subchoices must be unique throughout the.
https://docs.scale.com/reference#project-update-ontology

Args:
project_name (str):
Project's name.

ontology (List[Union[str, object]]):
A list of strings or OntologyChoice objects to be set.

name (str):
Name identifying the version of the ontology.
Returns:
Project
"""

endpoint = f"projects/{Api.quote_string(project_name)}/setOntology"
payload = dict(
ontology=project_ontology,
name=ontology_name,
)
projectdata = self.api.post_request(endpoint, body=payload)
return Project(projectdata, self)

def get_labeler_attempts(
self,
quality_task_ids: List[str] = None,
labeler_emails: List[str] = None,
next_token: str = "",
limit: int = 0,
) -> Dict[str, Union[str, List[str]]]:
"""Retrieves a list of training attempts by labelers.

Args:
quality_task_ids (List[str]):
arr of training scenario IDs returned training att.
labeler_emails (List[str]):
arr of email of the lblrs who completed training att.
next_token (str):
tokn to retrieve next page of results if there are more.
limit (int):
Number of Training Attempts to return per request.

Returns:
Dict[str, Union[str, List[str]]]:
A dict of list of training att matching labeler.
"""
endpoint = "quality/labelers"
params = {}
if quality_task_ids:
params["quality_task_ids"] = quality_task_ids
if labeler_emails:
params["labeler_emails"] = labeler_emails
if next_token:
params["next_token"] = next_token
if limit:
params["limit"] = limit
return self.api.get_request(endpoint, params=params)
2 changes: 1 addition & 1 deletion scaleapi/_version.py
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
__version__ = "2.13.0"
__version__ = "2.14.0"
__package_name__ = "scaleapi"