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 failing test #195

Merged
merged 12 commits into from
Apr 3, 2024
Merged

Fix failing test #195

merged 12 commits into from
Apr 3, 2024

Conversation

johnjosephhorton
Copy link
Contributor

@johnjosephhorton johnjosephhorton commented Apr 3, 2024

There were a few issues:

  1. We needed to add to Jobs.py code to create the ".edsl_cache.db"
  2. The "store" command for cache entry was converting parameters to string (which was stopping job running)
  3. Job running fails "show up" in this interview test failure because jobs that are failing for any reason (such as above) cause this test to fail- it's a bit complex and hard to explain. We probably need to re-factor this to show these early exceptions as these are now hard to debug.

@ellipsis - can you summarize code changes?


Ellipsis 🚀 This PR description was created by Ellipsis for commit b36628e.

Summary:

This PR addresses several issues, makes improvements to the Cache and CacheEntry classes, updates corresponding test files, and modifies the CacheEntry class to correctly handle parameters in the cache entry key generation.

Key points:

  • Improved the Cache and CacheEntry classes by adding type hints, improving docstrings, refactoring some methods.
  • Fixed issues with the 'Jobs.py' code and the 'store' command for cache entry.
  • Addressed job running failures.
  • Updated test_CacheEntry.py and test_LanguageModel.py to reflect changes in the main codebase.
  • Modified gen_key method in CacheEntry class to convert parameters to a JSON string before generating the key.
  • Updated expected keys in test_CacheEntry_gen_key and test_CacheEntry_key_property tests to reflect the change in key generation.

Generated with ❤️ by ellipsis.dev

Copy link
Contributor

@ellipsis-dev ellipsis-dev bot left a comment

Choose a reason for hiding this comment

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

❌ Changes requested.

  • Reviewed the entire pull request up to 3e6ce60
  • Looked at 1271 lines of code in 4 files
  • Took 3 minutes and 47 seconds to review
More info
  • Skipped 0 files when reviewing.
  • Skipped posting 3 additional comments because they didn't meet confidence threshold of 50%.
1. edsl/data/Cache.py:684:
  • Assessed confidence : 100%
  • Grade: 30%
  • Comment:
    The __eq__ method should also check if the corresponding values of the keys are equal. Consider changing it to:
return self.data.keys() == other_cache.data.keys() and all(self.data[key] == other_cache.data[key] for key in self.data.keys())
  • Reasoning:
    In the Cache.py file, the __eq__ method of the Cache class is only checking if the keys of the data dictionaries of the two Cache instances are equal. It should also check if the corresponding values (CacheEntry objects) are equal.
2. edsl/data/CacheEntry.py:103:
  • Assessed confidence : 100%
  • Grade: 0%
  • Comment:
    The __eq__ method should check if the other object is an instance of CacheEntry before accessing its attributes to avoid an AttributeError.
if not isinstance(other, CacheEntry):
    return False
return all(getattr(self, field) == getattr(other, field) for field in self.all_fields if field != 'timestamp')
  • Reasoning:
    In the CacheEntry.py file, the __eq__ method of the CacheEntry class is not checking if the other object is an instance of CacheEntry before accessing its attributes. This could lead to an AttributeError if the other object is not an instance of CacheEntry.
3. edsl/data/CacheEntry.py:165:
  • Assessed confidence : 100%
  • Grade: 0%
  • Comment:
    The store_input_example method should also remove the 'output' key from the dictionary to avoid confusion.
input = cls.example().to_dict()
_ = input.pop('timestamp')
_ = input.pop('output')
input['response'] = input.pop('output')
return input
  • Reasoning:
    In the CacheEntry.py file, the store_input_example method of the CacheEntry class is popping the 'timestamp' key from the input dictionary and adding a 'response' key. However, it is not removing the 'output' key. This could lead to confusion as both 'response' and 'output' keys would be present in the dictionary.

Workflow ID: wflow_DO63dc26mgGEi1sU


Want Ellipsis to fix these issues? Tag @ellipsis-dev in a comment. We'll respond in a few minutes. Learn more here.

return False
return self.data.keys() == other_cache.data.keys()

def __add__(self, other: "Cache"):
Copy link
Contributor

Choose a reason for hiding this comment

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

