Skip to content

Added testing for saving - #78

Merged
eharpste merged 11 commits into
apprenticelearner:masterfrom
rachwei:master
Jul 7, 2021
Merged

eharpste merged 11 commits into
apprenticelearner:masterfrom
rachwei:master

Conversation

@rachwei

@rachwei rachwei commented Jun 14, 2021

Copy link
Copy Markdown

No description provided.

eharpste and others added 10 commits December 9, 2020 18:41
Created simple tests for ModularAgent to test every supposedly legal agent configuration. Some are currently broken.
Excessive print statements were making it hard to read test output.
Fixed up some tests so that the majority of the configurations now pass the basic test.
Needed to fix a relative pathing issue with loading testing files.
It looked like specifictogeneral is universally broken for the fo_planner right now so I have removed it from the test profile in the interest of commiting a full pass test suite to check coverage reports.
Changes to re-enable saving had not be properly migrated after adding tests for saving. As far as I can tell they seem to work though may still have issues with different kinds of operations in learned skills.

@eharpste eharpste left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Took a pass through the new test_save. I added several comments for removing redundant tests and generally cleaning up the file. I'm already actively working on making the needed changes on my copy of the branch so don't worry about following up.

Comment thread tests/test_save.py Outdated
#ModularAgent()-- then request, train, give answers when dont know what to do
#when guesses and correct -- look same as when agent asks for hint and gets hint back-- reward should be 1
#needs value + cntentEditable
def test_FO_ModularAgent():

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

It looks like this only tests a single configuration of an FO_Planner based agent rather than all configurations like the numbert one. Even if some of these configurations fail we'll want to know. Ideally this test case would be a parallel of the ModularAgent one.

Comment thread tests/test_save.py Outdated

#check that copy is the same
dc = copy.deepcopy(resp)
assert(dc == resp)

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

This check seems like an unnecessary test since its just confirming the behavior of the external deepcopy library working on a built in dictionary type.

Comment thread tests/test_save.py Outdated
assert(agent.__dict__['epsilon'] == 100)
agent_stream = dill.dumps(agent)
agent_deserialized = dill.loads(agent_stream)
assert(agent_deserialized.__dict__['epsilon'] == 100)

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Not sure we need these final checks, since they are mainly checking against a possible language feature that doesn't exist.

Comment thread tests/test_save.py Outdated
for common in to_find_common:
assert(agent1dict[common] == agent2dict[common])

#checking rhs_by_how

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Would be great to remove a lot of this dead code.

Comment thread tests/test_save.py Outdated
resp, ans = train_A_req_A(agent)
assert resp['selection'] == ans['selection']
assert resp['action'] == ans['action']
assert str(int(resp['inputs']['value'])) == ans['inputs']['value']

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

I could see removing the asserts above as they duplicate the tests done in the configuration test. Not necessarily a bad thing to have duplicate tests but don't want to piss off our CI provider with unnecessary processing.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Note you probably still need to call the train function, just not assert the result.

Comment thread tests/test_save.py Outdated
@@ -0,0 +1,250 @@
# try: # python 3
# from apprentice_learner.models import Agent
# except ImportError: # python 2

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

No need for this as we don't support python 2 actively.

Comment thread tests/test_save.py
from apprentice.agents.ModularAgent import ModularAgent
from apprentice.agents.WhereWhenHowNoFoa import WhereWhenHowNoFoa
from apprentice.working_memory.representation import Sai
import dill

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

This is a style note but external imports should come before internal ones.

Removed redundant tests and tests that were only evaluating behavior of external libraries not related to our code.
Fixed up the fo_planner test so that is equivalent to the numbert one, with the caveat that it does not verify structural equivalence because of lambdas.
Removed dead code and cleaned up code style to bring it closer to PEP 8 spec.

@eharpste eharpste left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

I've gone through the new files and added changes that mostly clean up the code and better address some of our testing needs.

@eharpste
eharpste merged commit a80ea68 into apprenticelearner:master Jul 7, 2021
This was referenced Jul 7, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants