MCPcopy
hub / github.com/dask/dask / _register_command_ep

Function _register_command_ep

dask/cli.py:163–197  ·  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

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

Used in the wild real call sites across dependent graphs

searching dependent graphs…