px.field
px.field(...)는 planned @px.record 안의 값 하나를 설명할 contract_only marker입니다. 현재 public facade에는 두 symbol 모두 없습니다.
무엇을 만드나요?
승인된 후에는 Record field의 설명, 단위, 제약과 default를 schema에 추가하고 field의 이름과 타입은 class 선언에서 가져옵니다.
Studio에서는 어디에 보이나요?
planned Record를 사용하는 port의 Typed ports와 값 inspector 안에 field 이름, 타입과 단위로 보이는 목표 계약입니다.
문법
이 예제는 contract_only이며 현재 SDK에서 실행할 수 없습니다.
python
px.field(
*,
description,
unit=None,
constraints=None,
default=px.REQUIRED,
)최소 예제
이 예제는 contract_only이며 현재 SDK에서 실행할 수 없습니다.
python
from pipelinexlab import px
@px.record("section", description="Rectangular section dimensions.")
class Section:
width: float = px.field(unit="m", description="Section width.")
depth: float = px.field(
unit="m",
description="Section depth.",
constraints={"exclusiveMinimum": 0},
)매개변수
| 이름 | 설명 |
|---|---|
description | field 값의 의미를 설명하는 필수 문장 |
unit | 숫자 공학 값의 기준 단위 |
constraints | 최소값 등 field 값 제약 |
default | field를 생략했을 때 사용할 값. 기본값 px.REQUIRED |
반환값과 handle
승인된 계약에서는 Record class field에 붙는 metadata marker를 반환합니다. field 하나는 독립 Canvas port가 아니며 Record 전체가 하나의 port handle로 전달됩니다.
규칙과 진단
- planned
px.field(...)는@px.recordclass 안에서 사용합니다. - field 이름이 field key이고 Python annotation이 타입과 null 허용 여부를 정합니다.
- required 여부는
default유무로 정합니다. - field에 연결 가능 여부를 작성하지 않습니다. planned 계약에서 연결 여부는 Record를 받는 top-level
px.input(...)또는px.result(...)가 정합니다. - annotation과 default·constraint가 맞지 않으면 schema validation에서 field를 가리켜 표시합니다.