From 6d99b15656507a5fac950d92d1733c118de0c050 Mon Sep 17 00:00:00 2001 From: brandon Date: Thu, 20 Feb 2025 16:14:47 -0800 Subject: [PATCH 1/5] Doc fix caught by Avi --- src/groundlight/client.py | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/src/groundlight/client.py b/src/groundlight/client.py index 7c76b560..7eded0d7 100644 --- a/src/groundlight/client.py +++ b/src/groundlight/client.py @@ -207,6 +207,8 @@ def _verify_connectivity(self) -> None: f"Error connecting to Groundlight using API token '{self.api_token_prefix}...'" f" at endpoint '{self.endpoint}'. Endpoint might be invalid or unreachable? " "Check https://status.groundlight.ai/ for service status." + + f"Original Error was: {str(e)}" ) raise GroundlightClientError(msg) from e @@ -361,6 +363,9 @@ def create_detector( # noqa: PLR0913 """ Create a new Detector with a given name and query. + Counting and Multiclass detectors are in Beta, and can be created through the + ExperimentalApi via the `create_counting_detector` and `create_multiclass_detector` methods. + **Example usage**:: gl = Groundlight() @@ -384,7 +389,7 @@ def create_detector( # noqa: PLR0913 # Create a detector in a specific group detector = gl.create_detector( name="vehicle-counter", - query="How many vehicles are in the parking lot?", + query="Are there vehicles are in the parking lot?", group_name="parking-monitoring", patience_time=60.0 ) From f63b93428408cdb6235e0a6a70f96232f730f6b7 Mon Sep 17 00:00:00 2001 From: Auto-format Bot Date: Fri, 21 Feb 2025 00:15:40 +0000 Subject: [PATCH 2/5] Automatically reformatting code --- src/groundlight/client.py | 1 - 1 file changed, 1 deletion(-) diff --git a/src/groundlight/client.py b/src/groundlight/client.py index 7eded0d7..38643a22 100644 --- a/src/groundlight/client.py +++ b/src/groundlight/client.py @@ -207,7 +207,6 @@ def _verify_connectivity(self) -> None: f"Error connecting to Groundlight using API token '{self.api_token_prefix}...'" f" at endpoint '{self.endpoint}'. Endpoint might be invalid or unreachable? " "Check https://status.groundlight.ai/ for service status." - f"Original Error was: {str(e)}" ) raise GroundlightClientError(msg) from e From 6ebf364766d1600be2bb00be23f47276a9bf7f04 Mon Sep 17 00:00:00 2001 From: brandon Date: Thu, 20 Feb 2025 16:22:47 -0800 Subject: [PATCH 3/5] Nice catch --- src/groundlight/client.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/groundlight/client.py b/src/groundlight/client.py index 7eded0d7..84aa5f45 100644 --- a/src/groundlight/client.py +++ b/src/groundlight/client.py @@ -388,7 +388,7 @@ def create_detector( # noqa: PLR0913 # Create a detector in a specific group detector = gl.create_detector( - name="vehicle-counter", + name="vehicle-monitor", query="Are there vehicles are in the parking lot?", group_name="parking-monitoring", patience_time=60.0 From 6536990e46379288eb94b35db0675f9850d9c6c2 Mon Sep 17 00:00:00 2001 From: brandon Date: Thu, 20 Feb 2025 16:37:04 -0800 Subject: [PATCH 4/5] Add reStructureText links to create_detector docstring --- src/groundlight/client.py | 66 ++++++++++++++++++--------------------- 1 file changed, 30 insertions(+), 36 deletions(-) diff --git a/src/groundlight/client.py b/src/groundlight/client.py index 8d8608b1..8ea90bec 100644 --- a/src/groundlight/client.py +++ b/src/groundlight/client.py @@ -363,52 +363,46 @@ def create_detector( # noqa: PLR0913 Create a new Detector with a given name and query. Counting and Multiclass detectors are in Beta, and can be created through the - ExperimentalApi via the `create_counting_detector` and `create_multiclass_detector` methods. + ExperimentalApi via the :meth:`ExperimentalApi.create_counting_detector` and + :meth:`ExperimentalApi.create_multiclass_detector` methods. **Example usage**:: gl = Groundlight() - # Create a basic binary detector - detector = gl.create_detector( - name="dog-on-couch-detector", - query="Is there a dog on the couch?", - confidence_threshold=0.9, - patience_time=30.0 + # Create a basic binary detector detector = gl.create_detector( + name="dog-on-couch-detector", query="Is there a dog on the couch?", + confidence_threshold=0.9, patience_time=30.0 ) - # Create a detector with metadata - detector = gl.create_detector( - name="door-monitor", - query="Is the door open?", - metadata={"location": "front-entrance", "building": "HQ"}, - confidence_threshold=0.95 + # Create a detector with metadata detector = gl.create_detector( + name="door-monitor", query="Is the door open?", metadata={"location": + "front-entrance", "building": "HQ"}, confidence_threshold=0.95 ) - # Create a detector in a specific group - detector = gl.create_detector( - name="vehicle-monitor", - query="Are there vehicles are in the parking lot?", - group_name="parking-monitoring", - patience_time=60.0 + # Create a detector in a specific group detector = gl.create_detector( + name="vehicle-monitor", query="Are there vehicles are in the parking lot?", + group_name="parking-monitoring", patience_time=60.0 ) - :param name: A short, descriptive name for the detector. This name should be unique within your account - and help identify the detector's purpose. - :param query: The question that the detector will answer about images. For binary classification, - this should be a yes/no question (e.g. "Is there a person in the image?"). - :param group_name: Optional name of a group to organize related detectors together. If not specified, - the detector will be placed in the default group. - :param confidence_threshold: A value between 0.5 and 1 that sets the minimum confidence level required - for the ML model's predictions. If confidence is below this threshold, - the query may be sent for human review. - :param patience_time: The maximum time in seconds that Groundlight will attempt to generate a - confident prediction before falling back to human review. Defaults to 30 seconds. - :param pipeline_config: Advanced usage only. Configuration string needed to instantiate a specific - prediction pipeline for this detector. - :param metadata: A dictionary or JSON string containing custom key/value pairs to associate with - the detector (limited to 1KB). This metadata can be used to store additional - information like location, purpose, or related system IDs. You can retrieve this - metadata later by calling `get_detector()`. + :param name: A short, descriptive name for the detector. This name should be unique within + your account and help identify the detector's purpose. + :param query: The question that the detector will answer about images. For binary + classification, this should be a yes/no question (e.g. "Is there a person in + the image?"). + :param group_name: Optional name of a group to organize related detectors together. If not + specified, the detector will be placed in the default group. + :param confidence_threshold: A value between 0.5 and 1 that sets the minimum confidence + level required for the ML model's predictions. If confidence is + below this threshold, the query may be sent for human review. + :param patience_time: The maximum time in seconds that Groundlight will attempt to generate + a confident prediction before falling back to human review. Defaults to + 30 seconds. + :param pipeline_config: Advanced usage only. Configuration string needed to instantiate a + specific prediction pipeline for this detector. + :param metadata: A dictionary or JSON string containing custom key/value pairs to associate + with the detector (limited to 1KB). This metadata can be used to store + additional information like location, purpose, or related system IDs. You + can retrieve this metadata later by calling `get_detector()`. :return: The created Detector object """ From 426e147c52e68ad4c8eeea8272c2bcb62d719d9a Mon Sep 17 00:00:00 2001 From: brandon Date: Thu, 20 Feb 2025 16:39:16 -0800 Subject: [PATCH 5/5] the VScode rewrap extension failed me --- src/groundlight/client.py | 63 ++++++++++++++++++++++----------------- 1 file changed, 35 insertions(+), 28 deletions(-) diff --git a/src/groundlight/client.py b/src/groundlight/client.py index 8ea90bec..ff5a4f5a 100644 --- a/src/groundlight/client.py +++ b/src/groundlight/client.py @@ -370,39 +370,46 @@ def create_detector( # noqa: PLR0913 gl = Groundlight() - # Create a basic binary detector detector = gl.create_detector( - name="dog-on-couch-detector", query="Is there a dog on the couch?", - confidence_threshold=0.9, patience_time=30.0 + # Create a basic binary detector + detector = gl.create_detector( + name="dog-on-couch-detector", + query="Is there a dog on the couch?", + confidence_threshold=0.9, + patience_time=30.0 ) - # Create a detector with metadata detector = gl.create_detector( - name="door-monitor", query="Is the door open?", metadata={"location": - "front-entrance", "building": "HQ"}, confidence_threshold=0.95 + # Create a detector with metadata + detector = gl.create_detector( + name="door-monitor", + query="Is the door open?", + metadata={"location": "front-entrance", "building": "HQ"}, + confidence_threshold=0.95 ) - # Create a detector in a specific group detector = gl.create_detector( - name="vehicle-monitor", query="Are there vehicles are in the parking lot?", - group_name="parking-monitoring", patience_time=60.0 + # Create a detector in a specific group + detector = gl.create_detector( + name="vehicle-monitor", + query="Are there vehicles are in the parking lot?", + group_name="parking-monitoring", + patience_time=60.0 ) - :param name: A short, descriptive name for the detector. This name should be unique within - your account and help identify the detector's purpose. - :param query: The question that the detector will answer about images. For binary - classification, this should be a yes/no question (e.g. "Is there a person in - the image?"). - :param group_name: Optional name of a group to organize related detectors together. If not - specified, the detector will be placed in the default group. - :param confidence_threshold: A value between 0.5 and 1 that sets the minimum confidence - level required for the ML model's predictions. If confidence is - below this threshold, the query may be sent for human review. - :param patience_time: The maximum time in seconds that Groundlight will attempt to generate - a confident prediction before falling back to human review. Defaults to - 30 seconds. - :param pipeline_config: Advanced usage only. Configuration string needed to instantiate a - specific prediction pipeline for this detector. - :param metadata: A dictionary or JSON string containing custom key/value pairs to associate - with the detector (limited to 1KB). This metadata can be used to store - additional information like location, purpose, or related system IDs. You - can retrieve this metadata later by calling `get_detector()`. + :param name: A short, descriptive name for the detector. This name should be unique within your account + and help identify the detector's purpose. + :param query: The question that the detector will answer about images. For binary classification, + this should be a yes/no question (e.g. "Is there a person in the image?"). + :param group_name: Optional name of a group to organize related detectors together. If not specified, + the detector will be placed in the default group. + :param confidence_threshold: A value between 0.5 and 1 that sets the minimum confidence level required + for the ML model's predictions. If confidence is below this threshold, + the query may be sent for human review. + :param patience_time: The maximum time in seconds that Groundlight will attempt to generate a + confident prediction before falling back to human review. Defaults to 30 seconds. + :param pipeline_config: Advanced usage only. Configuration string needed to instantiate a specific + prediction pipeline for this detector. + :param metadata: A dictionary or JSON string containing custom key/value pairs to associate with + the detector (limited to 1KB). This metadata can be used to store additional + information like location, purpose, or related system IDs. You can retrieve this + metadata later by calling `get_detector()`. :return: The created Detector object """