From 6934697e1be558528e8e53691aa4ff81bcfe4496 Mon Sep 17 00:00:00 2001 From: Sasha Date: Thu, 14 Nov 2024 17:39:27 +0100 Subject: [PATCH 1/3] [OPIK-192]: add a dataset redirect link to creation; --- sdks/python/src/opik/api_objects/opik_client.py | 14 +++++++++++++- sdks/python/src/opik/url_helpers.py | 10 ++++++++++ 2 files changed, 23 insertions(+), 1 deletion(-) diff --git a/sdks/python/src/opik/api_objects/opik_client.py b/sdks/python/src/opik/api_objects/opik_client.py index 53b4eda3b..62d9e60bb 100644 --- a/sdks/python/src/opik/api_objects/opik_client.py +++ b/sdks/python/src/opik/api_objects/opik_client.py @@ -97,6 +97,16 @@ def _display_trace_url(self, workspace: str, project_name: str) -> None: f'Started logging traces to the "{project_name}" project at {project_url}.' ) self._project_name_most_recent_trace = project_name + + def _display_created_dataset_url(self, workspace: str, dataset_name: str) -> None: + dataset_url = url_helpers.get_dataset_url( + workspace=workspace, dataset_name=dataset_name + ) + + + LOGGER.info( + f'Created a dataset "{dataset_name}" project at {dataset_url}.' + ) def trace( self, @@ -405,7 +415,9 @@ def create_dataset( description=description, rest_client=self._rest_client, ) - + + self._display_created_dataset_url(workspace=self._workspace, dataset_name=name) + return result def get_or_create_dataset( diff --git a/sdks/python/src/opik/url_helpers.py b/sdks/python/src/opik/url_helpers.py index 78fb76b26..c49b53c45 100644 --- a/sdks/python/src/opik/url_helpers.py +++ b/sdks/python/src/opik/url_helpers.py @@ -53,6 +53,16 @@ def get_project_url(workspace: str, project_name: str) -> str: ) return urllib.parse.urljoin(ui_url, project_path) +def get_dataset_url(workspace: str, dataset_name: str) -> str: + ui_url = get_ui_url() + + dataset_path = urllib.parse.quote( + f"{workspace}/redirect/datasets?name={dataset_name}", + safe=ALLOWED_URL_CHARACTERS, + ) + + return urllib.parse.urljoin(ui_url, dataset_path) + def get_base_url(url: str) -> str: parsed = urllib.parse.urlparse(url) From 31378833456d844876c53ca9497ce28840c126a3 Mon Sep 17 00:00:00 2001 From: Sasha Date: Thu, 14 Nov 2024 17:39:53 +0100 Subject: [PATCH 2/3] [OPIK-192]: run linter; --- sdks/python/src/opik/api_objects/opik_client.py | 11 ++++------- sdks/python/src/opik/url_helpers.py | 3 ++- 2 files changed, 6 insertions(+), 8 deletions(-) diff --git a/sdks/python/src/opik/api_objects/opik_client.py b/sdks/python/src/opik/api_objects/opik_client.py index 62d9e60bb..0879bd408 100644 --- a/sdks/python/src/opik/api_objects/opik_client.py +++ b/sdks/python/src/opik/api_objects/opik_client.py @@ -97,16 +97,13 @@ def _display_trace_url(self, workspace: str, project_name: str) -> None: f'Started logging traces to the "{project_name}" project at {project_url}.' ) self._project_name_most_recent_trace = project_name - + def _display_created_dataset_url(self, workspace: str, dataset_name: str) -> None: dataset_url = url_helpers.get_dataset_url( workspace=workspace, dataset_name=dataset_name ) - - LOGGER.info( - f'Created a dataset "{dataset_name}" project at {dataset_url}.' - ) + LOGGER.info(f'Created a dataset "{dataset_name}" project at {dataset_url}.') def trace( self, @@ -415,9 +412,9 @@ def create_dataset( description=description, rest_client=self._rest_client, ) - + self._display_created_dataset_url(workspace=self._workspace, dataset_name=name) - + return result def get_or_create_dataset( diff --git a/sdks/python/src/opik/url_helpers.py b/sdks/python/src/opik/url_helpers.py index c49b53c45..b446f80ad 100644 --- a/sdks/python/src/opik/url_helpers.py +++ b/sdks/python/src/opik/url_helpers.py @@ -53,6 +53,7 @@ def get_project_url(workspace: str, project_name: str) -> str: ) return urllib.parse.urljoin(ui_url, project_path) + def get_dataset_url(workspace: str, dataset_name: str) -> str: ui_url = get_ui_url() @@ -60,7 +61,7 @@ def get_dataset_url(workspace: str, dataset_name: str) -> str: f"{workspace}/redirect/datasets?name={dataset_name}", safe=ALLOWED_URL_CHARACTERS, ) - + return urllib.parse.urljoin(ui_url, dataset_path) From 4a0d8a4525ea418417751452c704491d75e51e1b Mon Sep 17 00:00:00 2001 From: Sasha Date: Thu, 14 Nov 2024 17:41:36 +0100 Subject: [PATCH 3/3] [OPIK-192]: add link to a created dataset; --- sdks/python/src/opik/api_objects/opik_client.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/sdks/python/src/opik/api_objects/opik_client.py b/sdks/python/src/opik/api_objects/opik_client.py index 0879bd408..7f8d16ed2 100644 --- a/sdks/python/src/opik/api_objects/opik_client.py +++ b/sdks/python/src/opik/api_objects/opik_client.py @@ -103,7 +103,7 @@ def _display_created_dataset_url(self, workspace: str, dataset_name: str) -> Non workspace=workspace, dataset_name=dataset_name ) - LOGGER.info(f'Created a dataset "{dataset_name}" project at {dataset_url}.') + LOGGER.info(f'Created a "{dataset_name}" dataset at {dataset_url}.') def trace( self,