Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Minor architectural fixes #303

Merged
merged 4 commits into from
Jan 24, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
782 changes: 392 additions & 390 deletions poetry.lock

Large diffs are not rendered by default.

11 changes: 6 additions & 5 deletions src/hermes/commands/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
from pydantic_settings import BaseSettings, SettingsConfigDict


class HermesSettings(BaseSettings):
class _HermesSettings(BaseSettings):
"""Root class for HERMES configuration model."""

model_config = SettingsConfigDict(env_file_encoding='utf-8')
Expand All @@ -31,7 +31,7 @@ class HermesCommand(abc.ABC):
"""

command_name: str = ""
settings_class: Type = HermesSettings
settings_class: Type = _HermesSettings

def __init__(self, parser: argparse.ArgumentParser):
"""Initialize a new instance of any HERMES command.
Expand All @@ -45,18 +45,19 @@ def __init__(self, parser: argparse.ArgumentParser):
self.log = logging.getLogger(f"hermes.{self.command_name}")
self.errors = []

def init_plugins(self):
@classmethod
def init_plugins(cls):
"""Collect and initialize the plugins available for the HERMES command."""

# Collect all entry points for this group (i.e., all valid plug-ins for the step)
entry_point_group = f"hermes.{self.command_name}"
entry_point_group = f"hermes.{cls.command_name}"
group_plugins = {
entry_point.name: entry_point.load()
for entry_point in metadata.entry_points(group=entry_point_group)
}

# Collect the plug-in specific configurations
self.derive_settings_class({
cls.derive_settings_class({
plugin_name: plugin_class.settings_class
for plugin_name, plugin_class in group_plugins.items()
if hasattr(plugin_class, "settings_class") and plugin_class.settings_class is not None
Expand Down
4 changes: 2 additions & 2 deletions src/hermes/commands/clean/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
from hermes.commands.base import HermesCommand


class HermesCleanSettings(BaseModel):
class _HermesCleanSettings(BaseModel):
"""Configuration of the ``clean`` command."""
pass

Expand All @@ -21,7 +21,7 @@ class HermesCleanCommand(HermesCommand):
""" Clean up caches from previous HERMES runs. """

command_name = "clean"
settings_class = HermesCleanSettings
settings_class = _HermesCleanSettings

def __call__(self, args: argparse.Namespace) -> None:
self.log.info("Removing HERMES caches...")
Expand Down
4 changes: 2 additions & 2 deletions src/hermes/commands/curate/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
from hermes.model.context import CodeMetaContext


class CurateSettings(BaseModel):
class _CurateSettings(BaseModel):
"""Generic deposition settings."""

pass
Expand All @@ -25,7 +25,7 @@ class HermesCurateCommand(HermesCommand):
""" Curate the unified metadata before deposition. """

command_name = "curate"
settings_class = CurateSettings
settings_class = _CurateSettings

def init_command_parser(self, command_parser: argparse.ArgumentParser) -> None:
pass
Expand Down
4 changes: 2 additions & 2 deletions src/hermes/commands/deposit/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,7 @@ def publish(self) -> None:
pass


class DepositSettings(BaseModel):
class _DepositSettings(BaseModel):
"""Generic deposition settings."""

target: str = ""
Expand All @@ -116,7 +116,7 @@ class HermesDepositCommand(HermesCommand):
""" Deposit the curated metadata to repositories. """

command_name = "deposit"
settings_class = DepositSettings
settings_class = _DepositSettings

def init_command_parser(self, command_parser: argparse.ArgumentParser) -> None:
command_parser.add_argument('--file', '-f', nargs=1, action='append',
Expand Down
4 changes: 2 additions & 2 deletions src/hermes/commands/harvest/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ def __call__(self, command: HermesCommand) -> t.Tuple[t.Dict, t.Dict]:
pass


class HarvestSettings(BaseModel):
class _HarvestSettings(BaseModel):
"""Generic harvesting settings."""

sources: list[str] = []
Expand All @@ -35,7 +35,7 @@ class HermesHarvestCommand(HermesCommand):
""" Harvest metadata from configured sources. """

command_name = "harvest"
settings_class = HarvestSettings
settings_class = _HarvestSettings

def __call__(self, args: argparse.Namespace) -> None:
self.args = args
Expand Down
6 changes: 3 additions & 3 deletions src/hermes/commands/init/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -139,15 +139,15 @@ def convert_remote_url(url: str) -> str:
return url


class HermesInitSettings(BaseModel):
class _HermesInitSettings(BaseModel):
"""Configuration of the ``init`` command."""
pass


class HermesInitCommand(HermesCommand):
""" Install HERMES onto a project. """
command_name = "init"
settings_class = HermesInitSettings
settings_class = _HermesInitSettings

def __init__(self, parser: argparse.ArgumentParser):
super().__init__(parser)
Expand Down Expand Up @@ -554,7 +554,7 @@ def choose_push_branch(self):
"When should the automated HERMES process start?",
[
f"When I push the current branch {self.folder_info.current_branch}",
"When I push an other branch",
"When I push another branch",
"When a push a specific tag (not implemented)",
]
)
Expand Down
4 changes: 2 additions & 2 deletions src/hermes/commands/postprocess/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ class HermesPostprocessPlugin(HermesPlugin):
pass


class PostprocessSettings(BaseModel):
class _PostprocessSettings(BaseModel):
"""Generic post-processing settings."""

execute: list = []
Expand All @@ -25,7 +25,7 @@ class HermesPostprocessCommand(HermesCommand):
"""Post-process the published metadata after deposition."""

command_name = "postprocess"
settings_class = PostprocessSettings
settings_class = _PostprocessSettings

def __call__(self, args: argparse.Namespace) -> None:
pass
Loading