Description
What: Within the model adapter, DRUM asserts that there can be only one custom.py
file within the code folder.
Here is the snippet at line 139:
def load_custom_hooks(self):
custom_file_paths = list(Path(self._model_dir).rglob("{}.py".format(CUSTOM_FILE_NAME)))
assert len(custom_file_paths) <= 1
the problem lies with the rglob
function on a path. The full recursive search for custom.py
means the the system will search. all subdirectories in the code folder and find any custom.py
file. Several major python packages include a custom.py
for other reasons and those files are found within the virtual environment folder.
When multiple custom.py
files are found, the assertion on line 139 will fail throwing an error.
Example
The openpyxl has several files named custom.py
and those all get captured if your virtual environment is part of the code folder.
Here is a look at custom_file_paths
in a debugger.
The assertion will then fail.
I believe that I adopt a fairly common practice of having my virtual environment in my code folder and adding the environment to .gitignore
solution
I think changing rglob
to glob
will fix this issue. I have tested this locally but I am not able to install all the prerequisites for running the test suite so I can't submit a branch.