Skip to content

Commit 96f7f4f

Browse files
committed
fix: setting.json not existing
1 parent bd9d3b2 commit 96f7f4f

File tree

4 files changed

+15
-11
lines changed

4 files changed

+15
-11
lines changed

datatorch/api/client.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -30,17 +30,17 @@ def __init__(
3030
self.api_url = api_url
3131

3232
@property
33-
def api_key(self) -> str:
34-
return self._api_key or self._settings.get("API_KEY")
33+
def api_key(self) -> Union[str, None]:
34+
return self._api_key or self._settings.get("API_KEY", None)
3535

3636
@api_key.setter
3737
def api_key(self, api_key):
3838
self._api_key = api_key
3939
self.client.transport.headers["datatorch-api-key"] = self.api_key
4040

4141
@property
42-
def api_url(self) -> str:
43-
return self._api_url or self._settings.get("API_URL")
42+
def api_url(self) -> Union[str, None]:
43+
return self._api_url or self._settings.get("API_URL", None)
4444

4545
@api_url.setter
4646
def api_url(self, value):

datatorch/cli/main/commands.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
@click.command()
1313
@click.argument("key", nargs=-1)
1414
@click.option(
15-
"--host", default=BASE_URL, help="Login to a specific instance of DataTorch"
15+
"--host", default=BASE_URL, help="Url to to a specific API instance of DataTorch"
1616
)
1717
@click.option(
1818
"--no-web", is_flag=True, help="Disable opening webbrowser to access token link"

datatorch/core/settings.py

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -37,11 +37,15 @@ def set(self, key: str, value: str, globally=False, persist=True):
3737

3838
def load_json(path: str) -> dict:
3939

40-
with open(path) as fr:
41-
output = fr.read()
42-
data = json.loads(output or "{}")
43-
44-
return data
40+
try:
41+
with open(path) as fr:
42+
output = fr.read()
43+
data = json.loads(output or "{}")
44+
return data
45+
except FileNotFoundError:
46+
pass
47+
48+
return {}
4549

4650

4751
def save_json(path: str, settings: dict):

setup.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212

1313
setup(
1414
name="datatorch",
15-
version="0.1.5",
15+
version="0.1.6",
1616
description="A CLI and library for interacting with DataTorch",
1717
author="DataTorch",
1818
author_email="[email protected]",

0 commit comments

Comments
 (0)