Deleted .py file causing builds to fail when using cache in python project


#1

I had a model.py file in a certain directory in the past, which was renamed.
If that file exists, the build fails, as the “proper” model.py exists in a separate directory.
Somehow it seems that a “zombie” version (in python those are usually .pyc files) of that file is there as I get an import error when running the tests:

  File "/root/delta/transfers/action_controller.py", line 8, in <module>
    from models import Account
ImportError: cannot import name Account

I am certain the Account class exists in in the “proper” models.py, as rebuilding disabling cache results in a successful build.

I already tried changing my requirements.txt which forces a new cache to be created, but the problem somehow returned after a few builds.

The file models.py is not in any of the directories that are cached, so it shouldn’t affect the cache of future builds.

Is there a way I can guarantee there’s no .pyc files from previous builds in the container running my builds?


#2

The problem was indeed in our code.

cannot import name Account

was actually referring to a cyclic dependency, which is a bug in our code.
The weird thing is that depending on the thread order the bug would sometimes not happen.
And when running the tests locally the bug would never happen.
Anyway, once I was able to reproduce the problem locally, it was an easy fix.


#3

This topic was automatically closed 41 days after the last reply. New replies are no longer allowed.