Skip to content

Commit

Permalink
fix: loading credentials
Browse files Browse the repository at this point in the history
  • Loading branch information
gabrielmbmb committed Aug 18, 2023
1 parent 82ad0d3 commit 60051d2
Showing 1 changed file with 10 additions and 6 deletions.
16 changes: 10 additions & 6 deletions src/argilla/client/client.py
Original file line number Diff line number Diff line change
Expand Up @@ -106,18 +106,22 @@ def __init__(
"""
from argilla.client.login import ArgillaCredentials

if api_url is None and api_key is None:
api_url = api_url or os.getenv("ARGILLA_API_URL", "http://localhost:6900")
api_key = api_key or os.getenv("ARGILLA_API_KEY", DEFAULT_API_KEY)
workspace = workspace or os.getenv("ARGILLA_WORKSPACE")
extra_headers = extra_headers or {}

if api_url is None and api_key is None and workspace is None:
try:
credentials = ArgillaCredentials.load()
api_url = credentials.api_url
api_key = credentials.api_key
workspace = credentials.workspace
extra_headers = credentials.extra_headers
except FileNotFoundError:
api_url = os.getenv("ARGILLA_API_URL", "http://localhost:6900")
api_key = os.getenv("ARGILLA_API_KEY", DEFAULT_API_KEY)
workspace = os.getenv("ARGILLA_WORKSPACE")
extra_headers = {}
except FileNotFoundError as e:
raise ValueError(
"No `api_url`, `api_key` or `workspace` was provided and the credentials file could not be found"
) from e

# Checking that the api_url does not end in '/'
api_url = re.sub(r"\/$", "", api_url)
Expand Down

0 comments on commit 60051d2

Please sign in to comment.