Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ resources:
max_concurrent_runs: 1
parameters:
- name: batch_size
default: "0"
default: "250"
tasks:
- task_key: validate_configuration
max_retries: 0
Expand Down
34 changes: 22 additions & 12 deletions knowledge_base/failing_job_examples/src/invalid_configuration.py
Original file line number Diff line number Diff line change
@@ -1,14 +1,24 @@
# Databricks notebook source
batch_size_value = dbutils.widgets.get("batch_size")
def parse_positive_batch_size(value):
"""Parse *value* as a positive integer batch size.

Raises ValueError with a descriptive message if *value* cannot be
converted to an integer or is not greater than zero.
"""
try:
batch_size = int(value)
except ValueError:
raise ValueError(
f"Invalid job configuration: batch_size must be an integer, found {value!r}"
) from None

if batch_size <= 0:
raise ValueError(
f"Invalid job configuration: batch_size must be greater than zero, found {batch_size}"
)

try:
batch_size = int(batch_size_value)
except ValueError:
raise ValueError(
f"Invalid job configuration: batch_size must be an integer, found {batch_size_value!r}"
) from None

if batch_size <= 0:
raise ValueError(
f"Invalid job configuration: batch_size must be greater than zero, found {batch_size}"
)
return batch_size


batch_size_value = dbutils.widgets.get("batch_size")
batch_size = parse_positive_batch_size(batch_size_value)