Skip to content

ux: move translator load msg into translator instantiation #1184

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

Merged
merged 9 commits into from
May 22, 2025
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
3 changes: 0 additions & 3 deletions garak/harnesses/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,9 +33,6 @@ def _initialize_runtime_services():
# TODO: this block may be gated in the future to ensure it is only run once. At this time
# only one harness will execute per run so the output here is reasonable.
try:
msg = "🌐 Loading Language services if required."
logging.info(msg)
print(msg)
load_translators()
except GarakException as e:
logging.critical("❌ Language setup failed! ❌", exc_info=e)
Expand Down
8 changes: 8 additions & 0 deletions garak/translators/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -139,7 +139,15 @@ def is_meaning_string(text: str) -> bool:
class Translator(Configurable):
"""Base class for objects that execute translation"""

load_prefix = "🌐 Loading language service"

def __init__(self, config_root: dict = {}) -> None:

if self.load_prefix is not None:
full_msg = f"{self.load_prefix}: {self.__class__.__name__}"
logging.info(full_msg)
print(full_msg)

self._load_config(config_root=config_root)

self.source_lang, self.target_lang = self.language.split(",")
Expand Down
2 changes: 2 additions & 0 deletions garak/translators/local.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@
class NullTranslator(Translator):
"""Stand-in translator for pass through"""

load_prefix = None

def _load_translator(self):
pass

Expand Down