From f4b4a362a40a428e5b845d82a3fefba4fb454de9 Mon Sep 17 00:00:00 2001 From: Eric Tendian Date: Thu, 21 Dec 2023 11:44:07 -0600 Subject: [PATCH] Fixing other Vast API issues --- bin/autoscale-vast.py | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/bin/autoscale-vast.py b/bin/autoscale-vast.py index df7d31b..033d6c3 100755 --- a/bin/autoscale-vast.py +++ b/bin/autoscale-vast.py @@ -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 @@ -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}"}, ) @@ -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}"}, ) @@ -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)