Skip to content

Conversation

@Tim-Kerr
Copy link
Contributor

@Tim-Kerr Tim-Kerr commented Feb 18, 2023

NOTE: Requires PTDT-1107 to be merged first before this can be tested.

  • Implemented new client SDK function is_feature_schema_archived(feature_schema_node_id: str, ontology_id: str)
  • Returns 0 if the specified feature schema is not archived
  • Returns1 if the specified feature schema is archved
  • Throws an exception when:
  • There's no ontology with the specified id
  • The specified feature schema does not exist in the ontology

How to test:

  • Create a test ontology

Tool 1 - Bounding Box
Tool 2 - Bounding Box

  • Attach the test ontology to a project and label an asset with Tool 1.
  • Do no make any annotations with Tool 2
  • Submit with label
  • View the ontology in the Schema tab
  • Archive Tool 1 in the ontology

SDK Test Code

# Tool 1
res = client.is_feature_schema_archived('cl9fzdgd2008kx0mf4bpubp2y', 'cl98n1jtb002vknmfhj0c5f9s')
print(res)

Verify that the function returns 1 for archived nodes, and 0 otherwise.

https://www.loom.com/share/643245cb1bd441ccb64f5e0c44be8995

@Tim-Kerr Tim-Kerr requested a review from lgluszek February 18, 2023 17:54
bool
"""

ontology_endpoint = self.rest_endpoint + "/ontologies/" + ontology_id
Copy link
Contributor

@lgluszek lgluszek Mar 2, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

please encode ontology_id using urllib.parse.quote

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ontology_endpoint = self.rest_endpoint + "/ontologies/" + ontology_id
response = requests.get(
ontology_endpoint,
headers=self.rest_endpoint_headers,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
headers=self.rest_endpoint_headers,
headers=self.headers,

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

headers=self.rest_endpoint_headers,
)

if response.status_code == 200:
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
if response.status_code == 200:
if response.status_code == requests.codes.ok:

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Contributor

@kkim-labelbox kkim-labelbox left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Left one comment, and please add a test case for the function, thanks!

relationships = feature_schema_nodes['relationships']
feature_schema_node_list = tools + classifications + relationships

is_feature = lambda f: f['featureSchemaId'] == feature_schema_id
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This can be simplified to:

filtered_feature_schema_nodes = [feature_schema_node for feature_schema_node in feature_schema_node_list if feature_schema_node['featureSchemaId'] == feature_schema_id]
if filtered_feature_schema_nodes:
  return bool(filtered_feature_schema_nodes[0]['archived']

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Contributor

@kkim-labelbox kkim-labelbox left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM nice job!

Copy link
Contributor

@kkim-labelbox kkim-labelbox left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actually sorry, could you also add a case where is_feature_schema_archived is True?

@Tim-Kerr Tim-Kerr merged commit d64935d into develop Mar 10, 2023
@Tim-Kerr Tim-Kerr deleted the PTDT-1107 branch March 10, 2023 17:02
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants