I was thinking about it and I think yes more or less what you said but even simpler by merging instead of replacing each entry at a time.
prepare the new registry dict as before
call merge_with_old_registry (new function which does):
a. Check if the old registry doesn’t exist return the new one
b. if it exists, load it and merge the new one onto old one (direction is important!) and return the resulting dict.
It should be a very compact 1-2 lines of list comprehension code by borrowing from clean_nb in tools/fastai-nbstripout
write the dict as before
So really, there is just an extra merge step.
And if we ever want to reset the registry to discard old entries, we just delete the registry file before running make test-full.
So it’s a very low-tech solution. The bonus is that we will be able to discard the special flag and test writers will get to update the registry right away.
Implementation-wise, It’s up to you, @Benudek - I thought you are taking time off so I wasn’t proposing anything for you, but if that has changed, you’re welcome to tackle this.
it fails in tests/test_gen_doc_nbtest.py::test_wrapped:
def lookup_db(elt)->List[Dict]:
"Finds `this_test` entries from test_api_db.json"
db_file = Path(abspath(join(dirname( __file__ ), '..')))/DB_NAME
if not db_file.exists():
> raise Error(f'Could not find {db_file}. Please make sure it exists at this location or run `make test`')
E NameError: name 'Error' is not defined
a chicken and egg problem there, since it requires the registry file to run make test (which generates it), and the latter shouldn’t depend on the former. It probably should skip that test dynamically if the file is not there.
Fixed on latest master - going to keep throwing an error for now until we know this module is a bit more stable.
I’d still like to know when db search fails
Oh, for sure, the check should stay there - Just needed it not to impact the test suite.
And since we have to revamp how the registry file is update (see comments above), being able to delete the registry and re-create it will become important.
The cool thing about the test registry is its unintentional features - I already found several tests that were testing the same thing in slightly different ways, so I merged them and as a result discovered a bug in fastai and a bug in our registry. Awesome!
Yeah none of it makes sense. I’ll just loop all of them into other.
Direct tests:
Looks to see if any def test_xxx: names contain the function name
test_DataBunch_xxx: -> matches DataBunch
test_DataBunch_oneitem -> matches DataBunch and DataBunch.oneitem
Related tests:
any time the function is called in the body