seamless_transformer.transformation_class

Transformation class

Transformation

  • kind: class
  • signature: Transformation

Resolve and evaluate transformation checksums, sync or async.

Lifecycle: - .construct() / await .construction(): Evaluate dependencies and builds the transformation dict - .compute() / await .computation() : Run the transformation dict and return the result checksum. - .run() / await .task() : compute, then resolve the result checksum into a value.

Transformation.allow_input_fingertip

  • kind: method
  • signature: allow_input_fingertip(self)

If True, inputs may be fingertipped when resolving their buffers.

Transformation.buffer

  • kind: method
  • signature: buffer(self)

No docstring.

Transformation.cancel

  • kind: method
  • signature: cancel(self, *, recursive)

Cancel this transformation promise.

Transformation.cancel_async

  • kind: method
  • signature: cancel_async(self, *, recursive)

Cancel this transformation promise.

Cancellation is terminal for this Python object. Already-running CPU work may continue outside Python's control, but its result is detached from this promise.

Transformation.celltype

  • kind: method
  • signature: celltype(self)

No docstring.

Transformation.clear_exception

  • kind: method
  • signature: clear_exception(self)

No docstring.

Transformation.computation

  • kind: method
  • signature: computation(self, require_value)

Run the transformation and return the checksum.

First, constructs the transformation; then, evaluate its result. Returns the result checksum In case of failure, set .exception and return None.

If require_value is True, it is made sure that the value will be available too. (If only the checksum is available, the transformation will be recomputed.)

Transformation.compute

  • kind: method
  • signature: compute(self)

Run the transformation and return the checksum.

First, constructs the transformation; then, evaluate its result. Returns the result checksum In case of failure, set .exception and return None.

It is made sure that the result checksum is fingertippable (resolvable or recomputable).

Transformation.construct

  • kind: method
  • signature: construct(self)

Evaluate dependencies and calculate the transformation checksum from the inputs In case of failure, set .exception and return None

Transformation.construction

  • kind: method
  • signature: construction(self)

Evaluate dependencies and calculate the transformation checksum from the inputs In case of failure, set .exception and return None

Transformation.exception

  • kind: method
  • signature: exception(self)

No docstring.

Transformation.is_cached

  • kind: method
  • signature: is_cached(self)

Return whether this transformation is present in the database cache.

Transformation.is_cached_async

  • kind: method
  • signature: is_cached_async(self)

Return whether this transformation is present in the database cache.

Transformation.logs

  • kind: method
  • signature: logs(self)

No docstring.

Transformation.meta

  • kind: method
  • signature: meta(self, meta)

No docstring.

Transformation.result_checksum

  • kind: method
  • signature: result_checksum(self)

No docstring.

Transformation.run

  • kind: method
  • signature: run(self)

Run the transformation and returns the result,

First runs .compute, then fingertip the result checksum into a value. Raise RuntimeError in case of an exception.

Transformation.scratch

  • kind: method
  • signature: scratch(self, value)

No docstring.

Transformation.start

  • kind: method
  • signature: start(self, *, loop, _internal)

Ensure the computation task is scheduled; return self for chaining.

Transformation.status

  • kind: method
  • signature: status(self)

No docstring.

Transformation.task

  • kind: method
  • signature: task(self)

Create a Task Run the transformation and returns the result,

First runs .compute, then resolve the result checksum into a value. Raise RuntimeError in case of an exception.

Transformation.transformation_checksum

  • kind: method
  • signature: transformation_checksum(self)

No docstring.

Transformation.value

  • kind: method
  • signature: value(self)

No docstring.

TransformationError

  • kind: class
  • signature: TransformationError

No docstring.

_await_task_any_loop

  • kind: function
  • signature: _await_task_any_loop(task)

Await a task that may belong to a loop running in another thread.

_compute_executor_max_workers

  • kind: function
  • signature: _compute_executor_max_workers()

No docstring.

_dask_available

  • kind: function
  • signature: _dask_available()

No docstring.

_dependency_computation

  • kind: function
  • signature: _dependency_computation(dep, *, require_value, scratch)

No docstring.

_dependency_exception

  • kind: function
  • signature: _dependency_exception(dep)

No docstring.

_dependency_message

  • kind: function
  • signature: _dependency_message(name, dependency, error)

No docstring.

_dependency_result_checksum

  • kind: function
  • signature: _dependency_result_checksum(dep, *, scratch)

No docstring.

_ensure_loop_running

  • kind: function
  • signature: _ensure_loop_running(loop)

Run the given event loop in a background thread if it is not already running.

_format_exception

  • kind: function
  • signature: _format_exception(exc)

No docstring.

_is_expression

  • kind: function
  • signature: _is_expression(value)

No docstring.

_readonly_recursive

  • kind: function
  • signature: _readonly_recursive(value)

No docstring.

_record_exception

  • kind: function
  • signature: _record_exception(exc)

No docstring.

_start_dependency

  • kind: function
  • signature: _start_dependency(dep, *, loop, scratch)

No docstring.

_sync_task_loop

  • kind: function
  • signature: _sync_task_loop()

Return the loop on which a sync caller schedules in-process computations.

A thread without a running loop uses its own loop, run in a background thread. Transformer bodies run in executor threads, so nested sync calls each get a separate loop and default executor: blocked parents never starve their children of executor threads.

A thread whose own loop is running (Jupyter, or sync code inside a coroutine) cannot block on a task of that loop. Its computations go to a shared background driver loop instead. Only such top-level callers use it, which is what the plain-script main-thread loop is used for as well.

_thread_loop_is_running

  • kind: function
  • signature: _thread_loop_is_running()

Whether the calling thread runs an event loop it cannot block on.

compute_transformation_sync

  • kind: function
  • signature: compute_transformation_sync(transformation, *, require_value)

No docstring.

loop_is_nested

  • kind: function
  • signature: loop_is_nested(loop)

No docstring.

running_in_jupyter

  • kind: function
  • signature: running_in_jupyter()

Function to detect Jupyter-like environments:

  • That have default running event loop. This prevents sync evaluation because that blocks on coroutines running in the same loop

  • That support top-level await as a go-to alternative

transformation_from_dict

  • kind: function
  • signature: transformation_from_dict(transformation_dict, *, meta, scratch, tf_dunder, strict_dunder)

Build a Transformation from an already-prepared transformation dict.

transformation_from_pretransformation

  • kind: function
  • signature: transformation_from_pretransformation(pre_transformation, *, upstream_dependencies, meta, scratch, tf_dunder, strict_dunder, post_prepare_sync, post_prepare_async)

Build a Transformation from a PreTransformation