Skip to content

Commit 2cb71db

Browse files
committed
Merge feat/1446-A-priced-for-everywhere: #1467
2 parents 2ce2776 + 9d301f4 commit 2cb71db

3 files changed

Lines changed: 74 additions & 5 deletions

File tree

‎docs/SERVER.md‎

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -164,7 +164,8 @@ icon, a finish-alert toggle, the theme toggle, and links to these docs and
164164
the answer carries a plan it is shown under the verdict - under the error
165165
list too when the answer is invalid, as one naming a repo that isn't there
166166
is. The plan reads: step and list counts; the estimate with its basis, the
167-
card it is priced for, whether it is low confidence, blended toward the
167+
card it is priced for when that says more than the backend (`on <card>`,
168+
or `- for <card>` closing an inherited or no-figure line), whether it is low confidence, blended toward the
168169
curated figure, inherited from a template, or withheld (with the template
169170
it was not priced from) or unpriced for a stated reason; the host RAM the
170171
run is projected to hold (`host RAM ~N GB (observed | fit to N runs |

‎ui/src/lib/plan.test.ts‎

Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -308,6 +308,60 @@ describe('describePlan', () => {
308308
})
309309
})
310310

311+
it('an inherited or unpriced figure names the card last when it differs from the device', () => {
312+
const card = 'mps Apple M5 Pro (MPS)'
313+
const inherited = {
314+
...base.estimate,
315+
device: 'mps',
316+
basis: 'inherited' as const,
317+
inherited_from: 'templates/text-to-image',
318+
priced_for: card,
319+
}
320+
const [, firm] = describePlan({ ...base, estimate: inherited })
321+
expect(firm).toEqual({
322+
text: `~42 min, inherited from templates/text-to-image - for ${card}`,
323+
tone: 'plain',
324+
})
325+
const [, thin] = describePlan({
326+
...base,
327+
estimate: { ...inherited, low_confidence: true },
328+
})
329+
expect(thin).toEqual({
330+
text: `~42 min, inherited from templates/text-to-image, low confidence - for ${card}`,
331+
tone: 'warn',
332+
})
333+
const unknown = {
334+
...inherited,
335+
minutes: null,
336+
basis: 'unknown' as const,
337+
measured_on: null,
338+
cached_minutes: null,
339+
}
340+
const [, withheld] = describePlan({
341+
...base,
342+
estimate: { ...unknown, withheld: 'frames differ' },
343+
})
344+
expect(withheld).toEqual({
345+
text: `no figure - withheld (not priced from templates/text-to-image) - for ${card}`,
346+
tone: 'warn',
347+
})
348+
const [, reason] = describePlan({
349+
...base,
350+
estimate: { ...unknown, inherited_from: undefined, unpriced_reason: 'no run here' },
351+
})
352+
expect(reason.text).toBe(`no figure - no run here - for ${card}`)
353+
const [, bare] = describePlan({
354+
...base,
355+
estimate: { ...unknown, inherited_from: undefined },
356+
})
357+
expect(bare.text).toBe(`no measured cost - for ${card}`)
358+
const [, same] = describePlan({
359+
...base,
360+
estimate: { ...inherited, priced_for: 'mps' },
361+
})
362+
expect(same.text).toBe('~42 min, inherited from templates/text-to-image')
363+
})
364+
311365
it('an unpriced reason replaces the bare no measured cost', () => {
312366
const [, figure] = describePlan({
313367
...base,

‎ui/src/lib/plan.ts‎

Lines changed: 18 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -101,13 +101,27 @@ function qualifiers(estimate: Plan['estimate']) {
101101

102102
function figure(plan: Plan): PlanLine {
103103
const line = rawFigure(plan)
104-
if (plan.estimate.basis === 'unknown' || plan.estimate.minutes === null) {
105-
return line
104+
const { basis, minutes } = plan.estimate
105+
// the lines that say no "on X" name the card the run dispatches to last,
106+
// so their own wording reads as it does without one
107+
const forCard =
108+
basis === 'unknown' || minutes === null || basis === 'inherited'
109+
? dispatchCard(plan.estimate)
110+
: ''
111+
if (basis === 'unknown' || minutes === null) {
112+
return { text: `${line.text}${forCard}`, tone: line.tone }
106113
}
107114
const text = `${line.text}${tempered(plan.estimate)}`
108115
return plan.estimate.low_confidence
109-
? { text: `${text}, low confidence`, tone: 'warn' }
110-
: { text, tone: line.tone }
116+
? { text: `${text}, low confidence${forCard}`, tone: 'warn' }
117+
: { text: `${text}${forCard}`, tone: line.tone }
118+
}
119+
120+
/** ` - for <card>` when the card the run dispatches to says more than the
121+
* backend, else nothing. */
122+
function dispatchCard(estimate: Plan['estimate']): string {
123+
const { priced_for, device } = estimate
124+
return priced_for && priced_for !== device ? ` - for ${priced_for}` : ''
111125
}
112126

113127
function rawFigure(plan: Plan): PlanLine {

0 commit comments

Comments
 (0)