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

Avoid copying runs #26689

Merged
merged 13 commits into from
Sep 20, 2024
Merged

Avoid copying runs #26689

merged 13 commits into from
Sep 20, 2024

Conversation

hinthornw
Copy link
Collaborator

@hinthornw hinthornw commented Sep 20, 2024

Also, re-unify run trees. Use a single shared client. Etc.

Copy link

vercel bot commented Sep 20, 2024

The latest updates on your projects. Learn more about Vercel for Git ↗︎

1 Skipped Deployment
Name Status Preview Comments Updated (UTC)
langchain ⬜️ Ignored (Inspect) Visit Preview Sep 20, 2024 5:53pm

@dosubot dosubot bot added the size:L This PR changes 100-499 lines, ignoring generated files. label Sep 20, 2024
@dosubot dosubot bot added the Ɑ: core Related to langchain-core label Sep 20, 2024
@hinthornw hinthornw marked this pull request as draft September 20, 2024 01:14
@hinthornw hinthornw marked this pull request as ready for review September 20, 2024 02:52
@dosubot dosubot bot added community Related to langchain-community langchain Related to the langchain package 🤖:nit Small modifications/deletions, fixes, deps or improvements to existing code or docs labels Sep 20, 2024
@ccurme ccurme removed the langchain Related to the langchain package label Sep 20, 2024
def _start_trace(self, run: Run) -> None:
super()._start_trace(run)
if run._client is None:
run._client = self.client
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

This is so that if you were defining the client solely via a LangChainTracer we will hand off that client to the nested run tree

Copy link
Collaborator

Choose a reason for hiding this comment

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

any situations when one might create two tracers with different clients and pass them as callbacks?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Hmm.

This would still work in the case where it's all langchain code then.

This would not work for implicit propagation handoff to traceable (since traceable doesn't let you set multiple parents at a given time)

In either case I think that would be undesirable / haven't heard of anyone doing that before

Copy link
Collaborator

Choose a reason for hiding this comment

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

I assume no easy way to catch that as an issue to raise an error?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

hmm I kinda would prefer if we still traced something / didn't raise an error that could potentially interrupt their execution flow? It's kinda hard to catch correctly

@eyurtsev eyurtsev self-assigned this Sep 20, 2024
libs/community/pyproject.toml Show resolved Hide resolved
libs/core/langchain_core/runnables/config.py Outdated Show resolved Hide resolved
global _CLIENT
if _CLIENT is not None and _CLIENT.tracing_queue is not None:
_CLIENT.tracing_queue.join()
if rt._CLIENT is not None and rt._CLIENT.tracing_queue is not None:
Copy link
Collaborator

Choose a reason for hiding this comment

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

oh nice

def _start_trace(self, run: Run) -> None:
super()._start_trace(run)
if run._client is None:
run._client = self.client
Copy link
Collaborator

Choose a reason for hiding this comment

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

any situations when one might create two tracers with different clients and pass them as callbacks?

@dosubot dosubot bot added the lgtm PR looks good. Use to confirm that a PR is ready for merging. label Sep 20, 2024
@hinthornw hinthornw merged commit 19ce95d into master Sep 20, 2024
98 checks passed
@hinthornw hinthornw deleted the wfh/happyfamily branch September 20, 2024 17:57
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
community Related to langchain-community Ɑ: core Related to langchain-core lgtm PR looks good. Use to confirm that a PR is ready for merging. 🤖:nit Small modifications/deletions, fixes, deps or improvements to existing code or docs size:L This PR changes 100-499 lines, ignoring generated files.
Projects
Status: Done
Development

Successfully merging this pull request may close these issues.

3 participants