TexasInstruments / edgeai-tidl-tools

Edgeai TIDL Tools and Examples - This repository contains Tools and example developed for Deep learning runtime (DLRT) offering provided by TI’s edge AI solutions.
Other
121 stars 27 forks source link

Python DLR library prints an import message which breaks the setup script #43

Open edtamarin opened 1 year ago

edtamarin commented 1 year ago

Issue

When running the setup script, dlr v1.10 is installed. This version prints out an information message when the module is imported in the interpreter:

You acknowledge and agree that DLR collects the following metrics to help improve its performance.
By default, Amazon will collect and store the following information from your device:

record_type: <enum, internal record status, such as modelloaded, model>, arch: <string, platform architecture, eg 64bit>, osname: <string, platform os name, eg. Linux>, uuid: <string, one-way non-identifable hashed mac address, eg. 8fb35b79f7c7aa2f86afbcb231b1ba6e>,
dist: <string, distribution of os, eg. Ubuntu 16.04 xenial>, machine: <string, retuns the machine type, eg. x86_64 or i386>, model: <string, one-way non-identifable hashed model name, eg. 36f613e00f707dbe53a64b1d9625ae7d>

If you wish to opt-out of this data collection feature, please follow the steps below:

  1. Disable it with through code: from dlr.counter.phone_home import PhoneHome PhoneHome.disable_feature()
  2. Or, create a config file, ccm_config.json inside your DLR target directory path, i.e. python3.6/site-packages/dlr/counter/ccm_config.json. Then added below format content in it, {"enable_phone_home" : false}
  3. Restart DLR application.
  4. Validate this feature is disabled by verifying this notification is no longer displayed, or programmatically with following command: from dlr.counter.phone_home import PhoneHome PhoneHome.is_enabled() # false as disabled

This message is seen by the install script, which picks it up at the install location of the library and the following error is generated:

