feat(pricing): add -pricingUnitSize flag, deprecate -pixelsPerUnit - #3942
feat(pricing): add -pricingUnitSize flag, deprecate -pixelsPerUnit#3942rickstaa wants to merge 3 commits into
Conversation
|
Note Reviews pausedIt looks like this branch is under active development. To avoid overwhelming you with review comments due to an influx of new commits, CodeRabbit has automatically paused this review. You can configure this behavior by changing the Use the following commands to manage reviews:
Use the checkboxes below for quick actions:
📝 WalkthroughWalkthroughThis PR renames the CLI pricing scale flag from ChangesPricing Unit Size Flag Aliasing
Estimated code review effort🎯 2 (Simple) | ⏱️ ~8 minutes Possibly related issues
Poem
🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
ca923a0 to
cf8e7c8
Compare
There was a problem hiding this comment.
Actionable comments posted: 1
🧹 Nitpick comments (1)
cmd/livepeer/starter/starter_test.go (1)
403-417: ⚡ Quick winAdd a precedence case when both flags are passed.
This test is solid for one-flag inputs; add a case with both
-unitScaleand-pixelsPerUnitin the same parse to lock expected precedence behavior.Proposed test extension
func TestNewLivepeerConfig_UnitScaleFlag(t *testing.T) { require := require.New(t) // -unitScale sets PixelsPerUnit. fs := flag.NewFlagSet("livepeer-test", flag.ContinueOnError) cfg := NewLivepeerConfig(fs) require.NoError(fs.Parse([]string{"-unitScale", "1000000000000"})) require.Equal("1000000000000", *cfg.PixelsPerUnit) // -pixelsPerUnit is a deprecated alias for the same value. fs = flag.NewFlagSet("livepeer-test", flag.ContinueOnError) cfg = NewLivepeerConfig(fs) require.NoError(fs.Parse([]string{"-pixelsPerUnit", "42"})) require.Equal("42", *cfg.PixelsPerUnit) + + // If both are present, last one wins (Go flag parse order). + fs = flag.NewFlagSet("livepeer-test", flag.ContinueOnError) + cfg = NewLivepeerConfig(fs) + require.NoError(fs.Parse([]string{"-unitScale", "10", "-pixelsPerUnit", "20"})) + require.Equal("20", *cfg.PixelsPerUnit) }🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the rest with a brief reason, keep changes minimal, and validate. In `@cmd/livepeer/starter/starter_test.go` around lines 403 - 417, Add a precedence test inside TestNewLivepeerConfig_UnitScaleFlag that parses both flags together to lock expected behavior: call fs.Parse with both "-pixelsPerUnit" and "-unitScale" (e.g. []string{"-pixelsPerUnit","42","-unitScale","1000000000000"}) on a NewLivepeerConfig(fs) and assert cfg.PixelsPerUnit equals the value for -unitScale (the newer flag), and optionally repeat with the flags reversed to ensure order-independent precedence; reference NewLivepeerConfig and cfg.PixelsPerUnit when locating where to add the assertion.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In `@cmd/livepeer/starter/flags.go`:
- Around line 106-109: Update the runtime validation and log messages in
cmd/livepeer/starter/starter.go to use the new primary flag name "-unitScale"
(and mention "-pixelsPerUnit" only as deprecated) and to say "price per unit"
(or "work unit") instead of "price per pixel"; locate the checks and log/error
strings that reference cfg.PixelsPerUnit, "-pixelsPerUnit", or "price per pixel"
and change their wording to prefer "-unitScale" and "price per unit" so users
setting -unitScale see correct guidance.
---
Nitpick comments:
In `@cmd/livepeer/starter/starter_test.go`:
- Around line 403-417: Add a precedence test inside
TestNewLivepeerConfig_UnitScaleFlag that parses both flags together to lock
expected behavior: call fs.Parse with both "-pixelsPerUnit" and "-unitScale"
(e.g. []string{"-pixelsPerUnit","42","-unitScale","1000000000000"}) on a
NewLivepeerConfig(fs) and assert cfg.PixelsPerUnit equals the value for
-unitScale (the newer flag), and optionally repeat with the flags reversed to
ensure order-independent precedence; reference NewLivepeerConfig and
cfg.PixelsPerUnit when locating where to add the assertion.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: defaults
Review profile: CHILL
Plan: Pro
Run ID: 8e411cba-2c9d-4c68-a712-d278132ad85d
📒 Files selected for processing (2)
cmd/livepeer/starter/flags.gocmd/livepeer/starter/starter_test.go
`pixelsPerUnit` is really just a pricing scale factor: price is quoted per N work units (`price_per_work_unit = pricePerUnit / pixelsPerUnit`). The "pixels" name is transcoding-era legacy and is confusing for non-video / BYOC runners, where there are no pixels. Add `-unitScale` as the clearer primary flag and keep `-pixelsPerUnit` as a deprecated alias writing to the same config (following the datadir/dataDir pattern). Update the pricePerUnit/maxPricePerUnit help text to reference unitScale. No wire or config-format changes: the proto field and the config struct are untouched, so existing clients, discovery JSON, and configs keep working. Only the user-facing flag is renamed, with the old name still accepted. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
cf8e7c8 to
daa6847
Compare
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## master #3942 +/- ##
===================================================
- Coverage 33.30014% 33.29223% -0.00791%
===================================================
Files 171 171
Lines 42174 42175 +1
===================================================
- Hits 14044 14041 -3
- Misses 27077 27080 +3
- Partials 1053 1054 +1
... and 6 files with indirect coverage changes Continue to review full report in Codecov by Harness.
🚀 New features to boost your workflow:
|
pricingUnitSize reads as the size of one pricing unit (in work units), which parallels pricePerUnit and makes the direction unambiguous (larger = coarser granularity). The "pricing" qualifier keeps the flag self-documenting in isolation (config files, run commands) where the neighboring price flags aren't visible, and avoids the "unit of price" misread of priceUnitSize. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
cee0907 to
91b0432
Compare
There was a problem hiding this comment.
🧹 Nitpick comments (1)
cmd/livepeer/starter/starter_test.go (1)
403-423: ⚡ Quick winAdd a combined-flags precedence test to lock expected behavior.
Please add one case parsing both
-unitSizeand-pixelsPerUnitin the same argv and assert which one should win (typically last occurrence). This prevents ambiguity regressions while both names coexist.🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the rest with a brief reason, keep changes minimal, and validate. In `@cmd/livepeer/starter/starter_test.go` around lines 403 - 423, Add a new test case to the TestNewLivepeerConfig_UnitSizeFlag function that parses both the -unitSize and -pixelsPerUnit flags together in the same argv to test flag precedence behavior. Create a new FlagSet, initialize NewLivepeerConfig with it, parse a slice containing both flags (in the order that determines which should take precedence, typically with one appearing last), and then assert that PixelsPerUnit equals the value of the flag that should win according to the expected precedence rules. This locks in the intended behavior when both flags are provided simultaneously.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Nitpick comments:
In `@cmd/livepeer/starter/starter_test.go`:
- Around line 403-423: Add a new test case to the
TestNewLivepeerConfig_UnitSizeFlag function that parses both the -unitSize and
-pixelsPerUnit flags together in the same argv to test flag precedence behavior.
Create a new FlagSet, initialize NewLivepeerConfig with it, parse a slice
containing both flags (in the order that determines which should take
precedence, typically with one appearing last), and then assert that
PixelsPerUnit equals the value of the flag that should win according to the
expected precedence rules. This locks in the intended behavior when both flags
are provided simultaneously.
ℹ️ Review info
⚙️ Run configuration
Configuration used: defaults
Review profile: CHILL
Plan: Pro
Run ID: 6188c9a5-42d0-46d2-b7e2-fc7f518bd63b
📒 Files selected for processing (2)
cmd/livepeer/starter/flags.gocmd/livepeer/starter/starter_test.go
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
What
pixelsPerUnitis really just a pricing scale factor: it's the number of work units that one quoted price covers (price_per_work_unit = pricePerUnit / pixelsPerUnit). The "pixels" name is transcoding-era legacy and is confusing for non-video / BYOC / general-runner workloads, where there are no pixels.This adds
-pricingUnitSizeas the clearer primary flag and keeps-pixelsPerUnitas a deprecated alias writing to the same config value, following the existingdatadir/dataDirdeprecation pattern.Why
pricingUnitSize?The value is the size of one pricing unit, measured in work units:
pricePerUnitis the price forpricingUnitSizework units, soprice_per_work_unit = pricePerUnit / pricingUnitSize.pricePerUnit/maxPricePerUnit, all rooted inpric-.priceUnitSizeinvites, and the doubled-"unit" confusion ofworkUnitsPerUnit.Changes
-pricingUnitSizeflag (primary) +-pixelsPerUnitkept as a[Deprecated]alias to the samecfg.PixelsPerUnit.-pricePerUnit/-maxPricePerUnithelp text to referencepricingUnitSize.PixelsPerUnit.Compatibility
No wire or config-format changes. The proto field (
PriceInfo.pixelsPerUnit), the config struct field, discovery JSON, and thepixels_per_unit/pixelsperunitkeys in-maxPricePerCapability/-pricePerGatewayJSON are all untouched, so existing clients and deployments keep working. Only the user-facing flag is renamed, with the old name still accepted.A follow-up could rename the proto/JSON field in a coordinated, versioned way, but that is intentionally out of scope here to avoid breaking clients.
Summary by CodeRabbit
Summary
New Features
-pricingUnitSizecommand-line flag to configure work-unit pricing scale (mapped to the existing per-unit pricing configuration).Documentation
-pixelsPerUnitas deprecated and clarified it aliases-pricingUnitSize.Tests
PixelsPerUnitbehavior,-pricingUnitSizeparsing, and backward compatibility with-pixelsPerUnit.Chores
Checklist:
makeruns successfully./test.shpass