apache_beam.typehints.typecheck module

Runtime type checking support.

For internal use only; no backwards-compatibility guarantees.

class apache_beam.typehints.typecheck.AbstractDoFnWrapper(dofn)[source]

Bases: DoFn

An abstract class to create wrapper around DoFn

wrapper(method, args, kwargs)[source]
setup()[source]
start_bundle(*args, **kwargs)[source]
process(*args, **kwargs)[source]
finish_bundle(*args, **kwargs)[source]
teardown()[source]
class apache_beam.typehints.typecheck.OutputCheckWrapperDoFn(dofn, full_label)[source]

Bases: AbstractDoFnWrapper

A DoFn that verifies against common errors in the output type.

wrapper(method, args, kwargs)[source]
class apache_beam.typehints.typecheck.TypeCheckWrapperDoFn(dofn, type_hints, label=None)[source]

Bases: AbstractDoFnWrapper

A wrapper around a DoFn which performs type-checking of input and output.

wrapper(method, args, kwargs)[source]
process(*args, **kwargs)[source]
static type_check(type_constraint, datum, is_input)[source]

Typecheck a PTransform related datum according to a type constraint.

This function is used to optionally type-check either an input or an output to a PTransform.

Parameters:
  • type_constraint – An instance of a typehints.TypeContraint, one of the white-listed builtin Python types, or a custom user class.

  • datum – An instance of a Python object.

  • is_input – True if ‘datum’ is an input to a PTransform’s DoFn. False otherwise.

Raises:

TypeError – If ‘datum’ fails to type-check according to ‘type_constraint’.

class apache_beam.typehints.typecheck.TypeCheckCombineFn(combinefn, type_hints, label=None)[source]

Bases: CombineFn

A wrapper around a CombineFn performing type-checking of input and output.

setup(*args, **kwargs)[source]
create_accumulator(*args, **kwargs)[source]
add_input(accumulator, element, *args, **kwargs)[source]
merge_accumulators(accumulators, *args, **kwargs)[source]
compact(accumulator, *args, **kwargs)[source]
extract_output(accumulator, *args, **kwargs)[source]
teardown(*args, **kwargs)[source]
class apache_beam.typehints.typecheck.TypeCheckVisitor[source]

Bases: PipelineVisitor

enter_composite_transform(applied_transform)[source]
leave_composite_transform(applied_transform)[source]
visit_transform(applied_transform)[source]
class apache_beam.typehints.typecheck.PerformanceTypeCheckVisitor[source]

Bases: PipelineVisitor

visit_transform(applied_transform)[source]
get_input_type_hints(transform)[source]
get_output_type_hints(transform)[source]