Download test_agents.py from VAH6002/TFA: direct link, hf CLI and curl.
- Browser
- Download file 2.37 kB
-
https://huggingface.co/spaces/VAH6002/TFA/resolve/main/test_agents.py
- Command line
-
hf download hf://spaces/VAH6002/TFA/test_agents.py
-
curl -L -o test_agents.py https://huggingface.co/spaces/VAH6002/TFA/resolve/main/test_agents.py
2.37 kB
| """Test TFA Agents with Google ADK and mock data.""" | |
| import asyncio | |
| import os | |
| # Set a dummy API key for testing (agents won't actually call Gemini with mock data) | |
| # In production, set GOOGLE_API_KEY or use application default credentials | |
| os.environ.setdefault("GOOGLE_API_KEY", "test-key-for-mock") | |
| from tfa_agents.tools.sponge_mock import use_mock_client | |
| from tfa_agents import TFARunner | |
| async def test_tfa_pipeline(): | |
| """Test the full TFA pipeline with mock data.""" | |
| print("\n" + "=" * 70) | |
| print("TFA Agent Pipeline Test with Mock Data") | |
| print("=" * 70) | |
| # Configure mock client | |
| use_mock_client("code_regression") | |
| print("\nβ Mock client configured for 'code_regression' scenario") | |
| # Create runner | |
| runner = TFARunner() | |
| print("β TFA Runner initialized") | |
| # Test parameters | |
| invocation_id = "fe3e0b7f-7bb9-4524-8a79-3c62cf028243" | |
| test_name = "//gmail/android/copycat:mark_multiple_emails_as_read" | |
| print(f"\nAnalyzing failure:") | |
| print(f" Invocation: {invocation_id}") | |
| print(f" Test: {test_name}") | |
| print("\nRunning TFA pipeline...") | |
| print("-" * 70) | |
| try: | |
| result = await runner.analyze_failure_async( | |
| invocation_id=invocation_id, | |
| test_name=test_name, | |
| ) | |
| print("\n" + "=" * 70) | |
| print("ANALYSIS RESULT:") | |
| print("=" * 70) | |
| print(result) | |
| except Exception as e: | |
| print(f"\nβ Error during analysis: {type(e).__name__}: {e}") | |
| raise | |
| def main(): | |
| """Run the test.""" | |
| print(""" | |
| ββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ | |
| β TFA (Test Failure Analysis) - Agent Pipeline Test β | |
| β Using Google ADK with Mock Sponge Data β | |
| ββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ | |
| """) | |
| asyncio.run(test_tfa_pipeline()) | |
| print("\nβ Test completed!") | |
| if __name__ == "__main__": | |
| main() | |