Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[OPIK-192]: [SDK] add a link to create dataset #641

Open
wants to merge 3 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 9 additions & 0 deletions sdks/python/src/opik/api_objects/opik_client.py
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,13 @@ def _display_trace_url(self, workspace: str, project_name: str) -> None:
)
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_name}" dataset at {dataset_url}.')

def trace(
self,
id: Optional[str] = None,
Expand Down Expand Up @@ -406,6 +413,8 @@ def create_dataset(
rest_client=self._rest_client,
)

self._display_created_dataset_url(workspace=self._workspace, dataset_name=name)

return result

def get_or_create_dataset(
Expand Down
11 changes: 11 additions & 0 deletions sdks/python/src/opik/url_helpers.py
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,17 @@ 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)
base_url = f"{parsed.scheme}://{parsed.netloc}/"
Expand Down