-
Notifications
You must be signed in to change notification settings - Fork 60
OLS-2025: Collect config on startup #417
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
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -20,6 +20,8 @@ user_data_collection: | |
| feedback_storage: "/tmp/data/feedback" | ||
| transcripts_enabled: true | ||
| transcripts_storage: "/tmp/data/transcripts" | ||
| config_enabled: true | ||
| config_storage: "/tmp/data/config" | ||
|
Comment on lines
+23
to
+24
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🛠️ Refactor suggestion Do not enable config collection by default in shipped config (privacy/security risk). Having Apply this diff: - config_enabled: true
+ config_enabled: false
config_storage: "/tmp/data/config"🤖 Prompt for AI Agents
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Hmm, this is actually a good comment. In OLS, the config doesn't contain any secrets (if it does, it is user's fault and we are fine collecting it in this case), but the
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
|
||
|
|
||
| authentication: | ||
| module: "noop" | ||
| Original file line number | Diff line number | Diff line change | ||||||
|---|---|---|---|---|---|---|---|---|
|
|
@@ -6,12 +6,18 @@ | |||||||
|
|
||||||||
| from argparse import ArgumentParser | ||||||||
| import asyncio | ||||||||
| import json | ||||||||
| import logging | ||||||||
| from datetime import datetime, timezone | ||||||||
| from pathlib import Path | ||||||||
onmete marked this conversation as resolved.
Show resolved
Hide resolved
|
||||||||
| from rich.logging import RichHandler | ||||||||
|
|
||||||||
|
|
||||||||
| from runners.uvicorn import start_uvicorn | ||||||||
| from configuration import configuration | ||||||||
| from client import AsyncLlamaStackClientHolder | ||||||||
| from utils import suid | ||||||||
| import version | ||||||||
|
|
||||||||
| FORMAT = "%(message)s" | ||||||||
| logging.basicConfig( | ||||||||
|
|
@@ -21,6 +27,42 @@ | |||||||
| logger = logging.getLogger(__name__) | ||||||||
|
|
||||||||
|
|
||||||||
| def store_config(cfg_file: str) -> None: | ||||||||
| """Store service configuration in the local filesystem. | ||||||||
|
|
||||||||
| This function stores the original configuration file content once at startup. | ||||||||
| Since the configuration is immutable for a single service deployment, | ||||||||
| this avoids duplicating the same config data in every transcript/feedback. | ||||||||
|
|
||||||||
| Args: | ||||||||
| cfg_file: Path to the original configuration file. | ||||||||
| """ | ||||||||
| with open(cfg_file, "r", encoding="utf-8") as f: | ||||||||
| config_content = f.read() | ||||||||
|
|
||||||||
| data_to_store = { | ||||||||
| "metadata": { | ||||||||
| "timestamp": datetime.now(timezone.utc).isoformat(), | ||||||||
| "service_version": version.__version__, | ||||||||
| "config_file_path": cfg_file, | ||||||||
| }, | ||||||||
| "configuration": config_content, | ||||||||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Another concern I have reading this, is that we do not redact anything from the configuration file. These files may include passwords [0][1], API keys [2], etc... I'm not sure clients will want to send that anywhere. And even those storing this kind of content might have to deal with legal issues/procedures in order to do so. [0] lightspeed-stack/src/models/config.py Line 19 in 45eb299
[1] lightspeed-stack/src/models/config.py Line 64 in 45eb299
[2] lightspeed-stack/src/models/config.py Line 151 in 45eb299
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Yup - see previous comment: #417 (comment) |
||||||||
| } | ||||||||
|
|
||||||||
| # Store the data in the local filesystem | ||||||||
| config_storage = configuration.user_data_collection_configuration.config_storage | ||||||||
| if config_storage is None: | ||||||||
| raise ValueError("config_storage must be set when config collection is enabled") | ||||||||
| storage_path = Path(config_storage) | ||||||||
| storage_path.mkdir(parents=True, exist_ok=True) | ||||||||
| config_file_path = storage_path / f"{suid.get_suid()}.json" | ||||||||
|
|
||||||||
| with open(config_file_path, "w", encoding="utf-8") as config_file: | ||||||||
| json.dump(data_to_store, config_file, indent=2) | ||||||||
|
|
||||||||
| logger.info("Service configuration stored in '%s'", config_file_path) | ||||||||
onmete marked this conversation as resolved.
Show resolved
Hide resolved
|
||||||||
|
|
||||||||
|
|
||||||||
| def create_argument_parser() -> ArgumentParser: | ||||||||
| """Create and configure argument parser object.""" | ||||||||
| parser = ArgumentParser() | ||||||||
|
|
@@ -62,6 +104,13 @@ def main() -> None: | |||||||
| logger.info( | ||||||||
| "Llama stack configuration: %s", configuration.llama_stack_configuration | ||||||||
| ) | ||||||||
|
|
||||||||
| # store service configuration if enabled | ||||||||
| if configuration.user_data_collection_configuration.config_enabled: | ||||||||
| store_config(args.config_file) | ||||||||
| else: | ||||||||
| logger.debug("Config collection is disabled in configuration") | ||||||||
|
|
||||||||
| logger.info("Creating AsyncLlamaStackClient") | ||||||||
| asyncio.run( | ||||||||
| AsyncLlamaStackClientHolder().load(configuration.configuration.llama_stack) | ||||||||
|
|
||||||||
Uh oh!
There was an error while loading. Please reload this page.