|
1 | | -from typing import Generator |
| 1 | +from typing import Generator, TYPE_CHECKING |
2 | 2 | from labelbox.orm.db_object import DbObject, experimental |
3 | 3 | from labelbox.orm import query |
4 | 4 | from labelbox.orm.model import Entity, Field, Relationship |
|
9 | 9 | import logging |
10 | 10 | import time |
11 | 11 |
|
| 12 | +if TYPE_CHECKING: |
| 13 | + from labelbox import Project |
| 14 | + |
12 | 15 | logger = logging.getLogger(__name__) |
13 | 16 |
|
14 | 17 |
|
@@ -37,24 +40,25 @@ def __init__(self, client, project_id, *args, **kwargs): |
37 | 40 | super().__init__(client, *args, **kwargs) |
38 | 41 | self.project_id = project_id |
39 | 42 |
|
40 | | - def project(self) -> Entity.Project: |
| 43 | + def project(self) -> Project: |
41 | 44 | """ Returns Project which this Batch belongs to |
42 | 45 |
|
43 | 46 | Raises: |
44 | 47 | LabelboxError: if the project is not found |
45 | 48 | """ |
| 49 | + Project = Entity.Project |
46 | 50 | query_str = """query getProjectPyApi($projectId: ID!) { |
47 | 51 | project( |
48 | 52 | where: {id: $projectId}){ |
49 | 53 | %s |
50 | | - }}""" % query.results_query_part(Entity.Project) |
| 54 | + }}""" % query.results_query_part(Project) |
51 | 55 | params = {"projectId": self.project_id} |
52 | 56 | response = self.client.execute(query_str, params) |
53 | 57 |
|
54 | 58 | if response is None: |
55 | | - raise ResourceNotFoundError(Entity.Project, params) |
| 59 | + raise ResourceNotFoundError(Project, params) |
56 | 60 |
|
57 | | - return Entity.Project(self.client, response["project"]) |
| 61 | + return Project(self.client, response["project"]) |
58 | 62 |
|
59 | 63 | def remove_queued_data_rows(self) -> None: |
60 | 64 | """ Removes remaining queued data rows from the batch and labeling queue. |
|
0 commit comments