cp: cannot stat 'CALL': No such file or directory
cp: cannot stat 'HOME': No such file or directory
cp: cannot stat 'FEATURE': No such file or directory
cp: cannot stat 'ENABLED': No such file or directory
cp: cannot stat 'You': No such file or directory
cp: cannot stat 'acknowledge': No such file or directory
cp: cannot stat 'and': No such file or directory
cp: cannot stat 'agree': No such file or directory
cp: cannot stat 'that': No such file or directory
cp: cannot stat 'DLR': No such file or directory
cp: cannot stat 'collects': No such file or directory
cp: cannot stat 'the': No such file or directory
cp: cannot stat 'following': No such file or directory
cp: cannot stat 'metrics': No such file or directory
cp: cannot stat 'to': No such file or directory
cp: cannot stat 'help': No such file or directory
cp: cannot stat 'improve': No such file or directory
cp: cannot stat 'its': No such file or directory
cp: cannot stat 'performance.': No such file or directory
cp: cannot stat 'By': No such file or directory
cp: cannot stat 'default,': No such file or directory
cp: cannot stat 'Amazon': No such file or directory
cp: cannot stat 'will': No such file or directory
cp: cannot stat 'collect': No such file or directory
cp: cannot stat 'and': No such file or directory
cp: cannot stat 'store': No such file or directory
cp: cannot stat 'the': No such file or directory
cp: cannot stat 'following': No such file or directory
cp: cannot stat 'information': No such file or directory
cp: cannot stat 'from': No such file or directory
cp: cannot stat 'your': No such file or directory
cp: cannot stat 'device:': No such file or directory
cp: cannot stat 'record_type:': No such file or directory
cp: cannot stat '<enum,': No such file or directory
cp: cannot stat 'internal': No such file or directory
cp: cannot stat 'record': No such file or directory
cp: cannot stat 'status,': No such file or directory
cp: cannot stat 'such': No such file or directory
cp: cannot stat 'as': No such file or directory
cp: cannot stat 'model_loaded,': No such file or directory
cp: cannot stat 'model_>,': No such file or directory
cp: cannot stat 'arch:': No such file or directory
cp: cannot stat '<string,': No such file or directory
cp: cannot stat 'platform': No such file or directory
cp: cannot stat 'architecture,': No such file or directory
cp: cannot stat 'eg': No such file or directory
cp: cannot stat '64bit>,': No such file or directory
cp: cannot stat 'osname:': No such file or directory
cp: cannot stat '<string,': No such file or directory
cp: cannot stat 'platform': No such file or directory
cp: cannot stat 'os': No such file or directory
cp: cannot stat 'name,': No such file or directory
cp: cannot stat 'eg.': No such file or directory
cp: cannot stat 'Linux>,': No such file or directory
cp: cannot stat 'uuid:': No such file or directory
cp: cannot stat '<string,': No such file or directory
cp: cannot stat 'one-way': No such file or directory
cp: cannot stat 'non-identifable': No such file or directory
cp: cannot stat 'hashed': No such file or directory
cp: cannot stat 'mac': No such file or directory
cp: cannot stat 'address,': No such file or directory
cp: cannot stat 'eg.': No such file or directory
cp: cannot stat '8fb35b79f7c7aa2f86afbcb231b1ba6e>,': No such file or directory
cp: cannot stat 'dist:': No such file or directory
cp: cannot stat '<string,': No such file or directory
cp: cannot stat 'distribution': No such file or directory
cp: cannot stat 'of': No such file or directory
cp: cannot stat 'os,': No such file or directory
cp: cannot stat 'eg.': No such file or directory
cp: cannot stat 'Ubuntu': No such file or directory
cp: cannot stat '16.04': No such file or directory
cp: cannot stat 'xenial>,': No such file or directory
cp: cannot stat 'machine:': No such file or directory
cp: cannot stat '<string,': No such file or directory
cp: cannot stat 'retuns': No such file or directory
cp: cannot stat 'the': No such file or directory
cp: cannot stat 'machine': No such file or directory
cp: cannot stat 'type,': No such file or directory
cp: cannot stat 'eg.': No such file or directory
cp: cannot stat 'x86_64': No such file or directory
cp: cannot stat 'or': No such file or directory
cp: cannot stat 'i386>,': No such file or directory
cp: cannot stat 'model:': No such file or directory
cp: cannot stat '<string,': No such file or directory
cp: cannot stat 'one-way': No such file or directory
cp: cannot stat 'non-identifable': No such file or directory
cp: cannot stat 'hashed': No such file or directory
cp: cannot stat 'model': No such file or directory
cp: cannot stat 'name,': No such file or directory
cp: cannot stat 'eg.': No such file or directory
cp: cannot stat '36f613e00f707dbe53a64b1d9625ae7d>': No such file or directory
cp: cannot stat 'If': No such file or directory
cp: cannot stat 'you': No such file or directory
cp: cannot stat 'wish': No such file or directory
cp: cannot stat 'to': No such file or directory
cp: cannot stat 'opt-out': No such file or directory
cp: cannot stat 'of': No such file or directory
cp: cannot stat 'this': No such file or directory
cp: cannot stat 'data': No such file or directory
cp: cannot stat 'collection': No such file or directory
cp: cannot stat 'feature,': No such file or directory
cp: cannot stat 'please': No such file or directory
cp: cannot stat 'follow': No such file or directory
cp: cannot stat 'the': No such file or directory
cp: cannot stat 'steps': No such file or directory
cp: cannot stat 'below:': No such file or directory
cp: cannot stat '1.': No such file or directory
cp: cannot stat 'Disable': No such file or directory
cp: cannot stat 'it': No such file or directory
cp: cannot stat 'with': No such file or directory
cp: cannot stat 'through': No such file or directory
cp: cannot stat 'code:': No such file or directory
cp: cannot stat 'from': No such file or directory
cp: cannot stat 'dlr.counter.phone_home': No such file or directory
cp: cannot stat 'import': No such file or directory
cp: cannot stat 'PhoneHome': No such file or directory
cp: cannot stat 'PhoneHome.disable_feature()': No such file or directory
cp: cannot stat '2.': No such file or directory
cp: cannot stat 'Or,': No such file or directory
cp: cannot stat 'create': No such file or directory
cp: cannot stat 'a': No such file or directory
cp: cannot stat 'config': No such file or directory
cp: cannot stat 'file,': No such file or directory
cp: cannot stat 'ccm_config.json': No such file or directory
cp: cannot stat 'inside': No such file or directory
cp: cannot stat 'your': No such file or directory
cp: cannot stat 'DLR': No such file or directory
cp: cannot stat 'target': No such file or directory
cp: cannot stat 'directory': No such file or directory
cp: cannot stat 'path,': No such file or directory
cp: cannot stat 'i.e.': No such file or directory
cp: cannot stat 'python3.6/site-packages/dlr/counter/ccm_config.json.': No such file or directory
cp: cannot stat 'Then': No such file or directory
cp: cannot stat 'added': No such file or directory
cp: cannot stat 'below': No such file or directory
cp: cannot stat 'format': No such file or directory
cp: cannot stat 'content': No such file or directory
cp: cannot stat 'in': No such file or directory
cp: cannot stat 'it,': No such file or directory
cp: cannot stat '{"enable_phone_home"': No such file or directory
cp: cannot stat ':': No such file or directory
cp: cannot stat 'false}': No such file or directory
cp: cannot stat '3.': No such file or directory
cp: cannot stat 'Restart': No such file or directory
cp: cannot stat 'DLR': No such file or directory
cp: cannot stat 'application.': No such file or directory
cp: cannot stat '4.': No such file or directory
cp: cannot stat 'Validate': No such file or directory
cp: cannot stat 'this': No such file or directory
cp: cannot stat 'feature': No such file or directory
cp: cannot stat 'is': No such file or directory
cp: cannot stat 'disabled': No such file or directory
cp: cannot stat 'by': No such file or directory
cp: cannot stat 'verifying': No such file or directory
cp: cannot stat 'this': No such file or directory
cp: cannot stat 'notification': No such file or directory
cp: cannot stat 'is': No such file or directory
cp: cannot stat 'no': No such file or directory
cp: cannot stat 'longer': No such file or directory
cp: cannot stat 'displayed,': No such file or directory
cp: cannot stat 'or': No such file or directory
cp: cannot stat 'programmatically': No such file or directory
cp: cannot stat 'with': No such file or directory
cp: cannot stat 'following': No such file or directory
cp: cannot stat 'command:': No such file or directory
cp: cannot stat 'from': No such file or directory
cp: cannot stat 'dlr.counter.phone_home': No such file or directory
cp: cannot stat 'import': No such file or directory
cp: cannot stat 'PhoneHome': No such file or directory
cp: cannot stat 'PhoneHome.is_enabled()': No such file or directory
cp: cannot stat '#': No such file or directory
cp: cannot stat 'false': No such file or directory
cp: cannot stat 'as': No such file or directory
cp: cannot stat 'disabled': No such file or directory

This prevents the libdlr.so file from being copied to the appropriate location.

Proposed solution

In the install script, replace

dlr_loc=$(python3  << EOF
import dlr 
print(dlr.__file__)
EOF
)

with

dlr_loc=$(python3 -W ignore -c "import sys,os; sys.stdout = open(os.devnull, 'w'); import dlr; sys.stdout = sys.__stdout__; print(dlr.__file__)")

This solution temporarily blocks printing to stdout while dlr is imported and prevents the import message from being parsed in the install script.