|
89 | 89 | "# Set this if running in colab. Otherwise it should work if you have the LABELBOX_API_KEY set.\n", |
90 | 90 | "API_KEY = os.environ[\"LABELBOX_API_KEY\"]\n", |
91 | 91 | "# Only update this if you have an on-prem deployment\n", |
92 | | - "ENDPOINT = \"https://api.labelbox.com/graphql\" " |
| 92 | + "ENDPOINT = \"https://api.labelbox.com/graphql\"" |
93 | 93 | ] |
94 | 94 | }, |
95 | 95 | { |
|
108 | 108 | "metadata": {}, |
109 | 109 | "outputs": [], |
110 | 110 | "source": [ |
111 | | - "client = Client(api_key = API_KEY, endpoint = ENDPOINT)" |
| 111 | + "client = Client(api_key=API_KEY, endpoint=ENDPOINT)" |
112 | 112 | ] |
113 | 113 | }, |
114 | 114 | { |
|
191 | 191 | "metadata": {}, |
192 | 192 | "outputs": [], |
193 | 193 | "source": [ |
194 | | - "project.update(description = \"new description field\")\n", |
| 194 | + "project.update(description=\"new description field\")\n", |
195 | 195 | "print(project.description)" |
196 | 196 | ] |
197 | 197 | }, |
|
279 | 279 | } |
280 | 280 | ], |
281 | 281 | "source": [ |
282 | | - "datasets = client.get_datasets(where = Dataset.name == DATASET_NAME )\n", |
| 282 | + "datasets = client.get_datasets(where=Dataset.name == DATASET_NAME)\n", |
| 283 | + "\n", |
| 284 | + "projects = client.get_projects(\n", |
| 285 | + " where=((Project.name == PROJECT_NAME)\n", |
| 286 | + " & (Project.description == \"new description field\")))\n", |
283 | 287 | "\n", |
284 | | - "projects = client.get_projects(where = (\n", |
285 | | - " (Project.name == PROJECT_NAME)\n", |
286 | | - " & \n", |
287 | | - " (Project.description == \"new description field\")\n", |
288 | | - "))\n", |
289 | | - " \n", |
290 | 288 | "# The above two queries return PaginatedCollections because the filter parameters aren't guarenteed to be unique.\n", |
291 | 289 | "# So even if there is one element returned it is in a paginatedCollection.\n", |
292 | 290 | "print(projects)\n", |
|
313 | 311 | "metadata": {}, |
314 | 312 | "source": [ |
315 | 313 | "### Relationship\n", |
316 | | - "* This solves the above problem of querying by a relationship\n", |
| 314 | + "* Relationships can be used to query for related objects (solves the limitation outlined above)\n", |
| 315 | + " * E.g. if a user wants all projects that have a specific dataset attached, then can run the code below.\n", |
317 | 316 | "* You can find all realtionships of a DB object in the source code\n", |
318 | | - " * eg. for a Project ( https://github.com/Labelbox/labelbox-python/blob/develop/labelbox/schema/project.py))" |
| 317 | + " * E.g. for a Project ( https://github.com/Labelbox/labelbox-python/blob/develop/labelbox/schema/project.py))" |
319 | 318 | ] |
320 | 319 | }, |
321 | 320 | { |
|
0 commit comments