Skip to content

Add environment-variable profile loader for Python client#833

Open
vinayroyt wants to merge 3 commits intodelta-io:mainfrom
vinayroyt:feature/profile-string
Open

Add environment-variable profile loader for Python client#833
vinayroyt wants to merge 3 commits intodelta-io:mainfrom
vinayroyt:feature/profile-string

Conversation

@vinayroyt
Copy link
Copy Markdown

Summary

  • add DeltaSharingProfile.from_env() to build profiles from environment variables
  • add tests for default/custom env var names

Testing

  • pytest python/delta_sharing/tests/test_protocol.py -k from_env
  • Also ran below script to validate independently
import os

from delta_sharing.protocol import DeltaSharingProfile


def main() -> None:
    os.environ.setdefault("DSHARING_VERSION", "1")
    os.environ.setdefault("DSHARING_TOKEN", "token")
    os.environ.setdefault(
        "DSHARING_ENDPOINT",
        "https://localhost/delta-sharing/",
    )
    os.environ.setdefault("DSHARING_EXPTIME", "2021-11-12T00:12:29.0Z")

    profile = DeltaSharingProfile.from_env()
    assert profile.share_credentials_version == 1
    assert profile.bearer_token == "token"
    assert profile.endpoint == "https://localhost/delta-sharing"
    assert profile.expiration_time == "2021-11-12T00:12:29.0Z"

    print("profile from env OK")


if __name__ == "__main__":
    main()

Issue

Closes #448

Signed-off-by: Vinay Roy Thykkutathil <vinayroyt@live.com>
Signed-off-by: Vinay Roy Thykkutathil <vinayroyt@live.com>
Signed-off-by: Vinay Roy Thykkutathil <vinayroyt@live.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Delta Sharing Python Package to Load Credentials from String

1 participant