Skip to content

Commit e672d6a

Browse files
brandon-wadabrandonAuto-format Bot
authored
adds ability to pin note in experimental api (#383)
Adds in the is_pinned parameter to the sdk function `create_note` --------- Co-authored-by: brandon <[email protected]> Co-authored-by: Auto-format Bot <[email protected]>
1 parent 648facb commit e672d6a

File tree

2 files changed

+17
-1
lines changed

2 files changed

+17
-1
lines changed

src/groundlight/experimental_api.py

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -534,6 +534,7 @@ def create_note(
534534
detector: Union[str, Detector],
535535
note: str,
536536
image: Union[str, bytes, Image.Image, BytesIO, BufferedReader, np.ndarray, None] = None,
537+
is_pinned: bool = False,
537538
) -> None:
538539
"""
539540
Adds a note to a given detector.
@@ -568,7 +569,10 @@ def create_note(
568569
# self.notes_api.create_note(det_id, note, **kwargs)
569570
url = f"{self.endpoint}/v1/notes"
570571
files = {"image": ("image.jpg", img_bytes, "image/jpeg")} if img_bytes is not None else None
571-
data = {"content": note}
572+
data = {
573+
"content": note,
574+
"is_pinned": is_pinned,
575+
}
572576
params = {"detector_id": det_id}
573577
headers = {"x-api-token": self.configuration.api_key["ApiToken"]}
574578

test/unit/test_notes.py

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,3 +26,15 @@ def test_note_with_image(gl_experimental: ExperimentalApi):
2626
if notes[i].content == "test_note":
2727
found_note = True
2828
assert found_note
29+
30+
31+
def test_note_with_pin(gl_experimental: ExperimentalApi):
32+
name = f"Test {datetime.utcnow()}"
33+
det = gl_experimental.create_detector(name, "test_query")
34+
gl_experimental.create_note(det, "test_note", "test/assets/cat.jpeg", is_pinned=True)
35+
notes = (gl_experimental.get_notes(det).get("customer") or []) + (gl_experimental.get_notes(det).get("gl") or [])
36+
found_note = False
37+
for i in range(len(notes)):
38+
if notes[i].is_pinned:
39+
found_note = True
40+
assert found_note

0 commit comments

Comments
 (0)