schrodinger.seam.debug module

This module provides…
  1. debug flags for the adjusting the behavior of the runner

    are used to control the behavior of the runner in ways that are useful for development and testing, but not for production. If SCHRODINGER_SRC is not set, all flags will be ignored.

  2. transforms for inspecting the contents of a PCollection

To enable a debug flag, call set_debug_flag with the flag you want to enable, like this:

`python from schrodinger.seam.runners import debug debug.set_debug_flag(debug.DebugFlag.TRANSPARENT_STDOUT) `

Alternatively, you can set the SCHRODINGER_SEAM_DEBUG_FLAGS environment variable to a comma-separated list of flags you want to enable. For example:

`shell export SCHRODINGER_SEAM_DEBUG_FLAGS=TRANSPARENT_STDOUT,RUNNER_LOGLEVEL_DEBUG `

For more information on the available flags, see DebugFlag.

class schrodinger.seam.debug.DebugFlag

Bases: enum.StrEnum

TRANSPARENT_STDOUT = 'TRANSPARENT_STDOUT'

When set, the runner will not capture stdout and stderr from local worker processes. Instead, they will be printed directly to console.

RUNNER_LOGLEVEL_INFO = 'RUNNER_LOGLEVEL_INFO'

When set, the runner will log at INFO level, logging more to the console.

RUNNER_LOGLEVEL_DEBUG = 'RUNNER_LOGLEVEL_DEBUG'

When set, the runner will log at DEBUG level, logging even more to the console.

SDKWORKER_LOGLEVEL_INFO = 'SDKWORKER_LOGLEVEL_INFO'

When set, SDK workers will log at INFO level.

SDKWORKER_LOGLEVEL_DEBUG = 'SDKWORKER_LOGLEVEL_DEBUG'

When set, SDK workers will log at DEBUG level.

NO_PARALLEL = 'NO_PARALLEL'

When set, the runner will not distribute work to multiple workers at any stage of the pipeline. Instead, any work that doesn’t get done by local workers will never get done. Useful for quickly testing a workflow that would otherwise take a long time to run.

DISABLE_LICENSE_SANITY_CHECK = 'DISABLE_LICENSE_SANITY_CHECK'

When set, any job that runs a SeamRunner will not check that the job was registered with the licenses that the pipeline will use.

schrodinger.seam.debug.set_debug_flag(*flag: schrodinger.seam.debug.DebugFlag)
schrodinger.seam.debug.get_enabled_flags() set[schrodinger.seam.debug.DebugFlag]
schrodinger.seam.debug.is_enabled(flag: schrodinger.seam.debug.DebugFlag) bool
class schrodinger.seam.debug.WriteElementsAsBeamEncodedBytes(out_path: str | pathlib.Path)

Bases: apache_beam.transforms.ptransform.PTransform

A transform that encodes elements of a PCollection as base64-encoded bytes and writes them to a text file. The elements can be decoded back using ReadElementsFromBeamEncodedBytes. This is useful for serializing arbitrary pcollections to disk for later inspection and troubleshooting.

Note that Beam coders often uses pickling to serialize elements, so this is not intended as a long term storage solution.

Example usage:

>>> from schrodinger.seam import debug
>>> with beam.Pipeline() as p:
...     (p
...      | beam.Create([1, 'foo', ('b', 'a', 'r')])
...      | debug.WriteElementsAsBeamEncodedBytes('output.txt'))
>>> with beam.Pipeline() as p:
...     deserialized = p | debug.ReadElementsFromBeamEncodedBytes('output.txt')
...     # deserialized will contain [1, 'foo', ('b', 'a', 'r')]
__init__(out_path: str | pathlib.Path)
expand(inps)
class schrodinger.seam.debug.ReadElementsFromBeamEncodedBytes(in_path: str | pathlib.Path, typehint=typing.Any)

Bases: apache_beam.transforms.ptransform.PTransform

__init__(in_path: str | pathlib.Path, typehint=typing.Any)
expand(p)
class schrodinger.seam.debug.IPythonInspect(label: Optional[str] = None)

Bases: apache_beam.transforms.ptransform.PTransform

A transform that allows you to interactively inspect the contents of a PCollection by dropping into an IPython shell.

Example usage:

>>> from schrodinger.seam import debug
>>> from schrodinger.seam.runners import SeamRunner
>>> with beam.Pipeline(runner=SeamRunner()) as p:
...    (p
...     | beam.Create([1, 2, 3])
...     | debug.IPythonInspect())
expand(pcoll)