You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The issue is when you make a typo somewhere, then the error message is kind of misleading:
typo in the deploy function name:
$ pyinfra @local mysetup.mymodule:mydeploy_typo --debug
--> pyinfra error: No such attribute in module pyinfra.operations.mysetup.mymodule: mydeploy_typo
typo in the deploy module name:
$ pyinfra @local mysetup.mymodule_typo:mydeploy --debug
--> pyinfra error: No such module: pyinfra.operations.mysetup.mymodule_typo
forgotten deploy function name (not sure it's allowed though, but still, the error is kinda confusing):
$ pyinfra @local mysetup.mymodule --debug
--> pyinfra error: No such attribute in module pyinfra.operations.mysetup: mymodule
Seems like everything you pass gets prefixed with pyinfra.operations, creating a false impression pyinfra cli only supports builtin operations.
I debugged a bit and seems like it happens because in try_import_module_attribute. prefix is equal to pyinfra.operations, so it always gets appended to possible_modules. Later, the CliError only includes the last of possible_modules, so whatever you passed to pyinfra is going to get prefixed with pyinfra.operations.
Expected behavior
Perhaps the error needs to include all candidates so it's a bit more obvious what's going on? Happy to do a PR if it's welcome!
Describe the bug
I have the following package structure for my deploys:
It works great when I invoke it via pyinfra cli!
Misleading error message
The issue is when you make a typo somewhere, then the error message is kind of misleading:
Seems like everything you pass gets prefixed with
pyinfra.operations
, creating a false impression pyinfra cli only supports builtin operations.I debugged a bit and seems like it happens because in try_import_module_attribute.
prefix
is equal topyinfra.operations
, so it always gets appended topossible_modules
. Later, theCliError
only includes the last ofpossible_modules
, so whatever you passed to pyinfra is going to get prefixed withpyinfra.operations
.Expected behavior
Perhaps the error needs to include all candidates so it's a bit more obvious what's going on? Happy to do a PR if it's welcome!
Meta
pyinfra --support
.-vv
and--debug
.The text was updated successfully, but these errors were encountered: