-
Notifications
You must be signed in to change notification settings - Fork 20
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
feat: Make Mistral ai instrumentation read context attributes #420
feat: Make Mistral ai instrumentation read context attributes #420
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Rather than changing every test case to use using_attributes
, can we add one new test case and name it appropriately?
I want to test all the scenarios. sync, async, with tools, without, etc. |
def _check_context_attributes( | ||
attributes: Dict[str, Any], | ||
session_id: str, | ||
user_id: str, | ||
metadata: Dict[str, Any], | ||
tags: List[str], | ||
) -> None: | ||
assert attributes.pop(SESSION_ID, None) == session_id | ||
assert attributes.pop(USER_ID, None) == user_id | ||
attr_metadata = attributes.pop(METADATA, None) | ||
assert attr_metadata is not None | ||
assert isinstance(attr_metadata, str) # must be json string | ||
metadata_dict = json.loads(attr_metadata) | ||
assert metadata_dict == metadata | ||
attr_tags = attributes.pop(TAG_TAGS, None) | ||
assert attr_tags is not None | ||
assert len(attr_tags) == len(tags) | ||
assert list(attr_tags) == tags |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
it's a best practice i try to follow to avoid abstraction as much as possible in test cases. duplication, especially of something like an assert statement, is very acceptable and even encouraged. the reason being that test cases need to be easy to understand because they need to point you to issues quickly, be stupidly easy to understand, and serve as documentation for other developers. i like the way they put it here: dry is for code, damp is for tests
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I agree in general but in this case we're testing, on each case, that the attributes match the fixtures. I do not see the benefit of expanding this until we want to make more complex combined tests. However, if it's a must, I can explode the helper function on each test
Definitely agree we should test sync and async, but I think these should be separate test cases. I'm not clear that this feature has any interaction with something like tool calls. They are orthogonal features, aren't they? I'd also mention that by adding Thinking of it another way, when a test fails, it ideally points you directly to the root cause of the failure. if every test case uses |
Thinking about this some more, I'm not even sure we necessarily need to explicitly test What if instead we just add one test to |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
approving based on the agreed-upon changes we discussed @fjcasti1 nice job 👍
No description provided.