Skip to content

Commit 31d6331

Browse files
authored
Enhancements to Secret Management
1 parent 5c543c8 commit 31d6331

File tree

11 files changed

+539
-85
lines changed

11 files changed

+539
-85
lines changed

Pipfile

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,7 @@ tiktoken = "==0.4.0"
5050
hf-transfer = "==0.1.3"
5151
peft = "==0.5.0"
5252
azure-storage-file-datalake = ">=12.12.0"
53+
keyring = "==24.2.0"
5354

5455
[dev-packages]
5556
black = "==23.7.0"

Pipfile.lock

Lines changed: 83 additions & 27 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,7 @@ Using CLI for fine-tuning LLMs:
5454

5555
## What's New
5656

57+
- [PR 364](https://github.com/h2oai/h2o-llmstudio/pull/364) User secrets are now handled more securely and flexible. Support for handling secrets using the 'keyring' library was added. User settings are tried to be migrated automatically.
5758
- [PR 328](https://github.com/h2oai/h2o-llmstudio/pull/328) RLHF is now a separate problem type. Note that starting a new RLHF experiment from an old experiment that used RLHF is no longer supported. To continue from a previous experiment, please start a new experiment and enter the settings from the previous experiment manually.
5859
- [PR 308](https://github.com/h2oai/h2o-llmstudio/pull/308) Sequence to sequence models have been added as a new problem type.
5960
- [PR 152](https://github.com/h2oai/h2o-llmstudio/pull/152) Add RLHF functionality for fine-tuning LLMs.

llm_studio/app_utils/config.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -85,6 +85,7 @@ def get_size(x):
8585
],
8686
"user_settings": {
8787
"theme_dark": True,
88+
"credential_saver": ".env File",
8889
"default_aws_bucket_name": f"{os.getenv('AWS_BUCKET', 'bucket_name')}",
8990
"default_aws_access_key": os.getenv("AWS_ACCESS_KEY_ID", ""),
9091
"default_aws_secret_key": os.getenv("AWS_SECRET_ACCESS_KEY", ""),

llm_studio/app_utils/handlers.py

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -42,11 +42,12 @@
4242
list_current_experiments,
4343
)
4444
from llm_studio.app_utils.sections.settings import settings
45-
from llm_studio.app_utils.utils import (
46-
add_model_type,
47-
load_user_settings,
48-
save_user_settings,
45+
from llm_studio.app_utils.setting_utils import (
46+
load_default_user_settings,
47+
load_user_settings_and_secrets,
48+
save_user_settings_and_secrets,
4949
)
50+
from llm_studio.app_utils.utils import add_model_type
5051
from llm_studio.app_utils.wave_utils import report_error, wave_utils_handle_error
5152

5253
logger = logging.getLogger(__name__)
@@ -77,13 +78,13 @@ async def handle(q: Q) -> None:
7778
await settings(q)
7879
elif q.args["save_settings"]:
7980
logger.info("Saving user settings")
80-
save_user_settings(q)
81+
await save_user_settings_and_secrets(q)
8182
await settings(q)
8283
elif q.args["load_settings"]:
83-
load_user_settings(q)
84+
load_user_settings_and_secrets(q)
8485
await settings(q)
8586
elif q.args["restore_default_settings"]:
86-
load_user_settings(q, force_defaults=True)
87+
load_default_user_settings(q)
8788
await settings(q)
8889

8990
elif q.args["report_error"]:

llm_studio/app_utils/initializers.py

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -6,21 +6,20 @@
66
from bokeh.resources import Resources as BokehResources
77
from h2o_wave import Q
88

9+
from llm_studio.app_utils.config import default_cfg
10+
from llm_studio.app_utils.db import Database, Dataset
911
from llm_studio.app_utils.sections.common import interface
10-
from llm_studio.src.utils.config_utils import load_config_py, save_config_yaml
11-
12-
from .config import default_cfg
13-
from .db import Database, Dataset
14-
from .utils import (
12+
from llm_studio.app_utils.setting_utils import load_user_settings_and_secrets
13+
from llm_studio.app_utils.utils import (
1514
get_data_dir,
1615
get_database_dir,
1716
get_download_dir,
1817
get_output_dir,
1918
get_user_db_path,
2019
get_user_name,
21-
load_user_settings,
2220
prepare_default_dataset,
2321
)
22+
from llm_studio.src.utils.config_utils import load_config_py, save_config_yaml
2423

2524
logger = logging.getLogger(__name__)
2625

@@ -97,7 +96,7 @@ async def initialize_client(q: Q) -> None:
9796

9897
import_data(q)
9998

100-
load_user_settings(q)
99+
load_user_settings_and_secrets(q)
101100

102101
await interface(q)
103102

llm_studio/app_utils/sections/settings.py

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
from h2o_wave import Q, ui
55

66
from llm_studio.app_utils.sections.common import clean_dashboard
7+
from llm_studio.app_utils.setting_utils import Secrets
78
from llm_studio.src.loggers import Loggers
89

910

@@ -24,6 +25,34 @@ async def settings(q: Q) -> None:
2425
'Save settings persistently' button below. To reload \
2526
the persistently saved settings, use the 'Load settings' button.",
2627
),
28+
ui.separator("Credential Storage"),
29+
ui.inline(
30+
items=[
31+
ui.label("Credential Handler", width=label_width),
32+
ui.dropdown(
33+
name="credential_saver",
34+
value=q.client["credential_saver"],
35+
choices=[ui.choice(name, name) for name in Secrets.names()],
36+
trigger=False,
37+
width="300px",
38+
),
39+
]
40+
),
41+
ui.message_bar(
42+
type="info",
43+
text="""Method used to save credentials (passwords) \
44+
for 'Save settings persistently'. \
45+
The recommended approach for saving credentials (passwords) is to \
46+
use either Keyring or to avoid permanent storage \
47+
(requiring re-entry upon app restart). \
48+
Keyring will be disabled if it is not set up on the host machine. \
49+
Only resort to local .env if your machine's \
50+
accessibility is restricted to you.\n\
51+
When you select 'Save settings persistently', \
52+
credentials will be removed from all non-selected methods. \
53+
'Restore Default Settings' will clear credentials from all methods.
54+
""",
55+
),
2756
ui.separator("Appearance"),
2857
ui.inline(
2958
items=[

0 commit comments

Comments
 (0)