* Check for input blocks that need values.
(blocks: DeepnoteBlock[], blockMap: Map<string, BlockInfo>)
| 576 | * Check for input blocks that need values. |
| 577 | */ |
| 578 | function checkMissingInputs(blocks: DeepnoteBlock[], blockMap: Map<string, BlockInfo>): InputCheckResult { |
| 579 | const issues: LintIssue[] = [] |
| 580 | const inputsWithValues: string[] = [] |
| 581 | const inputsNeedingValues: string[] = [] |
| 582 | |
| 583 | for (const block of blocks) { |
| 584 | if (!INPUT_BLOCK_TYPES.has(block.type)) continue |
| 585 | |
| 586 | const metadata = block.metadata as Record<string, unknown> |
| 587 | const variableName = metadata.deepnote_variable_name as string |
| 588 | const currentValue = metadata.deepnote_variable_value |
| 589 | |
| 590 | if (!variableName) continue |
| 591 | |
| 592 | const info = blockMap.get(block.id) |
| 593 | if (!info) continue |
| 594 | |
| 595 | const hasValue = currentValue !== undefined && currentValue !== '' && currentValue !== null |
| 596 | |
| 597 | if (hasValue) { |
| 598 | inputsWithValues.push(variableName) |
| 599 | } else { |
| 600 | inputsNeedingValues.push(variableName) |
| 601 | |
| 602 | issues.push({ |
| 603 | severity: 'warning', |
| 604 | code: 'missing-input', |
| 605 | message: `Input "${variableName}" has no default value (use --input ${variableName}=<value> when running)`, |
| 606 | blockId: block.id, |
| 607 | blockLabel: info.label, |
| 608 | notebookName: info.notebookName, |
| 609 | details: { variableName, inputType: block.type }, |
| 610 | }) |
| 611 | } |
| 612 | } |
| 613 | |
| 614 | return { |
| 615 | issues, |
| 616 | summary: { |
| 617 | total: inputsWithValues.length + inputsNeedingValues.length, |
| 618 | withValues: inputsWithValues.length, |
| 619 | needingValues: inputsNeedingValues.sort(), |
| 620 | }, |
| 621 | } |
| 622 | } |
| 623 | |
| 624 | // ============================================================================ |
| 625 | // Stats Helper Functions |