Closed rickstaa closed 2 months ago
LGTM!
The base price and pixels per unit are parsed in line 807 as well but we don't retain the input amounts and currency after the autoPrice is created. Since its pretty trivial processing load, i don't see an issue parsing again here.
We could enhance this by adding a callback and moving this pricing check below the config.Pipeline switch so there is only one network != "offchain"
check per model config. With release right now, suggest we do that in a separate PR. Will create linear issue to track.
I built docker file and tested as follows with cfg.PricePerUnit = 1000 and cfg.PixelsPerUnit = 2:
price_per_unit: 10000, pixels_per_unit not set
livepeer-test-orchestrator | I0816 17:40:14.610709 1 starter.go:831] Price: 500.000 wei per compute unit
livepeer-test-orchestrator | I0816 17:40:15.107222 1 starter.go:1712] Orchestrator 0x3b28a7D785356Dc67C7970666747e042305bfB79 is active
livepeer-test-orchestrator | I0816 17:40:15.107367 1 starter.go:1061] Backfilling block events (this can take a while)...
livepeer-test-orchestrator | I0816 17:40:15.205258 1 block_watcher.go:454] Polling blocks from=243539104 to=243539183
livepeer-test-orchestrator | I0816 17:40:15.336174 1 starter.go:1066] Done backfilling block events
livepeer-test-orchestrator | I0816 17:40:15.353718 1 starter.go:1273] Capability text-to-image (ID: 27) advertised with model constraint stabilityai/sd-turbo at price 50000.000 wei per compute unit
livepeer-test-orchestrator | I0816 17:40:15.354410 1 starter.go:1547] ***Livepeer Running in Orchestrator Mode***
price_per_unit: 100000, pixels_per_unit: 1
livepeer-test-orchestrator | I0816 17:40:40.869689 1 starter.go:831] Price: 500.000 wei per compute unit
livepeer-test-orchestrator | I0816 17:40:41.349211 1 starter.go:1712] Orchestrator 0x3b28a7D785356Dc67C7970666747e042305bfB79 is active
livepeer-test-orchestrator | I0816 17:40:41.349343 1 starter.go:1061] Backfilling block events (this can take a while)...
livepeer-test-orchestrator | I0816 17:40:41.442891 1 block_watcher.go:454] Polling blocks from=243539267 to=243539290
livepeer-test-orchestrator | I0816 17:40:41.577230 1 starter.go:1066] Done backfilling block events
livepeer-test-orchestrator | I0816 17:40:41.594010 1 starter.go:1273] Capability text-to-image (ID: 27) advertised with model constraint stabilityai/sd-turbo at price 100000.000 wei per compute unit
livepeer-test-orchestrator | I0816 17:40:41.594759 1 starter.go:1547] ***Livepeer Running in Orchestrator Mode***
price_per_unit:"a"
livepeer-test-orchestrator | I0816 17:41:06.741961 1 starter.go:831] Price: 500.000 wei per compute unit
livepeer-test-orchestrator | I0816 17:41:07.238336 1 starter.go:1712] Orchestrator 0x3b28a7D785356Dc67C7970666747e042305bfB79 is active
livepeer-test-orchestrator | I0816 17:41:07.238566 1 starter.go:1061] Backfilling block events (this can take a while)...
livepeer-test-orchestrator | I0816 17:41:07.327291 1 block_watcher.go:454] Polling blocks from=243539371 to=243539392
livepeer-test-orchestrator | I0816 17:41:07.455815 1 starter.go:1066] Done backfilling block events
livepeer-test-orchestrator | E0816 17:41:07.472575 1 starter.go:1144] Error parsing -aiModels: value is not a number: "a"
pixels_per_unit: "a"
livepeer-test-orchestrator | I0816 18:01:51.838666 1 starter.go:831] Price: 500.000 wei per compute unit
livepeer-test-orchestrator | I0816 18:01:52.307451 1 starter.go:1712] Orchestrator 0x3b28a7D785356Dc67C7970666747e042305bfB79 is active
livepeer-test-orchestrator | I0816 18:01:52.307560 1 starter.go:1061] Backfilling block events (this can take a while)...
livepeer-test-orchestrator | I0816 18:01:52.402763 1 block_watcher.go:454] Polling blocks from=243544153 to=243544353
livepeer-test-orchestrator | I0816 18:01:52.529878 1 starter.go:1066] Done backfilling block events
livepeer-test-orchestrator | E0816 18:01:52.545473 1 starter.go:1144] Error parsing -aiModels: value is not a number: "a"
livepeer-test-orchestrator | I0816 18:01:52.545571 1 db.go:368] Closing DB
price_per_unit and pixels_per_unit not set
livepeer-test-orchestrator | I0816 17:41:41.963702 1 starter.go:831] Price: 500.000 wei per compute unit
livepeer-test-orchestrator | I0816 17:41:42.448320 1 starter.go:1712] Orchestrator 0x3b28a7D785356Dc67C7970666747e042305bfB79 is active
livepeer-test-orchestrator | I0816 17:41:42.448484 1 starter.go:1061] Backfilling block events (this can take a while)...
livepeer-test-orchestrator | I0816 17:41:42.541870 1 block_watcher.go:454] Polling blocks from=243539393 to=243539533
livepeer-test-orchestrator | I0816 17:41:42.679104 1 starter.go:1066] Done backfilling block events
livepeer-test-orchestrator | W0816 17:41:42.694330 1 starter.go:1168] No 'pricePerUnit' specified for model 'stabilityai/sd-turbo' in pipeline 'text-to-image'. Using default value from `-pricePerUnit`: 1000
livepeer-test-orchestrator | I0816 17:41:42.694445 1 starter.go:1273] Capability text-to-image (ID: 27) advertised with model constraint stabilityai/sd-turbo at price 500.000 wei per compute unit
livepeer-test-orchestrator | I0816 17:41:42.694669 1 starter.go:1547] ***Livepeer Running in Orchestrator Mode***
price_per_unit: 100000, pixels_per_unit: -1
livepeer-test-orchestrator | I0816 18:01:01.274430 1 starter.go:831] Price: 500.000 wei per compute unit
livepeer-test-orchestrator | I0816 18:01:01.763479 1 starter.go:1712] Orchestrator 0x3b28a7D785356Dc67C7970666747e042305bfB79 is active
livepeer-test-orchestrator | I0816 18:01:01.763609 1 starter.go:1061] Backfilling block events (this can take a while)...
livepeer-test-orchestrator | I0816 18:01:01.857399 1 block_watcher.go:454] Polling blocks from=243544101 to=243544152
livepeer-test-orchestrator | I0816 18:01:01.971863 1 starter.go:1066] Done backfilling block events
livepeer-test-orchestrator | I0816 18:01:01.988056 1 db.go:368] Closing DB
livepeer-test-orchestrator | panic: 'pixelsPerUnit' value specified for model 'stabilityai/sd-turbo' in pipeline 'text-to-image' must be a valid positive integer, provided -1.00
livepeer-test-orchestrator |
livepeer-test-orchestrator | goroutine 11 [running]:
livepeer-test-orchestrator | github.com/livepeer/go-livepeer/cmd/livepeer/starter.StartLivepeer({_, _}, {0xc0002cc760, 0xc0002cc770, 0xc0002cc780, 0xc0002cc790, 0xc0002cc7a0, 0xc0002cc7d0, 0xc0002cc7b0, 0xc0002cc910, ...})
livepeer-test-orchestrator | /src/cmd/livepeer/starter/starter.go:1157 +0xb4ce
livepeer-test-orchestrator | main.main.func1()
livepeer-test-orchestrator | /src/cmd/livepeer/livepeer.go:97 +0x59
livepeer-test-orchestrator | created by main.main in goroutine 1
livepeer-test-orchestrator | /src/cmd/livepeer/livepeer.go:96 +0xbe5
livepeer-test-orchestrator exited with code 2
price_per_unit: -100000, pixels_per_unit: 1
livepeer-test-orchestrator | I0816 17:59:49.877916 1 starter.go:831] Price: 500.000 wei per compute unit
livepeer-test-orchestrator | I0816 17:59:50.362090 1 starter.go:1712] Orchestrator 0x3b28a7D785356Dc67C7970666747e042305bfB79 is active
livepeer-test-orchestrator | I0816 17:59:50.362208 1 starter.go:1061] Backfilling block events (this can take a while)...
livepeer-test-orchestrator | I0816 17:59:50.465855 1 block_watcher.go:454] Polling blocks from=243543759 to=243543868
livepeer-test-orchestrator | I0816 17:59:50.591894 1 starter.go:1066] Done backfilling block events
livepeer-test-orchestrator | I0816 17:59:50.607725 1 db.go:368] Closing DB
livepeer-test-orchestrator | panic: 'pricePerUnit' value specified for model 'stabilityai/sd-turbo' in pipeline 'text-to-image' must be a valid positive integer, provided -100000.00
livepeer-test-orchestrator |
livepeer-test-orchestrator | goroutine 11 [running]:
livepeer-test-orchestrator | github.com/livepeer/go-livepeer/cmd/livepeer/starter.StartLivepeer({_, _}, {0xc0003237f0, 0xc000323800, 0xc000323810, 0xc000323820, 0xc000323830, 0xc000323860, 0xc000323840, 0xc0003239a0, ...})
livepeer-test-orchestrator | /src/cmd/livepeer/starter/starter.go:1170 +0xb3fa
livepeer-test-orchestrator | main.main.func1()
livepeer-test-orchestrator | /src/cmd/livepeer/livepeer.go:97 +0x59
livepeer-test-orchestrator | created by main.main in goroutine 1
livepeer-test-orchestrator | /src/cmd/livepeer/livepeer.go:96 +0xbe5
price_per_unit: "100000", pixels_per_unit: "1"
livepeer-test-orchestrator | I0816 17:59:22.103032 1 starter.go:831] Price: 500.000 wei per compute unit
livepeer-test-orchestrator | I0816 17:59:22.610861 1 starter.go:1712] Orchestrator 0x3b28a7D785356Dc67C7970666747e042305bfB79 is active
livepeer-test-orchestrator | I0816 17:59:22.610987 1 starter.go:1061] Backfilling block events (this can take a while)...
livepeer-test-orchestrator | I0816 17:59:22.711376 1 block_watcher.go:454] Polling blocks from=243543504 to=243543758
livepeer-test-orchestrator | I0816 17:59:22.855847 1 starter.go:1066] Done backfilling block events
livepeer-test-orchestrator | E0816 17:59:22.873015 1 starter.go:1144] Error parsing -aiModels: value is not a number: "100000"
livepeer-test-orchestrator | I0816 17:59:22.873153 1 db.go:368] Closing DB
@ad-astra-video Thanks so much for the quick and thorough review! Improving the logic in the configuration parsing block makes a lot of sense. I appreciate you taking the time to create an issue 🙏🏻.
What does this pull request do? Explain your changes. (required)
This pull request ensures that the code correctly handles the case where no pricePerUnit is set in the AIConfig. It also adds logic to use the value provided by the
pricePerUnit
flag if no price is given and the flag exists.Specific updates (required)
starter.go
that prevents anil
error from being thrown when users don't set a price.-pricePerUnit
flag.How did you test each of these updates (required)
Tested changes on-chain with a orchestrator and Gateway.
Does this pull request close any open issues?
Checklist:
make
runs successfully./test.sh
pass