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

chore(weave): Add attributes to Call object and allow explicit root #1739

Merged
merged 15 commits into from
Jun 12, 2024

Conversation

tssweeney
Copy link
Contributor

@tssweeney tssweeney commented Jun 8, 2024

This PR supports the Langchain integration work and does two things:

  1. Makes sure the attributes payload is attached to the Calls (this is just good to do in general)
  2. Allows the user to explicitly force a root trace (as opposed to inheriting from context stack
  3. Moves parent to 3rd param and sets better default

@circle-job-mirror
Copy link

circle-job-mirror bot commented Jun 8, 2024

@tssweeney tssweeney marked this pull request as ready for review June 8, 2024 17:29
@tssweeney tssweeney requested a review from a team as a code owner June 8, 2024 17:29
op: Union[str, Op],
parent: Optional[Call],
inputs: dict,
attributes: dict = {},
Copy link
Contributor

Choose a reason for hiding this comment

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

Should avoid using a mutable object as a default value

Copy link
Contributor Author

Choose a reason for hiding this comment

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

fixed

inputs (dict): The inputs to the operation.
display_name (Optional[str], optional): The display name for the call. Defaults to None.
attributes (Optional[dict], optional): The attributes for the call. Defaults to None.
_use_stack (bool, optional): Whether to push the call onto the runtime stack. Defaults to True.
Copy link
Contributor

Choose a reason for hiding this comment

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

Why prefix with "_"? I think its just as obscure as "parent". I'd just call it "use_stack".

I think the docstring could cover both cases of stack use: If True, read parent from call_context, and push call onto call_context.

Should parent and use_stack be mutually exclusive? I mean should we throw an error if both are passed?

Ideally parent would have a default value of None and be moved to after inputs. This would mean we need to update positional callers, but that's probably not too bad right now since they're all in our codebase.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

removed underscore. I like to use that when the param is not something we want to be used externally and therefore have more liberties to change

Copy link
Contributor Author

Choose a reason for hiding this comment

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

we don't want mutual exclusivity. We want to be able to specify a parent and to not use the stack (this is the exact case in Langchain integration)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

moved parent to 3rd

) -> Call:
"""Create, log, and push a call onto the runtime stack.
Copy link
Contributor

Choose a reason for hiding this comment

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

Since you're adding the docstring, I'm going to review it.

Style: Please use the style in api.py for publish. My little doc generator script expects that style and I made some decisions in choosing it. In particular, don't put the type next to the parameter. The type information is already annotated in the function signature, no need to reproduce it.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

fixed

"""Create, log, and push a call onto the runtime stack.

Args:
op (Union[str, Op]): The operation to log.
Copy link
Contributor

Choose a reason for hiding this comment

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

The Op that this is a call for. If a string is passed, a code-less op will be created using "op" as the id.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

fixed

@tssweeney tssweeney merged commit bdf9a93 into master Jun 12, 2024
24 checks passed
@tssweeney tssweeney deleted the tim/add_support_for_explicit_root_and_attributes branch June 12, 2024 17:36
@github-actions github-actions bot locked and limited conversation to collaborators Jun 12, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants