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

Enhancements to Secret Management #364

Merged
merged 58 commits into from
Sep 12, 2023
Merged
Show file tree
Hide file tree
Changes from 41 commits
Commits
Show all changes
58 commits
Select commit Hold shift + click to select a range
7757f50
use keyring to store credentials
maxjeblick Aug 9, 2023
e4a4d52
use keyring migration
maxjeblick Aug 9, 2023
dfd5238
update pipfile
maxjeblick Aug 9, 2023
5adb0f2
switch to yaml
maxjeblick Aug 9, 2023
f5b9514
try to fix ssh keyring
maxjeblick Aug 9, 2023
419689d
Merge branch 'max/use_keyring_storage' of github.com:h2oai/h2o-llmstu…
maxjeblick Aug 9, 2023
1a6a662
switch to DBUSkeyring
maxjeblick Aug 9, 2023
03d84f2
undo switch to DBUSkeyring
maxjeblick Aug 9, 2023
55c8a88
switch to DBUSkeyring
maxjeblick Aug 9, 2023
26ba4f7
set SecretService in make wave
maxjeblick Aug 9, 2023
75377d0
pop up if secret cannot be saved
maxjeblick Aug 9, 2023
340dfce
pop up if secret cannot be saved
maxjeblick Aug 9, 2023
1b641b6
pop up if secret cannot be saved
maxjeblick Aug 9, 2023
e86c4e2
show traceback
maxjeblick Aug 9, 2023
858860a
add factory method for credentials
maxjeblick Aug 10, 2023
449934b
add factory method for credentials
maxjeblick Aug 10, 2023
8023c7a
fix keyring deletion
maxjeblick Aug 10, 2023
24db4a8
fix format
maxjeblick Aug 10, 2023
351e9c6
fix format
maxjeblick Aug 10, 2023
a0ecff5
add tests for settings
maxjeblick Aug 10, 2023
a1cdb20
refact settings
maxjeblick Aug 10, 2023
4a07912
add readme with updates
maxjeblick Aug 10, 2023
a02a1cc
remove make keyring variable
maxjeblick Aug 10, 2023
fcdcf0c
fix format
maxjeblick Aug 10, 2023
bf4c673
better wording
maxjeblick Aug 10, 2023
95ff87b
better wording
maxjeblick Aug 10, 2023
0c0a0e6
update pipfile
maxjeblick Aug 10, 2023
1630aac
fix pr number
maxjeblick Aug 10, 2023
d59f483
Update requirements.txt
maxjeblick Aug 10, 2023
cc467f5
Merge branch 'main' into max/use_keyring_storage
maxjeblick Aug 10, 2023
105c209
remove uneeded variables
maxjeblick Aug 10, 2023
29ae38f
Merge branch 'main' into max/use_keyring_storage
maxjeblick Aug 14, 2023
3056be5
Merge branch 'max/use_keyring_storage' of github.com:h2oai/h2o-llmstu…
maxjeblick Aug 14, 2023
ebef445
Merge branch 'main' into max/use_keyring_storage
maxjeblick Aug 16, 2023
8efb651
fix merge conflicts
maxjeblick Aug 16, 2023
fcda030
refact saveing of user settings
maxjeblick Aug 16, 2023
ea1340f
refact saveing of user settings
maxjeblick Aug 16, 2023
33aad0c
add button for no setting error pop up
maxjeblick Aug 16, 2023
6e8a829
Merge branch 'main' into max/use_keyring_storage
maxjeblick Aug 16, 2023
512ad37
Merge branch 'main' into max/use_keyring_storage
maxjeblick Aug 17, 2023
e081e3c
first save/load secrets
maxjeblick Aug 17, 2023
a95cb5a
more type annotations
maxjeblick Aug 17, 2023
7581249
Merge branch 'main' into max/use_keyring_storage
maxjeblick Aug 17, 2023
037aadc
Merge branch 'main' into max/use_keyring_storage
maxjeblick Aug 17, 2023
e965ffc
Merge branch 'max/use_keyring_storage' of github.com:h2oai/h2o-llmstu…
maxjeblick Aug 17, 2023
a494812
fix merge conflicts
maxjeblick Sep 12, 2023
97faf73
add keyring dependency
maxjeblick Sep 12, 2023
051d006
Update requirements.txt
maxjeblick Sep 12, 2023
76d06bb
use env file as default
maxjeblick Sep 12, 2023
58a9359
disable keyring if it is not working
maxjeblick Sep 12, 2023
f14523d
disable keyring after 3 seconds
maxjeblick Sep 12, 2023
ae91449
disable keyring after 3 seconds
maxjeblick Sep 12, 2023
35a1a98
use timeout for keyring credential saver
maxjeblick Sep 12, 2023
4ba47a6
fix timeout
maxjeblick Sep 12, 2023
02f1bf6
fix timeout
maxjeblick Sep 12, 2023
6d12cfb
fix timeout
maxjeblick Sep 12, 2023
691e033
fix format
maxjeblick Sep 12, 2023
d6dc681
update readme comment
maxjeblick Sep 12, 2023
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
1 change: 1 addition & 0 deletions Pipfile
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@ h2o-wave = "0.26"
tiktoken = "0.4.0"
hf-transfer = "0.1.3"
peft = "0.4.0"
keyring = "24.2.0"

[dev-packages]
pytest = "==7.4.0"
Expand Down
508 changes: 335 additions & 173 deletions Pipfile.lock

Large diffs are not rendered by default.

1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@ Using CLI for fine-tuning LLMs:

## What's New

- [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 using the keyring library. Please monitor the logs for more information.
- [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.
- [PR 308](https://github.com/h2oai/h2o-llmstudio/pull/308) Sequence to sequence models have been added as a new problem type.
- [PR 152](https://github.com/h2oai/h2o-llmstudio/pull/152) Add RLHF functionality for fine-tuning LLMs.
Expand Down
1 change: 1 addition & 0 deletions app_utils/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,7 @@ def get_size(x):
],
"user_settings": {
"theme_dark": True,
"credential_saver": "Keyring",
"default_aws_bucket_name": f"{os.getenv('AWS_BUCKET', 'bucket_name')}",
"default_aws_access_key": os.getenv("AWS_ACCESS_KEY_ID", ""),
"default_aws_secret_key": os.getenv("AWS_SECRET_ACCESS_KEY", ""),
Expand Down
13 changes: 9 additions & 4 deletions app_utils/handlers.py
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,12 @@
list_current_experiments,
)
from app_utils.sections.settings import settings
from app_utils.utils import add_model_type, load_user_settings, save_user_settings
from app_utils.utils.setting_utils import (
load_default_user_settings,
load_user_settings_and_secrets,
save_user_settings_and_secrets,
)
from app_utils.utils.utils import add_model_type
from app_utils.wave_utils import report_error, wave_utils_handle_error

logger = logging.getLogger(__name__)
Expand Down Expand Up @@ -73,13 +78,13 @@ async def handle(q: Q) -> None:
await settings(q)
elif q.args["save_settings"]:
logger.info("Saving user settings")
save_user_settings(q)
await save_user_settings_and_secrets(q)
await settings(q)
elif q.args["load_settings"]:
load_user_settings(q)
load_user_settings_and_secrets(q)
await settings(q)
elif q.args["restore_default_settings"]:
load_user_settings(q, force_defaults=True)
load_default_user_settings(q)
await settings(q)

elif q.args["report_error"]:
Expand Down
14 changes: 7 additions & 7 deletions app_utils/initializers.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,20 +7,20 @@
from h2o_wave import Q

from app_utils.sections.common import interface
from llm_studio.src.utils.config_utils import load_config_py, save_config_yaml

from .config import default_cfg
from .db import Database, Dataset
from .utils import (
from app_utils.utils.utils import (
get_data_dir,
get_database_dir,
get_download_dir,
get_output_dir,
get_user_db_path,
get_user_name,
load_user_settings,
prepare_default_dataset,
)
from llm_studio.src.utils.config_utils import load_config_py, save_config_yaml

from .config import default_cfg
from .db import Database, Dataset
from .utils.setting_utils import load_user_settings_and_secrets

logger = logging.getLogger(__name__)

Expand Down Expand Up @@ -97,7 +97,7 @@ async def initialize_client(q: Q) -> None:

import_data(q)

load_user_settings(q)
load_user_settings_and_secrets(q)

await interface(q)

Expand Down
7 changes: 6 additions & 1 deletion app_utils/sections/chat.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,12 @@
from h2o_wave import ui
from transformers import AutoTokenizer, TextStreamer

from app_utils.utils import get_experiments, get_ui_elements, parse_ui_elements, set_env
from app_utils.utils.utils import (
get_experiments,
get_ui_elements,
parse_ui_elements,
set_env,
)
from llm_studio.src.datasets.text_utils import get_tokenizer
from llm_studio.src.models.text_causal_language_modeling_model import Model
from llm_studio.src.utils.config_utils import load_config_yaml
Expand Down
2 changes: 1 addition & 1 deletion app_utils/sections/dataset.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
from app_utils.config import default_cfg
from app_utils.db import Dataset
from app_utils.sections.experiment import experiment_start
from app_utils.utils import (
from app_utils.utils.utils import (
add_model_type,
check_valid_upload_content,
clean_error,
Expand Down
2 changes: 1 addition & 1 deletion app_utils/sections/experiment.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
from app_utils.config import default_cfg
from app_utils.sections.chat import chat_tab, load_cfg_model_tokenizer
from app_utils.sections.common import clean_dashboard
from app_utils.utils import (
from app_utils.utils.utils import (
add_model_type,
flatten_dict,
get_cfg_list_items,
Expand Down
2 changes: 1 addition & 1 deletion app_utils/sections/home.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

from app_utils.config import default_cfg
from app_utils.sections.common import clean_dashboard
from app_utils.utils import (
from app_utils.utils.utils import (
get_datasets,
get_experiments,
get_gpu_usage,
Expand Down
2 changes: 1 addition & 1 deletion app_utils/sections/project.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
experiment_rename_form,
get_table_and_message_item_indices,
)
from app_utils.utils import get_experiments_status
from app_utils.utils.utils import get_experiments_status

logger = logging.getLogger(__name__)

Expand Down
32 changes: 32 additions & 0 deletions app_utils/sections/settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
from h2o_wave import Q, ui

from app_utils.sections.common import clean_dashboard
from app_utils.utils.setting_utils import Secrets
from llm_studio.src.loggers import Loggers


Expand All @@ -24,6 +25,37 @@ async def settings(q: Q) -> None:
'Save settings persistently' button below. To reload \
the persistently saved settings, use the 'Load settings' button.",
),
ui.separator("Credential Storage"),
ui.inline(
items=[
ui.label("Credential Handler", width=label_width),
ui.dropdown(
name="credential_saver",
value=q.client["credential_saver"],
choices=[ui.choice(name, name) for name in Secrets.names()],
trigger=False,
width="300px",
),
]
),
ui.message_bar(
type="info",
text="""Method used to save credentials (passwords) \
for 'Save settings persistently'. \
The recommended approach for saving credentials (passwords) is to \
use either Keyring or to avoid permanent storage \
(requiring re-entry upon app restart). \
If Keyring isn't set up on the system, \
a pop-up will notify the user of the failure. \
In this scenario, you can choose not to save \
credentials long-term or utilize a local .env file. \
Only resort to the latter if your machine's \
accessibility is restricted to you.\
When you select 'Save settings persistently', \
credentials will be removed from all non-selected methods. \
'Restore Default Settings' will clear credentials from all methods.
""",
),
ui.separator("Appearance"),
ui.inline(
items=[
Expand Down
Empty file added app_utils/utils/__init__.py
Empty file.
Loading