apache_beam.utils.python_callable module

Python Callable utilities.

For internal use only; no backwards-compatibility guarantees.

class apache_beam.utils.python_callable.PythonCallableWithSource(source: str)[source]

Bases: object

Represents a Python callable object with source codes before evaluated.

Proxy object to Store a callable object with its string form (source code). The string form is used when the object is encoded and transferred to foreign SDKs (non-Python SDKs).

Supported formats include fully-qualified names such as math.sin, expressions such as lambda x: x * x or str.upper, and multi-line function definitions such as def foo(x): … or class definitions like class Foo(…): …. If the source string contains multiple lines then lines prior to the last will be evaluated to provide the context in which to evaluate the expression, for example:

import math

lambda x: x - math.sin(x)

is a valid chunk of source code.

classmethod load_from_source(source)[source]
static load_from_expression(source)[source]
static load_from_fully_qualified_name(fully_qualified_name)[source]
static load_from_script(source, method_name=None)[source]
default_label()[source]
get_source() str[source]