The __add__ method is modifying the current instance. It should return a new instance with the combined data. Consider changing it to:

Suggested change
def __add__(self, other: "Cache"):
new_cache = Cache()
new_cache.data = self.data.copy()
new_cache.data.update(other.data)
return new_cache

Copy link
Contributor Author

Choose a reason for hiding this comment

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

This is an interesting suggestion, @ellipsis, but this would make a new Cache w/o a sqlite backend. We need to think about this one more. Might just not allow __ add __ here

Copy link
Contributor

Choose a reason for hiding this comment

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

I was in the process of addressing the reviewer's comment about the __add__ method in the Cache class. The reviewer suggested that this method might not be necessary in this context. Therefore, I was planning to remove this method from the class. However, I ran out of time before I could make this change. I would appreciate any feedback or suggestions on how to proceed. Thank you!


Responding to this comment by @johnjosephhorton. For more information about Ellipsis, check the documentation.

edsl/data/CacheEntry.py Outdated Show resolved Hide resolved
Copy link
Contributor

@ellipsis-dev ellipsis-dev bot left a comment

Choose a reason for hiding this comment

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

👍 Looks good to me!

  • Performed an incremental review on de65a5b
  • Looked at 13 lines of code in 1 files
  • Took 50 seconds to review
More info
  • Skipped 0 files when reviewing.
  • Skipped posting 1 additional comments because they didn't meet confidence threshold of 50%.
1. tests/language_models/test_LanguageModel.py:129:
  • Assessed confidence : 0%
  • Comment:
    This change seems to be fixing a test case where the 'parameters' attribute was previously being compared as a string, but now it's being compared as a dictionary. This change seems to be in line with the PR description where it was mentioned that the 'store' command for cache entry was converting parameters to string, which was causing issues. I don't see any obvious issues with this change.
  • Reasoning:
    The change in the test file seems to be fixing a test case where the 'parameters' attribute was previously being compared as a string, but now it's being compared as a dictionary. This change seems to be in line with the PR description where it was mentioned that the 'store' command for cache entry was converting parameters to string, which was causing issues. I don't see any obvious issues with this change.

Workflow ID: wflow_KFPlfAiFQ98EJbyB


Not what you expected? You can customize the content of the reviews using rules. Learn more here.

johnjosephhorton and others added 2 commits April 2, 2024 22:07
Co-authored-by: ellipsis-dev[bot] <65095814+ellipsis-dev[bot]@users.noreply.github.com>
Copy link
Contributor

@ellipsis-dev ellipsis-dev bot left a comment

Choose a reason for hiding this comment

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

❌ Changes requested.

  • Performed an incremental review on b36628e
  • Looked at 41 lines of code in 2 files
  • Took 1 minute and 48 seconds to review
More info
  • Skipped 0 files when reviewing.
  • Skipped posting 1 additional comments because they didn't meet confidence threshold of 50%.
1. tests/data/test_CacheEntry.py:49:
  • Assessed confidence : 0%
  • Comment:
    The test cases have been updated correctly to reflect the changes in the 'gen_key' method.
  • Reasoning:
    The test cases in 'test_CacheEntry.py' have been updated to reflect the changes in the 'gen_key' method. The expected keys in 'test_CacheEntry_gen_key' and 'test_CacheEntry_key_property' have been updated correctly. No issues found here.

Workflow ID: wflow_BxqsPi91EezeyINQ


Want Ellipsis to fix these issues? Tag @ellipsis-dev in a comment. We'll respond in a few minutes. Learn more here.

Generates a key for the cache entry.
- Treats single and double quotes as the same. TODO: add more robustness.
"""
#long_key = f"{model}{parameters}{system_prompt}{user_prompt}{iteration}"
Copy link
Contributor

Choose a reason for hiding this comment

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

Please remove the commented out line of code for better code readability.

@johnjosephhorton
Copy link
Contributor Author

Ok @apostolosfilippas this should fix that issue you had. It does surface a bigger issue we have in the unit testing, re: failures caused by "simple"bugs that only show up in the Interview test in this fairly cryptic way

@apostolosfilippas apostolosfilippas merged commit 1aa89bc into main Apr 3, 2024
6 checks passed
@johnjosephhorton johnjosephhorton deleted the fix_failing_test branch April 3, 2024 10:22
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