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

fix(examples): better error handling and other fixes #438

Merged
merged 8 commits into from
Mar 3, 2025

Conversation

ajbozarth
Copy link
Member

Which issue(s) does this pull-request address?

Ref #336

Description

Various improvements to existing examples:

  • Add better and more consistent error handling, this also cleans up pytest e2e output
  • set options.execution.max_iterations default to math.inf to match TS implementation
  • various "mypy" fixes (actually just PyCharm checker)
  • conditionally run watsonx and openai examples in pytest
  • fix pytest that was whacking the ollama env vars for future tests (like examples)

Checklist

Signed-off-by: Alex Bozarth <ajbozart@us.ibm.com>
@ajbozarth ajbozarth added bug Something isn't working python Python related functionality labels Mar 1, 2025
@ajbozarth ajbozarth self-assigned this Mar 1, 2025
@ajbozarth ajbozarth requested a review from a team as a code owner March 1, 2025 01:29
@ajbozarth
Copy link
Member Author

If I do any more work on existing examples this weekend I'll add here, otherwise I'll open separate PRs for new examples.

@ajbozarth
Copy link
Member Author

Also @Tomas2D the e2e tests are still failing, but in a smaller number now. The following examples fail intermittently when run (even outside pytest):

  • agents/simple.py
  • tools/duckduckgo.py
  • tools/openmeteo.py
  • workflows/multi_agents.py

The first three usually fail on ToolInput validation, but sometimes on the old LinePrefixParserError('The generated output does not adhere to the schema.\nNothing valid has been parsed yet!')

multi_agents.py sometimes also fails on Tool validation, but is generally still failing the same way as test_multi_agents_workflow_creation, which from a bit more testing seems to be at somewhat caused by the existence of multiple agents in the workflow.

Signed-off-by: Alex Bozarth <ajbozart@us.ibm.com>
Copy link
Contributor

@Tomas2D Tomas2D 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 move all try/except blocks within example body into the __main__ block?
It would be easier to read and generally look better in the docs (in the future we might stip the __main__ block entirely in the documentation)

@ajbozarth
Copy link
Member Author

Can you move all try/except blocks within example body into the main block?
@Tomas2D done, all examples now have the same __main__ with centralized error handling

Tomas2D
Tomas2D previously approved these changes Mar 3, 2025
Copy link
Contributor

@Tomas2D Tomas2D left a comment

Choose a reason for hiding this comment

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

Not sure whether sys.exit(e.explain()) is a good practise.

@ajbozarth
Copy link
Member Author

Not sure whether sys.exit(e.explain()) is a good practise

This was what was generally suggested on stack overflow, I had doubts at first too, but it works really well in practice

Signed-off-by: Alex Bozarth <ajbozart@us.ibm.com>
Signed-off-by: Alex Bozarth <ajbozart@us.ibm.com>
@ajbozarth ajbozarth merged commit 83f11b3 into i-am-bee:main Mar 3, 2025
2 checks passed
@ajbozarth ajbozarth deleted the examples branch March 3, 2025 19:51
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working python Python related functionality
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants