I am getting a `KeyringLocked("Failed to unlock th...
# ask-the-community
b
I am getting a
KeyringLocked("Failed to unlock the collection!")
when I register workflows. I need to unlock my keyring to proceed, but don't understand why.
Copy code
/home/ubuntu/vfm/ml_platform/workflows/data_processing/launch:9 in <module>                                               │
│                                                                                     │
│ ❱  9 │  launch(                                                                            │
│                                                                                     │
│ /home/ubuntu/vfm/ml_platform/orchestration/cli/launcher.py:80 in launch                                                 │
│                                                                                     │
│ ❱ 80 │  │  registered_preprocess_wf = remote.register_script(                                                     │
│                                                                                     │
│ /home/ubuntu/.venv/lib/python3.11/site-packages/flytekit/remote/remote.py:929 in register_script                                    │
│                                                                                     │
│ ❱  929 │  │  │  │  md5_bytes, upload_native_url = self.fast_package(pathlib.Path(source_pat                                     │
│                                                                                     │
│ /home/ubuntu/.venv/lib/python3.11/site-packages/flytekit/remote/remote.py:802 in fast_package                                      │
│                                                                                     │
│ ❱  802 │  │  return self.upload_file(pathlib.Path(zip_file))                                                     │
│                                                                                     │
│ /home/ubuntu/.venv/lib/python3.11/site-packages/flytekit/remote/remote.py:825 in upload_file                                      │
│                                                                                     │
│ ❱  825 │  │  upload_location = self.client.get_upload_signed_url(                                                   │
│                                                                                     │
│ /home/ubuntu/.venv/lib/python3.11/site-packages/flytekit/remote/remote.py:236 in client                                         │
│                                                                                     │
│ ❱  236 │  │  │  self._client = SynchronousFlyteClient(self.config.platform, **self._kwargs)                                     │
│                                                                                     │
│ /home/ubuntu/.venv/lib/python3.11/site-packages/flytekit/clients/raw.py:50 in __init__                                         │
│                                                                                     │
│ ❱  50 │  │  │  cfg, upgrade_channel_to_authenticated(cfg, upgrade_channel_to_proxy_authenti                                     │
│                                                                                     │
│ /home/ubuntu/.venv/lib/python3.11/site-packages/flytekit/clients/auth_helper.py:140 in upgrade_channel_to_authenticated                         │
│                                                                                     │
│ ❱ 140 │  authenticator = get_authenticator(cfg, RemoteClientConfigStore(in_channel))                                          │
│                                                                                     │
│ /home/ubuntu/.venv/lib/python3.11/site-packages/flytekit/clients/auth_helper.py:73 in get_authenticator                                 │
│                                                                                     │
│ ❱  73 │  │  return PKCEAuthenticator(cfg.endpoint, cfg_store, scopes=cfg.scopes, verify=veri                                     │
│                                                                                     │
│ /home/ubuntu/.venv/lib/python3.11/site-packages/flytekit/clients/auth/authenticator.py:111 in __init__                                 │
│                                                                                     │
│ ❱ 111 │  │  super().__init__(endpoint, header_key, KeyringStore.retrieve(endpoint), verify=v                                     │
│                                                                                     │
│ /home/ubuntu/.venv/lib/python3.11/site-packages/flytekit/clients/auth/keyring.py:58 in retrieve                                     │
│                                                                                     │
│ ❱ 58 │  │  │  refresh_token = _keyring.get_password(for_endpoint, KeyringStore._refresh_to                                      │
│                                                                                     │
│ /home/ubuntu/.venv/lib/python3.11/site-packages/keyring/core.py:56 in get_password                                           │
│                                                                                     │
│ ❱  56 │  return get_keyring().get_password(service_name, username)                                                   │
│                                                                                     │
│ /home/ubuntu/.venv/lib/python3.11/site-packages/keyring/backends/SecretService.py:79 in get_password                                  │
│                                                                                     │
│ ❱  79 │  │  collection = self.get_preferred_collection()                                                       │
│                                                                                     │
│ /home/ubuntu/.venv/lib/python3.11/site-packages/keyring/backends/SecretService.py:68 in get_preferred_collection                            │
│                                                                                     │
│ ❱  68 │  │  │  │  raise KeyringLocked("Failed to unlock the collection!")
k
I have never seen this
b
@Ketan (kumare3) If it helps, I see this when using FlyteRemote register_script. It happens with both sandbox as well as remote cluster.
k
yes, but it seems to be a problem with the keyring library
d
FlyteRemote uses keyring to store authentication secrets. Else you would need to authenticate every single time. Especially with Linux keyring can be a tricky to setup. Can you check which backend you are using?
Copy code
import keyring
from keyring.backends.chainer import ChainerBackend

# Get the current keyring backend
current_backend = keyring.get_keyring()

# Print the type and description of the backend
print("Keyring backend:", type(current_backend))
print("Keyring backend description:", current_backend)

# If the backend is ChainerBackend, list its backends
if isinstance(current_backend, ChainerBackend):
    print("ChainerBackend is using the following backends:")
    for backend in current_backend.backends:
        print("-", type(backend), ":", backend)
You might then check if keyring generally works:
Copy code
import keyring

# Define the service name, username, and password
service_name = "my_service"
username = "my_username"
password = "my_secure_password"

# Store the password
keyring.set_password(service_name, username, password)
print("Password stored successfully.")

# Retrieve the password
retrieved_password = keyring.get_password(service_name, username)
print(f"Retrieved password: {retrieved_password}")
b
Thank you. I’ll check this.
Copy code
Keyring backend: <class 'keyring.backends.SecretService.Keyring'>
Keyring backend description: keyring.backends.SecretService.Keyring (priority: 5)
Copy code
Traceback (most recent call last):
  File "/home/ubuntu/vfm/foo.py", line 24, in <module>
    keyring.set_password(service_name, username, password)
  File "/home/ubuntu/.venv/lib/python3.11/site-packages/keyring/core.py", line 61, in set_password
    get_keyring().set_password(service_name, username, password)
  File "/home/ubuntu/.venv/lib/python3.11/site-packages/keyring/backends/SecretService.py", line 88, in set_password
    collection = self.get_preferred_collection()
                 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/ubuntu/.venv/lib/python3.11/site-packages/keyring/backends/SecretService.py", line 68, in get_preferred_collection
    raise KeyringLocked("Failed to unlock the collection!")
keyring.errors.KeyringLocked: Failed to unlock the collection!
cc: @Dennis Keck
d
Yeah that's the default linux keyring backend, not the installation instructions in the keyring readmehttps://github.com/jaraco/keyring/blob/main/README.rst These recommended keyring backends are supported: • ... • Freedesktop Secret Service supports many DE including GNOME (requires secretstorage) • KDE4 & KDE5 KWallet (requires dbus) • ... Installation - Linux On Linux, the KWallet backend relies on dbus-python, which does not always install correctly when using pip (compilation is needed). For best results, install dbus-python as a system package.
k
You can also just use keyring.alt, store in plain files