Pipes Context
Pipes Context
Details
Holds the execution context received from Dagster and provides methods to report materializations, asset checks, logs, and custom messages back to the orchestrator.
Active bindings
asset_keysThe list of asset keys from the context.
asset_keyThe single asset key. Errors if there is not exactly one.
run_idThe Dagster run ID.
job_nameThe Dagster job name.
retry_numberThe current retry number.
extrasThe extras dictionary passed from Dagster.
partition_keyThe partition key, or
NULL.partition_key_rangeThe partition key range, or
NULL.partition_time_windowThe partition time window, or
NULL.is_asset_stepWhether this step involves assets.
is_partition_stepWhether this step involves partitions.
provenanceThe provenance info by asset key.
code_versionThe code version info by asset key.
Methods
Method log()
Send a log message to Dagster.
Method log_external_stream()
Send a raw external stream log (e.g. captured stdout or
stderr) to Dagster via the log_external_stream message method.
Method report_asset_materialization()
Report an asset materialization to Dagster.
Usage
PipesContext$report_asset_materialization(
metadata = NULL,
asset_key = NULL,
data_version = NULL
)Arguments
metadataA named list of metadata values. Each value may be either a raw R value (which will be auto-wrapped with type
"__infer__") or an explicitpipes_metadata_value()result.asset_keyThe asset key. If
NULL, uses the single asset key from context.data_versionOptional data version string.
Method report_asset_check()
Report an asset check result to Dagster.
Usage
PipesContext$report_asset_check(
check_name,
passed,
asset_key = NULL,
severity = "ERROR",
metadata = NULL
)Arguments
check_nameThe name of the check.
passedWhether the check passed.
asset_keyThe asset key. If
NULL, uses the single asset key from context.severityThe severity level (
"ERROR"or"WARN").metadataA named list of metadata values. Each value may be either a raw R value (which will be auto-wrapped with type
"__infer__") or an explicitpipes_metadata_value()result.
Method close()
Close the Pipes session. Optionally report an exception
to Dagster by passing an error/condition object; the exception will
be serialized into the closed message params per the Pipes protocol.
Examples
if (FALSE) { # \dontrun{
ctx <- open_dagster_pipes()
tryCatch({
output_path <- ctx$get_extra("output_path")
ctx$log("starting work", level = "INFO")
# ... do work that may fail ...
ctx$report_asset_materialization(
metadata = list(
row_count = pipes_metadata_value(1000L, "int"),
output_path = pipes_metadata_value(output_path, "path")
)
)
ctx$close()
}, error = function(e) {
# Forward the exception to Dagster via the `closed` message.
ctx$close(exception = e)
stop(e)
})
} # }