Skip to content

Commit

Permalink
Fixing other Vast API issues
Browse files Browse the repository at this point in the history
  • Loading branch information
EricTendian committed Dec 21, 2023
1 parent e9d35ef commit f4b4a36
Showing 1 changed file with 5 additions and 4 deletions.
9 changes: 5 additions & 4 deletions bin/autoscale-vast.py
Original file line number Diff line number Diff line change
Expand Up @@ -63,8 +63,9 @@ def __init__(
self.vast_api_key = os.getenv("VAST_API_KEY")
if not self.vast_api_key:
self.vast_api_key = (
open(os.path.expanduser("~/.vast_api_key")).read().strip()
open(os.path.expanduser("~/.vast_api_key")).read()
)
self.vast_api_key = self.vast_api_key.strip()

self.envs = dotenv_values(".env.vast") # type: ignore

Expand Down Expand Up @@ -187,7 +188,7 @@ def find_available_instances(self, vram_needed: float) -> list[dict]:
}

r = requests.get(
"https://console.vast.ai/api/v0/bundles",
"https://console.vast.ai/api/v0/bundles/",
params={"q": json.dumps(query)},
headers={"Authorization": f"Bearer {self.vast_api_key}"},
)
Expand All @@ -205,7 +206,7 @@ def find_available_instances(self, vram_needed: float) -> list[dict]:

def get_current_instances(self) -> list[dict]:
r = requests.get(
"https://console.vast.ai/api/v0/instances",
"https://console.vast.ai/api/v0/instances/",
params={"owner": "me"},
headers={"Authorization": f"Bearer {self.vast_api_key}"},
)
Expand Down Expand Up @@ -250,7 +251,7 @@ def create_instances(self, count: int) -> int:

instance_id = instance["id"]
# Bid 1.25x the minimum bid
bid = round(float(instance["dph_total"]) * 1.25, 6)
bid = max(round(float(instance["dph_total"]) * 1.25, 6), 0.001)

# Adjust concurrency based on GPU RAM
concurrency = floor(instance["gpu_ram"] / vram_required)
Expand Down

0 comments on commit f4b4a36

Please sign in to comment.