MCPcopy Create free account
hub / github.com/dask/dask / _register_command_ep

Function _register_command_ep

dask/cli.py:165–199  ·  view source on GitHub ↗

Add `entry_point` command to `interface`. Parameters ---------- interface : click.Command or click.Group The click interface to augment with `entry_point`. entry_point : importlib.metadata.EntryPoint The entry point which loads to a ``click.Command`` or ``cli

(interface, entry_point)

Source from the content-addressed store, hash-verified

163
164
165def _register_command_ep(interface, entry_point):
166 """Add `entry_point` command to `interface`.
167
168 Parameters
169 ----------
170 interface : click.Command or click.Group
171 The click interface to augment with `entry_point`.
172 entry_point : importlib.metadata.EntryPoint
173 The entry point which loads to a ``click.Command`` or
174 ``click.Group`` instance to be added as a sub-command or
175 sub-group in `interface`.
176
177 """
178 try:
179 command = entry_point.load()
180 except Exception as e:
181 warnings.warn(
182 f"While registering the command with name '{entry_point.name}', an "
183 f"exception occurred; {e}."
184 )
185 return
186 if not isinstance(command, (click.Command, click.Group)):
187 warnings.warn(
188 "entry points in 'dask_cli' must be instances of "
189 f"click.Command or click.Group, not {type(command)}."
190 )
191 return
192
193 if command.name in interface.commands:
194 warnings.warn(
195 f"While registering the command with name '{command.name}', an "
196 "existing command or group; the original has been overwritten."
197 )
198
199 interface.add_command(command)
200
201
202def run_cli():

Callers 3

test_register_command_epFunction · 0.90
run_cliFunction · 0.85

Calls 1

loadMethod · 0.80

Tested by 2

test_register_command_epFunction · 0.72