Skip to content
This repository was archived by the owner on Jun 5, 2025. It is now read-only.

Commit 4c1b4be

Browse files
committed
Optimize signtures
1 parent d2c6069 commit 4c1b4be

File tree

4 files changed

+13
-11
lines changed

4 files changed

+13
-11
lines changed

src/codegate/cli.py

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -305,16 +305,16 @@ def serve(
305305
ca = CertificateAuthority.get_instance()
306306
ca.ensure_certificates_exist()
307307

308-
# Set up event loop
309-
loop = asyncio.new_event_loop()
310-
asyncio.set_event_loop(loop)
311-
312308
# Initialize secrets manager and pipeline factory
313309
secrets_manager = SecretsManager()
314310
pipeline_factory = PipelineFactory(secrets_manager)
315311

316312
app = init_app(pipeline_factory)
317313

314+
# Set up event loop
315+
loop = asyncio.new_event_loop()
316+
asyncio.set_event_loop(loop)
317+
318318
# Run the server
319319
try:
320320
loop.run_until_complete(run_servers(cfg, app))
@@ -331,6 +331,7 @@ def serve(
331331
logger.exception("Unexpected error occurred")
332332
click.echo(f"Error: {e}", err=True)
333333
sys.exit(1)
334+
334335

335336

336337
async def run_servers(cfg: Config, app) -> None:

src/codegate/pipeline/secrets/secrets.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,9 @@ class CodegateSecrets(PipelineStep):
2626
def __init__(self):
2727
"""Initialize the CodegateSecrets pipeline step."""
2828
super().__init__()
29+
# Initialize signatures eagerly
30+
CodegateSignatures.initialize("signatures.yaml")
31+
CodegateSignatures._ensure_signatures_loaded()
2932

3033
@property
3134
def name(self) -> str:

src/codegate/pipeline/secrets/signatures.py

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -61,9 +61,11 @@ def initialize(cls, yaml_path: str) -> None:
6161
raise FileNotFoundError(f"Signatures file not found: {yaml_path}")
6262

6363
with cls._instance_lock:
64-
cls._yaml_path = yaml_path
65-
cls._signatures_loaded = False
66-
logger.debug(f"SecretFinder initialized with {yaml_path}")
64+
# Only initialize if not already initialized with this path
65+
if cls._yaml_path != yaml_path:
66+
cls._yaml_path = yaml_path
67+
cls._signatures_loaded = False
68+
logger.debug(f"SecretFinder initialized with {yaml_path}")
6769

6870
@classmethod
6971
def _preprocess_yaml(cls, content: str) -> str:

src/codegate/server.py

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@
44
from codegate import __description__, __version__
55
from codegate.dashboard.dashboard import dashboard_router
66
from codegate.pipeline.factory import PipelineFactory
7-
from codegate.pipeline.secrets.signatures import CodegateSignatures
87
from codegate.providers.anthropic.provider import AnthropicProvider
98
from codegate.providers.llamacpp.provider import LlamaCppProvider
109
from codegate.providers.ollama.provider import OllamaProvider
@@ -31,9 +30,6 @@ def init_app(pipeline_factory: PipelineFactory) -> FastAPI:
3130
# Create provider registry
3231
registry = ProviderRegistry(app)
3332

34-
# Initialize SignaturesFinder
35-
CodegateSignatures.initialize("signatures.yaml")
36-
3733
# Register all known providers
3834
registry.add_provider(
3935
"openai",

0 commit comments

Comments
 (0)