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
I have set up a Click CLI for my team that lazily loads commands, which is going to be very useful for scaling up how many commands our team can add to the tool without slowing the whole thing down. However, it doesn't seem to work with Trogon, which I'd very much like to give us the option of using.
The way this works for us mechanically is somewhat custom, though recommended by the Click documentation. Essentially, instead of loading python modules containing commands thru imports, we load them dynamically when the command or its info is needed. This LazyCommand class is a dummy wrapper around the real command, and only knows the command's name and short_help.
It looks like from the code (looking at introspect.py), Trogon obtains info about the Click command/group objects from their fields, not from their getter functions. Lazy loading relies on these getter functions being called to know when it needs to actual load the module and supply correct information about the command.
I'm thinking instead of accessing the Click command's fields directly to instead call the to_info_dict function , which seems to return all necessary info, and is interceptible by lazy loading. Or at least call it once so that lazy loading can work
I do have concerns though that the Trogon app might load every command and its info all at once anyway instead of doing so lazily, which would somewhat defeat the point...
The text was updated successfully, but these errors were encountered:
I have set up a Click CLI for my team that lazily loads commands, which is going to be very useful for scaling up how many commands our team can add to the tool without slowing the whole thing down. However, it doesn't seem to work with Trogon, which I'd very much like to give us the option of using.
The way this works for us mechanically is somewhat custom, though recommended by the Click documentation. Essentially, instead of loading python modules containing commands thru imports, we load them dynamically when the command or its info is needed. This
LazyCommand
class is a dummy wrapper around the real command, and only knows the command's name andshort_help
.It looks like from the code (looking at
introspect.py
), Trogon obtains info about the Click command/group objects from their fields, not from their getter functions. Lazy loading relies on these getter functions being called to know when it needs to actual load the module and supply correct information about the command.I'm thinking instead of accessing the Click command's fields directly to instead call the
to_info_dict
function , which seems to return all necessary info, and is interceptible by lazy loading. Or at least call it once so that lazy loading can workI do have concerns though that the Trogon app might load every command and its info all at once anyway instead of doing so lazily, which would somewhat defeat the point...
The text was updated successfully, but these errors were encountered: