Page MenuHome

Deleting the cache directory (Clean up)
Needs ReviewPublic

Authored by Himanshi Kalra (calra) on Mar 2 2021, 8:15 PM.

Details

Summary

Problem:
Dynamic Paint creates a cache directory in the lib/physics folder which is versioned by SVN.

Solution:
Deleting the cache directory every time the tests are run.

Changes:
Adding a new _blendcache_cleanup function to delete the cache directory (byproduct of baking).

Diff Detail

Repository
rB Blender
Branch
blendcache_dir (branched from master)
Build Status
Buildable 13203
Build 13203: arc lint + arc unit

Event Timeline

Himanshi Kalra (calra) requested review of this revision.Mar 2 2021, 8:15 PM
Himanshi Kalra (calra) created this revision.
Himanshi Kalra (calra) edited the summary of this revision. (Show Details)
  • Calling the cleanup function right after baking

I'd prefer if it didn't write to the version controlled folders at all (we could run a file->save_as before starting the bake i suppose?), but i'll take what i can get

tests/python/modules/mesh_test.py
355

if this raises an exception, cleanup won't happen. Probably unlikely to happen but this is a test suite so... Maybe it's better to do cleanup in __del__() method?

One more question. I'm not very familiar with baking modifiers, but you want to change a frame later to do comparison, will this affect it in some way (e.g. make test slower, or even generate cache again)?

Lets go on the assumption that when the test fails, it will bring down the blender process and the cleanup may not be called at all.

still feels like we're making it much more difficult than it ought to be a simple bpy.ops.wm.save_as_mainfile to the folder blender is in would sidestep all of this

  • Calling the destructor after comparison before test checking

(we could run a file->save_as before starting the bake i suppose?)

We could save the blend file at another place, perform bake and testing on it, copy the file back if/when its updated. Hmm, this solution feels more hackier than the current one. A simpler approach would be to expose/create the python api for cache directory, I will try to look into it soon.

tests/python/modules/mesh_test.py
355

Yes I shifted it back again in the run_test method. Letting it get compared first before deleting. Deleting the cache right after baking was a bad idea.

Could we just ignore blender cache files in SVN the same way we ignore python __pycache__ in git?

tests/python/modules/mesh_test.py
616–617

Oh this is not exactly what I meant. Defining __del__ above should be enough. It should get called automatically when MeshTest instance is not needed anymore, the same way you don't call __init__ explicitly anywhere. So I thought cleaning up in MeshTest is fine.

  • Removing the explicit call for destructor
Himanshi Kalra (calra) marked 2 inline comments as done.Mar 3 2021, 11:04 AM