File tree Expand file tree Collapse file tree 2 files changed +54
-0
lines changed Expand file tree Collapse file tree 2 files changed +54
-0
lines changed Original file line number Diff line number Diff line change @@ -1685,3 +1685,30 @@ def delete_feature_schema_from_ontology(
16851685 raise labelbox .exceptions .LabelboxError (
16861686 "Failed to remove feature schema from ontology, message: " +
16871687 str (response .json ()['message' ]))
1688+
1689+ def unarchive_feature_schema_node (self , ontology_id : str ,
1690+ root_feature_schema_id : str ) -> None :
1691+ """
1692+ Unarchives a feature schema node in an ontology.
1693+ Only root level feature schema nodes can be unarchived.
1694+ Args:
1695+ ontology_id (str): The ID of the ontology
1696+ root_feature_schema_id (str): The ID of the root level feature schema
1697+ Returns:
1698+ None
1699+ """
1700+ ontology_endpoint = self .rest_endpoint + "/ontologies/" + urllib .parse .quote (
1701+ ontology_id ) + '/feature-schemas/' + urllib .parse .quote (
1702+ root_feature_schema_id ) + '/unarchive'
1703+ response = requests .patch (
1704+ ontology_endpoint ,
1705+ headers = self .headers ,
1706+ )
1707+ if response .status_code == requests .codes .ok :
1708+ if not bool (response .json ()['unarchived' ]):
1709+ raise labelbox .exceptions .LabelboxError (
1710+ "Failed unarchive the feature schema." )
1711+ else :
1712+ raise labelbox .exceptions .LabelboxError (
1713+ "Failed unarchive the feature schema node, message: " ,
1714+ response .text )
Original file line number Diff line number Diff line change @@ -246,3 +246,30 @@ def test_ontology_create_read(client, rand_gen):
246246 assert _get_attr_stringify_json (created_ontology ,
247247 attr ) == _get_attr_stringify_json (
248248 queried_ontology , attr )
249+
250+
251+ def test_unarchive_feature_schema_node (client , ontology ):
252+ feature_schema_to_unarchive = ontology .normalized ['tools' ][0 ]
253+ result = client .unarchive_feature_schema_node (
254+ ontology .uid , feature_schema_to_unarchive ['featureSchemaId' ])
255+ assert result == None
256+
257+
258+ def test_unarchive_feature_schema_node_for_non_existing_feature_schema (
259+ client , ontology ):
260+ with pytest .raises (
261+ Exception ,
262+ match =
263+ "Failed to find feature schema node by id: invalid-feature-schema-id"
264+ ):
265+ client .unarchive_feature_schema_node (ontology .uid ,
266+ 'invalid-feature-schema-id' )
267+
268+
269+ def test_unarchive_feature_schema_node_for_non_existing_ontology (
270+ client , ontology ):
271+ feature_schema_to_unarchive = ontology .normalized ['tools' ][0 ]
272+ with pytest .raises (Exception ,
273+ match = "Failed to find ontology by id: invalid-ontology" ):
274+ client .unarchive_feature_schema_node (
275+ 'invalid-ontology' , feature_schema_to_unarchive ['featureSchemaId' ])
You can’t perform that action at this time.
0 commit comments