diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 3bb7b03..0a714f5 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -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 diff --git a/README.rst b/README.rst index 2d17a2c..2cb2575 100644 --- a/README.rst +++ b/README.rst @@ -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 ________ @@ -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 ^^^^^^^^^^^^^^^^^^^^^ @@ -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. @@ -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 ______________ diff --git a/scaleapi/__init__.py b/scaleapi/__init__.py index 7e4368e..7d4711c 100644 --- a/scaleapi/__init__.py +++ b/scaleapi/__init__.py @@ -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) diff --git a/scaleapi/_version.py b/scaleapi/_version.py index 1860cc4..89429b5 100644 --- a/scaleapi/_version.py +++ b/scaleapi/_version.py @@ -1,2 +1,2 @@ -__version__ = "2.13.0" +__version__ = "2.14.0" __package_name__ = "scaleapi"