Skip to content

Commit

Permalink
DynamicEntryPointCommandGroup: Allow entry points to be excluded (#…
Browse files Browse the repository at this point in the history
…6223)

The `DynamicEntryPointCommandGroup` now checks plugin classes for the
`cli_exposed` class attribute, and when set to `False`, no dynamic
command is generated for the entry point, even if it matches the entry
point filter regex.

This is used for the `core.sqlite_temp` storage plugin, since this is a
storage that is automatically cleaned up after it is garbage collected,
for example when the Python interpreter shuts down. It therefore does
not make sense to allow a profile to be created using this storage
plugin through `verdi profile setup`.
  • Loading branch information
sphuber authored Dec 13, 2023
1 parent 2b2e74b commit 9e30ec8
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 1 deletion.
3 changes: 2 additions & 1 deletion aiida/cmdline/groups/dynamic.py
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,8 @@ def list_commands(self, ctx: click.Context) -> list[str]:
commands = super().list_commands(ctx)
commands.extend([
entry_point for entry_point in get_entry_point_names(self.entry_point_group)
if re.match(self.entry_point_name_filter, entry_point)
if re.match(self.entry_point_name_filter, entry_point) and
getattr(self.factory(entry_point), 'cli_exposed', True)
])
return sorted(commands)

Expand Down
3 changes: 3 additions & 0 deletions aiida/storage/sqlite_temp/backend.py
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,9 @@ class Configuration(BaseModel):

_read_only = False

cli_exposed = False
"""Ensure this plugin is not exposed in ``verdi profile setup``."""

@staticmethod
def create_profile(
name: str = 'temp',
Expand Down

0 comments on commit 9e30ec8

Please sign in to comment.