Bug in the Hailo SDK code

I am trying to compile an HEF model.
I am just running these two lines

runner = ClientRunner(har=har_file, hw_arch=hw_arch)
    hef_data = runner.compile()

It is crashing during compile, and giving me the error

[error] TypeError: expected str, bytes or os.PathLike object, not NoneType

With debugging, I can see that the problem happens here in hailo’s source code for hailo_tools_runner.py

def run_hailo_tools(tool_args, exe_name, client=None, server=None, builder_pb_input=None):
    hailo_tools_path = SDKPaths().join_hailo_tools_path("build/" + exe_name)
    return run_tool_from_binary(
        hailo_tools_path,
        tool_args,
        client=client,
        server=server,
        builder_pb_input=builder_pb_input,
    )

The problem is that the line hailo_tools_path = SDKPaths().join_hailo_tools_path("build/" + exe_name) is evaluating to None.
So why is this?
Well, let’s dig a bit deeper, and have a look at the SDKPaths class.
I has this method
It calls this method

def join_hailo_tools_path(self, path):
        if self.is_internal:
            hailo_sdk_internals = pkgutil.get_loader("hailo_sdk_internals")
            package_dir = os.path.dirname(os.path.dirname(os.path.dirname(hailo_sdk_internals.get_filename())))
            return os.path.join(package_dir, "sdk_server", "hailo_tools", path)

        if self.is_release:
            hailo_sdk_common = pkgutil.get_loader("hailo_sdk_common")
            return os.path.join(os.path.dirname(os.path.dirname(hailo_sdk_common.get_filename())), "hailo_tools", path)

It basically it checks if self.is_internal and checks if self.is_release. In my case, both are False, so it returns None, and breaks the code!!!
(@hailo error handling would be nice!)

Ok so why is it returning None? I would expect .is_release to be True.
Well, as you see here, it decides whether it is a release or internal in this code

class SDKPaths(with_metaclass(Singleton, object)):
    HAILO_TEMP_DIR_PREFIX = "hailo"
    DEFAULT_BUILD_DIR = "build"

    def __init__(self):
        self._build_dir = type(self).DEFAULT_BUILD_DIR
        self._custom_build_dir = None
        self._has_graphviz = True

        hailo_sdk_common = pkgutil.get_loader("hailo_sdk_common")
        self._is_release = "site-packages" in os.path.dirname(os.path.dirname(hailo_sdk_common.get_filename()))
        self._is_internal = pkgutil.get_loader("hailo_sdk_internals") is not None

It basically says, if the package was installed in the folder ‘site-packages’ then it must be a release.

However, Ubuntu does not install it in site-packages unless you are installing it inside a virtual env. But the docs to not say you MUST install in a venv. they only recommend it. Since i am isolating my environment by putting everything in a docekr container, I decided not to use venv. Whoops! that breaks everything!

@hailo, please fix the code so that this is possible, or at the very least, gives some sensible error message.

Hey @mgreiner79,

This is excellent work, thanks for reporting this issue. I’m looking into it now and will escalate it to R&D for further investigation. We’ll keep you updated on the progress.

In the meantime, have you found any workarounds? Based on your analysis, I see a few potential temporary solution:

  • Ensure your installation puts components into site-packages( can be done in docker)

Let me know if you’ve tried any of these approaches or if you’ve discovered another solution. Your detailed breakdown of the root cause is extremely helpful for our team.

Hi @omria,
Thank you for dealing with this. My work around was to create a virtual environment on the Docker image, with this line in my Dockerfile
‘ RUN python3.10 -m venv /venv &&
ls -l /venv’
Then make sure the Docker’s entry point uses the venv with this line in my Dockerfile
‘ENV VIRTUAL_ENV=/venv’

Then, when I pip install, the dependencies are installed in the place where Hailo expects them.