Skip to content

Commit

Permalink
Reuse set_host logic for defaults
Browse files Browse the repository at this point in the history
  • Loading branch information
kbolashev committed Nov 4, 2024
1 parent 9d325f0 commit 8f17b7f
Showing 1 changed file with 15 additions and 12 deletions.
27 changes: 15 additions & 12 deletions dagshub/common/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,9 +21,21 @@
HTTP_TIMEOUT_KEY = "DAGSHUB_HTTP_TIMEOUT"
DAGSHUB_QUIET_KEY = "DAGSHUB_QUIET"

parsed_host = urlparse(os.environ.get(HOST_KEY, DEFAULT_HOST))
hostname = parsed_host.hostname
host = parsed_host.geturl().rstrip("/")

def set_host(new_host: str):
_parsed_host = urlparse(new_host)
_hostname = _parsed_host.hostname
_host = _parsed_host.geturl().rstrip("/")

global hostname, host, parsed_host
hostname, host, parsed_host = _hostname, _host, _parsed_host


hostname = ""
host = ""
parsed_host = ""
set_host(os.environ.get(HOST_KEY, DEFAULT_HOST))

client_id = os.environ.get(CLIENT_ID_KEY, DEFAULT_CLIENT_ID)
cache_location = os.environ.get(TOKENS_CACHE_LOCATION_KEY, DEFAULT_TOKENS_CACHE_LOCATION)
token = os.environ.get(DAGSHUB_USER_TOKEN_KEY)
Expand Down Expand Up @@ -61,12 +73,3 @@
f"Number of download threads was set to {download_threads}. "
f"We recommend lowering the value if you get met with rate limits"
)


def set_host(new_host: str):
_parsed_host = urlparse(new_host)
_hostname = _parsed_host.hostname
_host = _parsed_host.geturl().rstrip("/")

global hostname, host, parsed_host
hostname, host, parsed_host = _hostname, _host, _parsed_host

0 comments on commit 8f17b7f

Please sign in to comment.