vast-ai / vast-python

Vast.ai python and cli api client
MIT License
117 stars 44 forks source link

Missing ability to get open ports #112

Open oxysoft opened 2 months ago

oxysoft commented 2 months ago

I am opening ports like this: --env '-p 8188:8188'. The real effective port is shown in the console on the website and doesn't appear to be retrievable from this script, which is a problem since I want to automate a lot of separate instances.

twinnedAI commented 2 months ago

@oxysoft you can get the port mapping of an instance by using the raw flag. This returns a json object with all informations:

CLI:

vastai show instance <id> --raw

Python:

from vastai import VastAI
import json

client = VastAI(api_key='1234', raw=True)
instance_raw = client.show_instance(id=instance_id)
print(json.loads(instance_raw))