feat(pricing): add -unitScale flag, deprecate -pixelsPerUnit#3942
feat(pricing): add -unitScale flag, deprecate -pixelsPerUnit#3942rickstaa wants to merge 1 commit into
Conversation
📝 WalkthroughWalkthroughThis PR renames the CLI pricing scale flag from ChangesUnit Scale Flag Aliasing
Estimated code review effort🎯 2 (Simple) | ⏱️ ~8 minutes 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
| // Scale factor for both O's pricePerUnit and B's maxPricePerUnit: price is | ||
| // quoted per this many work units. -pixelsPerUnit is the deprecated alias. | ||
| fs.StringVar(cfg.PixelsPerUnit, "unitScale", *cfg.PixelsPerUnit, "Scale factor for pricing: price is quoted per this many work units. Set > 1 for finer price granularity than 1 wei per unit.") | ||
| fs.StringVar(cfg.PixelsPerUnit, "pixelsPerUnit", *cfg.PixelsPerUnit, "[Deprecated] Use -unitScale. Amount of pixels per unit; set > 1 for smaller price granularity than 1 wei / pixel.") |
There was a problem hiding this comment.
Align runtime validation/log wording with -unitScale as primary flag.
After this rename, startup validation/logging still refers to -pixelsPerUnit and “price per pixel” in cmd/livepeer/starter/starter.go (Lines 1137-1166 in the provided snippet). Users setting -unitScale will get misleading guidance on failures. Please update those messages to prefer -unitScale (optionally mention -pixelsPerUnit as deprecated alias).
🤖 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/flags.go` around lines 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.
`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.28986% -0.01028%
===================================================
Files 171 171
Lines 42174 42175 +1
===================================================
- Hits 14044 14040 -4
- Misses 27077 27080 +3
- Partials 1053 1055 +2
... and 3 files with indirect coverage changes Continue to review full report in Codecov by Harness.
🚀 New features to boost your workflow:
|
What
pixelsPerUnitis 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 / general-runner workloads, where there are no pixels.This adds
-unitScaleas the clearer primary flag and keeps-pixelsPerUnitas a deprecated alias writing to the same config value, following the existingdatadir/dataDirdeprecation pattern.@j0sh not really set on the naming, if you have a better naming let me know. However the
pixelsPerUnitfeels less accurate.Changes
-unitScaleflag (primary) +-pixelsPerUnitkept as a[Deprecated]alias to the samecfg.PixelsPerUnit.-pricePerUnit/-maxPricePerUnithelp text to referenceunitScale.PixelsPerUnit.Compatibility
No wire or config-format changes. The proto field (
PriceInfo.pixelsPerUnit), the config struct field, discovery JSON, and all existing configs are 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
New Features
-unitScalecommand-line flag for configuring work-unit pricing scaleDocumentation
-pixelsPerUnitas deprecated in favor of-unitScaleTests