-
Notifications
You must be signed in to change notification settings - Fork 24
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
Feature/refactor backend tests env dependency #72
Feature/refactor backend tests env dependency #72
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.
Looks great Harry! I've asked a couple of questions, thanks
backend/src/agents/__init__.py
Outdated
return {"name": agent.name, "description": agent.description} | ||
|
||
|
||
agents = [DatastoreAgent(config.datastore_agent_llm), MathsAgent(config.maths_agent_llm)] | ||
agents_details = [get_agent_details(agent) for agent in agents] | ||
def get_question_agents() -> List[Agent]: |
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 wonder if the name question_agents is too vague, could it be something like available_agents?
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.
yeah I like available_agents, will change to that
@@ -24,8 +26,9 @@ def test_get_agent_for_task_no_agent_found(mocker): | |||
|
|||
def test_get_agent_for_task_agent_found(mocker): | |||
plan = {"agent_name": mock_agent_name} | |||
mocker.patch("src.router.agents", mock_agents) | |||
mocker.patch("src.router.llm", mock_model) | |||
mocker.patch("src.router.get_llm", return_value=mock_model) |
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.
Just so I understand, we're not actually using the get_llm function which needs the env file, instead we're instantiating a mock value for llm with 'mockllm' on line 8?
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.
Actually, this is a little confusing, I'll change. Yes, the test is mocking out get_llm
so that whenever it is called during the test, the mock_model on line 8 will always be returned. The confuding part is that line 8 is actually using get_llm
to get the mock model. It would make more sense if line 8 was:
mock_model = MockLLM()
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.
Ah yes okay, thanks that makes sense
.github/workflows/test-backend.yml
Outdated
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.
@harryBedfordSL - I am unable to test it locally. Even after renaming the .env file locally, all the tests are running in my other branch and according to you they should fail without all the changes in this PR, so not sure how to test this one.
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.
Happy with the changes.
Description
This PR removes the dependency that our tests have on the .env file. This arose from certain imports causing files to run that were making use of env variables. My understanding is that this is a compile time issue. So, the change has been to make sure that wherever the env variables are used, it is at run time, and not compile time. For example, using getters for the agents instead of instantiating them in the init file.
Changelog