Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
28 commits
Select commit Hold shift + click to select a range
2bee54f
[PTDT-1108] Added client method unarchive_root_schema_node
Tim-Kerr Feb 25, 2023
4ff4242
Ran yapf formatter
Tim-Kerr Feb 25, 2023
63703a7
Updated property name to match value sent back from the api
Tim-Kerr Feb 27, 2023
3660587
fix merge conflict
Tim-Kerr Mar 1, 2023
a761ab1
Fix rest entpoint url
Tim-Kerr Mar 1, 2023
f03fe04
updated function name
Tim-Kerr Mar 1, 2023
285962c
Ran yapf formatter
Tim-Kerr Mar 1, 2023
d5bfb3a
Ran linter
Tim-Kerr Mar 1, 2023
bbf1fdd
Merge branch 'develop' into PTDT-1108
Tim-Kerr Mar 2, 2023
179ec61
Cleanup
Tim-Kerr Mar 2, 2023
3f98a70
url encoding rest params
Tim-Kerr Mar 2, 2023
734dd3b
pr suggestions
Tim-Kerr Mar 2, 2023
69d9825
updated error message
Tim-Kerr Mar 2, 2023
4764f3e
updated error message
Tim-Kerr Mar 2, 2023
b61eb56
Ran yapf formatter
Tim-Kerr Mar 2, 2023
3bd48c1
Merge branch 'develop' into PTDT-1108
Tim-Kerr Mar 3, 2023
85e77f6
Added extra docs
Tim-Kerr Mar 3, 2023
5e7de09
Merge branch 'develop' into PTDT-1108
Tim-Kerr Mar 8, 2023
43b6009
Added integration test
Tim-Kerr Mar 8, 2023
bbc9e4f
Ran yapf formatter
Tim-Kerr Mar 8, 2023
3548045
Added unhappy path integration tests
Tim-Kerr Mar 8, 2023
2c45ec7
Now raising an exception if the feature schema is not successfully ar…
Tim-Kerr Mar 9, 2023
b34b2d9
cleanup
Tim-Kerr Mar 9, 2023
a4640bf
moved client method to the bottom of the file to avoid conflicts
Tim-Kerr Mar 10, 2023
954cb91
Moved tests to the bottom of the file to avoid conflicts
Tim-Kerr Mar 10, 2023
9c51b28
Merge branch 'develop' into PTDT-1108
Tim-Kerr Mar 10, 2023
65b814b
Now returning None from the client method
Tim-Kerr Mar 10, 2023
5f89245
Ran the formatter
Tim-Kerr Mar 10, 2023
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
27 changes: 27 additions & 0 deletions labelbox/client.py
Original file line number Diff line number Diff line change
Expand Up @@ -1685,3 +1685,30 @@ def delete_feature_schema_from_ontology(
raise labelbox.exceptions.LabelboxError(
"Failed to remove feature schema from ontology, message: " +
str(response.json()['message']))

def unarchive_feature_schema_node(self, ontology_id: str,
root_feature_schema_id: str) -> None:
"""
Unarchives a feature schema node in an ontology.
Only root level feature schema nodes can be unarchived.
Args:
ontology_id (str): The ID of the ontology
root_feature_schema_id (str): The ID of the root level feature schema
Returns:
None
"""
ontology_endpoint = self.rest_endpoint + "/ontologies/" + urllib.parse.quote(
ontology_id) + '/feature-schemas/' + urllib.parse.quote(
root_feature_schema_id) + '/unarchive'
response = requests.patch(
ontology_endpoint,
headers=self.headers,
)
if response.status_code == requests.codes.ok:
if not bool(response.json()['unarchived']):
raise labelbox.exceptions.LabelboxError(
"Failed unarchive the feature schema.")
else:
raise labelbox.exceptions.LabelboxError(
"Failed unarchive the feature schema node, message: ",
response.text)
27 changes: 27 additions & 0 deletions tests/integration/test_ontology.py
Original file line number Diff line number Diff line change
Expand Up @@ -246,3 +246,30 @@ def test_ontology_create_read(client, rand_gen):
assert _get_attr_stringify_json(created_ontology,
attr) == _get_attr_stringify_json(
queried_ontology, attr)


def test_unarchive_feature_schema_node(client, ontology):
feature_schema_to_unarchive = ontology.normalized['tools'][0]
result = client.unarchive_feature_schema_node(
ontology.uid, feature_schema_to_unarchive['featureSchemaId'])
assert result == None


def test_unarchive_feature_schema_node_for_non_existing_feature_schema(
client, ontology):
with pytest.raises(
Exception,
match=
"Failed to find feature schema node by id: invalid-feature-schema-id"
):
client.unarchive_feature_schema_node(ontology.uid,
'invalid-feature-schema-id')


def test_unarchive_feature_schema_node_for_non_existing_ontology(
client, ontology):
feature_schema_to_unarchive = ontology.normalized['tools'][0]
with pytest.raises(Exception,
match="Failed to find ontology by id: invalid-ontology"):
client.unarchive_feature_schema_node(
'invalid-ontology', feature_schema_to_unarchive['featureSchemaId'])