Azure / autorest.az

Azure CLI Code Generator
MIT License
22 stars 20 forks source link

Log the importErrors instead of silently passing #878

Closed Mossaka closed 3 years ago

Mossaka commented 3 years ago

Please log the errors instead of silently passing them in __init__.py, action.py and custom.py because it is creating a log headache to debug issues with loading the extension wheels.

For example, in __init__.py, we are see

def load_command_table(self, args):
        from azext_mlv2.generated.commands import load_command_table

        load_command_table(self, args)
        try:
            from azext_mlv2.manual.commands import load_command_table as load_command_table_manual

            load_command_table_manual(self, args)
        except ImportError:
            pass
        return self.command_table

The issue is on this line except ImportError:: without logging/printing out the error messages, it is very hard for us to debug what went wrong with the imports. It easily took us one dev's day to debug it because all we are seeing from azure cli --debug is

cli.azure.cli.core.azclierror: 'ml' is misspelled or not recognized by the system.
az_command_data_logger: 'ml' is misspelled or not recognized by the system.

If you could change it to

except ImportError as e:
    logger.debug(e)

this will make debugging experience much easier!

The same suggestion applies to action.py and custom.py

from .generated.action import *  # noqa: F403

try:
    from .manual.action import *  # noqa: F403
except ImportError as e:
    logger.debug(e)
Mossaka commented 3 years ago

@kairu-ms gently ping

kairu-ms commented 3 years ago

@Mossaka it has been fixed in pre release version. Please add argument --use=https://github.com/Azure/autorest.az/releases/download/1.7.3-b.20210818.1/autorest-az-1.7.3.tgz and have a try. Thanks.