Skip to content

Commit

Permalink
minor login flow updates (#796)
Browse files Browse the repository at this point in the history
  • Loading branch information
jlewitt1 authored May 9, 2024
1 parent 42ecf3f commit 76d805e
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 7 deletions.
15 changes: 10 additions & 5 deletions runhouse/resources/secrets/secret.py
Original file line number Diff line number Diff line change
Expand Up @@ -173,11 +173,16 @@ def local_secrets(cls, names: List[str] = None) -> Dict[str, "Secret"]:
secrets = {}
for name in names:
path = os.path.expanduser(f"~/.rh/secrets/{name}.json")
with open(path, "r") as f:
config = json.load(f)
if config["name"].startswith("~") or config["name"].startswith("^"):
config["name"] = config["name"][2:]
secrets[name] = Secret.from_config(config)
try:
with open(path, "r") as f:
config = json.load(f)
if config["name"].startswith("~") or config["name"].startswith("^"):
config["name"] = config["name"][2:]
secrets[name] = Secret.from_config(config)
except json.JSONDecodeError:
# Ignore any empty / corrupted files
continue

return secrets

@classmethod
Expand Down
6 changes: 4 additions & 2 deletions runhouse/rns/login.py
Original file line number Diff line number Diff line change
Expand Up @@ -83,12 +83,14 @@ def login(
)
token = getpass("Token: ")

if not configs.CONFIG_PATH.exists():
rh_config_exists = configs.CONFIG_PATH.exists()
if not rh_config_exists:
upload_config = False

# download the config automatically if no config.yaml exists
download_config = (
download_config
if download_config is not None
if download_config is not None or not rh_config_exists
else typer.confirm(
"Download your Runhouse config to your local .rh folder?",
default=True,
Expand Down

0 comments on commit 76d805e

Please sign in to comment.