Skip to content
This repository has been archived by the owner on Jun 13, 2023. It is now read-only.

Commit

Permalink
Update abstra-cli
Browse files Browse the repository at this point in the history
  • Loading branch information
abstra-bot committed Apr 26, 2023
1 parent c624ef5 commit 146dc0e
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 4 deletions.
4 changes: 4 additions & 0 deletions abstra_cli/apis/files.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,3 +23,7 @@ def list_workspace_files():

def delete_file(filepath):
return api_main.hf_api_runner("DELETE", "file", {"filepath": filepath})


def delete_folder(path):
return api_main.hf_api_runner("DELETE", "folder", {"path": path})
17 changes: 13 additions & 4 deletions abstra_cli/apis/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
import urllib.request
import urllib.response

from .public import get_info_from_token
import abstra_cli.credentials as credentials


Expand All @@ -14,9 +13,19 @@

def get_auth_info():
api_token = credentials.get_credentials()
if not api_token:
return None, None, None
workspace_id, author_id = get_info_from_token(api_token)
headers = credentials.get_auth_headers(api_token)
response = requests.get(f"https://auth.abstra.cloud/abstra-cloud", headers=headers)
response_json = response.json()
if response_json is None:
return api_token, None, None

author_id = response_json.get("author_id")
workspaces = response_json.get("workspaces", [{}])

workspace_id = None
if len(workspaces) != 0:
workspace_id = workspaces[0].get("id")

return api_token, workspace_id, author_id


Expand Down

0 comments on commit 146dc0e

Please sign in to comment.