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

Add experiment link in the SDK #353

Merged
merged 6 commits into from
Oct 7, 2024
Merged

Conversation

jverre
Copy link
Collaborator

@jverre jverre commented Oct 4, 2024

Details

Display a link to the experiment when the experiment ends, the URL requires the dataset ID which is not known which leads to 1 extra API call but shouldn't degrade the experience too much. The output from an experiment is now:

╭─ My 42 dataset (5 samples) ────────╮
│                                    │
│ Total time:        00:00:02        │
│ Number of samples: 5               │
│                                    │
│ ContainsHello: 0.0000 (avg)        │
│ ContainsBye: 0.0000 (avg)          │
│ is_json_metric: 0.2000 (avg)       │
│ hallucination_metric: 0.0000 (avg) │
│                                    │
╰────────────────────────────────────╯
Uploading results to Opik ... 
View the results here

In a follow up PR we can consider removing the Uploading results to Opik... message as it is now redundant (assuming the upload time is relatively small)

@jverre jverre requested a review from a team as a code owner October 4, 2024 17:44
japdubengsub
japdubengsub previously approved these changes Oct 7, 2024
dataset_id = dataset.id

config = opik.config.OpikConfig()
ui_url = get_ui_url()
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

When this method is called, OpikConfig will be reinitialized again, which can be considered a resource-intensive operation as it involves reading environment variables, config file, etc.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@japdubengsub The evaluate function is already very resource intensive and takes at least 15 seconds to run, don't think this will be an issue. Is there another way to get the configuration that is already read ? If not, we can keep as is



def get_ui_url() -> str:
config = opik.config.OpikConfig()
opik_url_override = config.url_override

return opik_url_override.rstrip("/api")


def get_experiment_url(dataset_name: str, experiment_id: str) -> str:
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The whole Experiment object could have been passed here since it contains all the necessary fields – dataset_name, client, and experiment ID.
This method could even be made a method of the "Experiment" class itself.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@japdubengsub Works as is, we can refactor this in the future if we keep it as is

scoring_metrics=[metrics.Equals()],
task_threads=1,
)
with mock.patch.object(
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just to point out, the test does not verify whether a notification was actually printed.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I didn't know how to add tests for it but I manually verified it works, we can add a test in the future if it fails

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

we can add this to our e2e flow later, when we do sdk check we fetch URL and open it + test data is there
@AndreiCautisanu FYI please add to backlog

Nimrod007
Nimrod007 previously approved these changes Oct 7, 2024
@jverre jverre merged commit b8557b2 into main Oct 7, 2024
21 checks passed
@jverre jverre deleted the jacques/add-experiment-message branch October 7, 2024 16:34
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants