Keyboard shortcuts

Press ← or → to navigate between chapters

Press ? to show this help

Press Esc to hide this help

LightweightContext: 경량 실행 맥락

transforms.api.LightweightContext는 경량 단일 노드 변환의 compute 함수에 선택적으로 주입하는 맥락 객체입니다. 함수에 ctx 인자를 추가합니다. Spark의 TransformContext에 대응하는 역할이며, Spark 세션을 제공하는 유형으로 사용하지 않습니다.

메서드 또는 속성동작
abort_job()작업 실행을 종료하고 이 작업의 모든 출력 트랜잭션을 중단
auth_header변환 실행에 사용하는 인증 헤더
is_incremental현재 증분 실행인지 여부

다음은 값 매개변수로 작업 중단 여부를 전달하는 가상 예시입니다. 해당 매개변수 기능의 저장소 버전 조건을 충족하고 polars를 run 의존성으로 추가합니다.

from transforms.api import BooleanParam, Input, Output, transform


@transform.using(
    my_input=Input("/path/to/input"),
    my_output=Output("/path/to/output"),
    abort_requested=BooleanParam(False),
)
def compute(ctx, my_input, my_output, abort_requested):
    if abort_requested.value:
        ctx.abort_job()
    my_output.write_table(my_input.polars(lazy=True))

인증 헤더를 로그나 출력에 남기지 않습니다. 증분 여부를 기준으로 중단하는 로직에서는 초기 비증분 빌드까지 중단되는지 확인해야 합니다.