Skip to content

Commit ee1d147

Browse files
authored
Get resource tags from a project (#1356)
2 parents ddf2658 + 679f05c commit ee1d147

File tree

2 files changed

+20
-0
lines changed

2 files changed

+20
-0
lines changed

labelbox/schema/project.py

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -206,6 +206,22 @@ def update_project_resource_tags(
206206
for tag in res["project"]["updateProjectResourceTags"]
207207
]
208208

209+
def get_resource_tags(self) -> List[ResourceTag]:
210+
"""
211+
Returns tags for a project
212+
"""
213+
query_str = """query GetProjectResourceTagsPyApi($projectId: ID!) {
214+
project(where: {id: $projectId}) {
215+
name
216+
resourceTags {%s}
217+
}
218+
}""" % (query.results_query_part(ResourceTag))
219+
220+
results = self.client.execute(
221+
query_str, {"projectId": self.uid})['project']['resourceTags']
222+
223+
return [ResourceTag(self.client, tag) for tag in results]
224+
209225
def labels(self, datasets=None, order_by=None) -> PaginatedCollection:
210226
""" Custom relationship expansion method to support limited filtering.
211227

tests/integration/test_project.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -111,6 +111,10 @@ def delete_tag(tag_id: str):
111111
assert len(project_resource_tag) == 1
112112
assert project_resource_tag[0].uid == tagA.uid
113113

114+
project_resource_tags = client.get_project(p1.uid).get_resource_tags()
115+
assert len(project_resource_tags) == 1
116+
assert project_resource_tags[0].uid == tagA.uid
117+
114118
delete_tag(tagA.uid)
115119
delete_tag(tagB.uid)
116120

0 commit comments

Comments
 (0)