Skip to content

Commit bd80fd8

Browse files
tests: fix notebook tests
1 parent 3d44d17 commit bd80fd8

File tree

7 files changed

+24
-52
lines changed

7 files changed

+24
-52
lines changed

docs/sdk/tutorials/llm_dynamic.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -147,7 +147,7 @@ Now, we'll generate a conversation by providing a prompt.
147147

148148
```python
149149
conversation = kili.llm.create_conversation(
150-
project_id=project_id, prompt="Give me Schrödinger equation."
150+
project_id=project_id, initial_prompt="Give me Schrödinger equation."
151151
)
152152
```
153153

recipes/frame_dicom_data.ipynb

Lines changed: 7 additions & 46 deletions
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,6 @@
4242
"source": [
4343
"import os\n",
4444
"import shutil\n",
45-
"import subprocess\n",
4645
"\n",
4746
"import requests\n",
4847
"import tqdm"
@@ -165,7 +164,10 @@
165164
"for asset_key in sorted_files.keys():\n",
166165
" print(asset_key)\n",
167166
" im = read_dcm_image(sorted_files[asset_key][20])\n",
168-
" im.save(f\"./recipes/img/frame_dicom_data_{asset_key}.png\")"
167+
" im_directory = os.path.dirname(os.path.abspath(\"\"))\n",
168+
" img_name = f\"frame_dicom_data_{asset_key}.png\"\n",
169+
" save_location = os.path.join(im_directory, \"img\", img_name)\n",
170+
" im.save(img_name)"
169171
]
170172
},
171173
{
@@ -316,56 +318,15 @@
316318
"cell_type": "markdown",
317319
"metadata": {},
318320
"source": [
319-
"Finally, let's import the volumes using `appendManyToDataset` (see [link](https://staging.cloud.kili-technology.com/docs/python-graphql-api/python-api/#append_many_to_dataset)). The key argument is `json_content_array`, which is a list of list of strings. Each element is the list of urls or paths pointing to images of the volume considered.\n",
320-
" - Let's host these images locally to demonstrate how we would do it with cloud URLs for example :"
321-
]
322-
},
323-
{
324-
"cell_type": "code",
325-
"execution_count": null,
326-
"metadata": {},
327-
"outputs": [],
328-
"source": [
329-
"subprocess.Popen(\n",
330-
" f\"python -m http.server 8001 --directory {ASSET_ROOT}\",\n",
331-
" shell=True,\n",
332-
" stdin=None,\n",
333-
" stdout=None,\n",
334-
" stderr=None,\n",
335-
" close_fds=True,\n",
336-
")\n",
337-
"ROOT_URL = \"http://localhost:8001/\""
338-
]
339-
},
340-
{
341-
"cell_type": "code",
342-
"execution_count": null,
343-
"metadata": {},
344-
"outputs": [],
345-
"source": [
346-
"def files_to_urls(files):\n",
347-
" return list(map(lambda file: ROOT_URL + file.split(\"TCGA-LUAD\")[1], files))"
348-
]
349-
},
350-
{
351-
"cell_type": "code",
352-
"execution_count": null,
353-
"metadata": {},
354-
"outputs": [],
355-
"source": [
356-
"kili.append_many_to_dataset(\n",
357-
" project_id=project_id,\n",
358-
" external_id_array=list(sorted_images.keys()),\n",
359-
" json_content_array=list(map(files_to_urls, sorted_images.values())),\n",
360-
")"
321+
"Finally, let's import the volumes using `appendManyToDataset` (see [link](https://staging.cloud.kili-technology.com/docs/python-graphql-api/python-api/#append_many_to_dataset)). The key argument is `json_content_array`, which is a list of list of strings. Each element is the list of urls or paths pointing to images of the volume considered."
361322
]
362323
},
363324
{
364325
"attachments": {},
365326
"cell_type": "markdown",
366327
"metadata": {},
367328
"source": [
368-
"Or, as mentionned, you can simply provide the paths to your images, and call the function like below : "
329+
"You can simply provide the paths to your images, and call the function like below : "
369330
]
370331
},
371332
{
@@ -405,7 +366,7 @@
405366
"source": [
406367
"ds_size = kili.count_assets(project_id=project_id)\n",
407368
"print(ds_size)\n",
408-
"assert ds_size == 6"
369+
"assert ds_size == 3"
409370
]
410371
},
411372
{

recipes/img/assets_inserted.png

-153 KB
Loading

recipes/img/frame_annotation.png

-809 KB
Loading

recipes/llm_dynamic.ipynb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -237,7 +237,7 @@
237237
"outputs": [],
238238
"source": [
239239
"conversation = kili.llm.create_conversation(\n",
240-
" project_id=project_id, prompt=\"Give me Schrödinger equation.\"\n",
240+
" project_id=project_id, initial_prompt=\"Give me Schrödinger equation.\"\n",
241241
")"
242242
]
243243
},

src/kili/services/export/format/kili/__init__.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -295,9 +295,6 @@ def _scale_normalized_vertices_image_video_annotation(
295295
" the resolution of your asset.`"
296296
)
297297

298-
width = asset["resolution"]["width"] if "resolution" in asset else 0
299-
height = asset["resolution"]["height"] if "resolution" in asset else 0
300-
301298
# bbox, segmentation, polygons
302299
if "boundingPoly" in annotation and normalized_vertices:
303300
annotation["boundingPoly"] = [
@@ -310,6 +307,9 @@ def _scale_normalized_vertices_image_video_annotation(
310307
]
311308
return
312309

310+
width = asset["resolution"]["width"] if "resolution" in asset else 0
311+
height = asset["resolution"]["height"] if "resolution" in asset else 0
312+
313313
if "boundingPoly" in annotation and not normalized_vertices:
314314
annotation["boundingPoly"] = [
315315
{

src/kili/utils/bucket.py

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
"""Module for managing bucket's signed urls."""
22

33
import itertools
4+
import os
45
from typing import List, Union
56
from urllib.parse import parse_qs, urlparse
67

@@ -67,5 +68,15 @@ def clean_signed_url(url: str, endpoint: str) -> str:
6768
"""Return a cleaned signed url for frame upload."""
6869
query = urlparse(url).query
6970
id_param = parse_qs(query)["id"][0]
70-
base_path = endpoint.replace("/graphql", "/files").replace("http://", "https://")
71+
# Check if Kili is using http or https
72+
kili_path = os.getenv(
73+
"KILI_API_ENDPOINT", "https://cloud.kili-technology.com/api/label/v2/graphql"
74+
)
75+
is_using_http = kili_path.startswith("http://")
76+
if is_using_http:
77+
base_path = endpoint.replace("https://", "http://")
78+
else:
79+
base_path = endpoint.replace("http://", "https://")
80+
81+
base_path = endpoint.replace("/graphql", "/files")
7182
return f"{base_path}?id={id_param}"

0 commit comments

Comments
 (0)