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

Moved flush to after_call #354

Merged
merged 2 commits into from
Oct 7, 2024
Merged

Conversation

dsblank
Copy link
Contributor

@dsblank dsblank commented Oct 4, 2024

Details

This PR adds @track(flush=True) so that you don't have to do it manually after the function has been called.

Before:

from opik import track, flush_tracker

@track()
def streaming_function(input):
    messages = [{"role": "user", "content": input}]
    response = framework.completion(
        model="gpt-3.5-turbo",
        messages=messages,
    )
    return response
streaming_function("Why?")
flush_tracker()

After:

from opik import track

@track(flush=True)
def streaming_function(input):
    messages = [{"role": "user", "content": input}]
    response = framework.completion(
        model="gpt-3.5-turbo",
        messages=messages,
    )
    return response
streaming_function("Why?")

Issues

None, except for adding some convenience.

Testing

No tests added.

Documentation

Docstring for flush added.

@dsblank dsblank requested a review from a team as a code owner October 4, 2024 18:55
@dsblank dsblank self-assigned this Oct 4, 2024
@dsblank dsblank added the enhancement New feature or request label Oct 4, 2024
@jverre
Copy link
Collaborator

jverre commented Oct 4, 2024

This look good to me, thanks :) Let's wait for @japdubengsub to review and approve before we merge

@dsblank Do you think we should update the docs ? Could be good to add a paragraph in the log_traces page

@dsblank dsblank force-pushed the dsb/flush-as-track-argument-after-call branch from d8e0889 to a210760 Compare October 4, 2024 21:31
Copy link
Contributor

@japdubengsub japdubengsub left a comment

Choose a reason for hiding this comment

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

Unfortunately, I wasn't part of the initial discussion on this task since I joined the project a bit later, so I might be slightly out of context.
Everything looks okay!
My only concern is that this might negatively impact batching mode. However, since both this mode and batching are disabled by default, there shouldn't be any significant issues. :)

Copy link
Collaborator

@andrescrz andrescrz left a comment

Choose a reason for hiding this comment

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

Can you add tests?

@dsblank dsblank force-pushed the dsb/flush-as-track-argument-after-call branch from a210760 to fb56267 Compare October 7, 2024 13:45
@dsblank
Copy link
Contributor Author

dsblank commented Oct 7, 2024

@andrescrz, I can't find a test of tracker.flush_tracker and I don't have enough information to test it myself. Can you point me to something that I could use as a base to copy?

@dsblank dsblank force-pushed the dsb/flush-as-track-argument-after-call branch from fb56267 to 71ccdb2 Compare October 7, 2024 16:04
@dsblank dsblank force-pushed the dsb/flush-as-track-argument-after-call branch from 71ccdb2 to dff22c4 Compare October 7, 2024 18:04
@jverre jverre merged commit 21215ad into main Oct 7, 2024
21 checks passed
@jverre jverre deleted the dsb/flush-as-track-argument-after-call branch October 7, 2024 18:09
@andrescrz
Copy link
Collaborator

@andrescrz, I can't find a test of tracker.flush_tracker and I don't have enough information to test it myself. Can you point me to something that I could use as a base to copy?

As discussed offline, this was tested manually prior to merge, so it's fine to go from my end. We can add a test if any issue or at a later stage.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants