vast-ai / vast-python

Vast.ai python and cli api client
MIT License
122 stars 48 forks source link

--order can't handle ascending order #102

Open perweij opened 8 months ago

perweij commented 8 months ago

I want to run vast search offers with the --order flag, with the arguments in ascending order.

From the README:

--order ORDER Comma-separated list of fields to sort on. postfix field with - to sort desc. ex: -o 'num_gpus,total_flops-'. default='score-'.

It works when I use postfix - for descending order:

vast search offers 'reliability > 0.99  num_gpus>=4' -o 'num_gpus-'
ID        CUDA    N  Model        PCIE  cpu_ghz  vCPUs     RAM  Disk   $/hr     DLP     DLP/$   score  NV Driver   Net_up  Net_down  R     Max_Days  mach_id  status    ports  country           
10074804  12.2  12x  RTX_4090     12.6  2.2      256.0   773.8  12819  7.2010   383.1   53.20   53.3   535.161.07  1109.7  2611.5    99.4  284.8     8866     verified  12001  North_Carolina,_US
...

but if I remove the - it crashes:

vast search offers 'reliability > 0.99  num_gpus>=4' -o 'num_gpus'
Traceback (most recent call last):
  File "/home/perweij/root/bin/vast", line 3892, in <module>
    main()
  File "/home/perweij/root/bin/vast", line 3878, in main
    sys.exit(args.func(args) or 0)
             ^^^^^^^^^^^^^^^
  File "/home/perweij/root/bin/vast", line 2310, in search__offers
    if field in offers_alias:
       ^^^^^
UnboundLocalError: cannot access local variable 'field' where it is not associated with a value

OS: Ubuntu 23.10 Vast CLI version: latest, as of today (22 Mar 2024) Python 3.11.6