Skip to content

Commit 7f62002

Browse files
committed
Warn if readonly is True
1 parent aa53ce7 commit 7f62002

File tree

2 files changed

+11
-1
lines changed

2 files changed

+11
-1
lines changed

libs/labelbox/src/labelbox/data/annotation_types/relationship.py

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
from typing import Union, Optional
2-
from pydantic import BaseModel
2+
from pydantic import BaseModel, model_validator
33
from enum import Enum
4+
import warnings
45
from labelbox.data.annotation_types.annotation import (
56
BaseAnnotation,
67
ObjectAnnotation,
@@ -18,6 +19,14 @@ class Type(Enum):
1819
type: Type = Type.UNIDIRECTIONAL
1920
readonly: Optional[bool] = None
2021

22+
@model_validator(mode='after')
23+
def check_readonly(self):
24+
if self.readonly is True:
25+
warnings.warn(
26+
"Creating a relationship with readonly=True is in beta and its behavior may change in future releases.",
27+
)
28+
return self
29+
2130

2231
class RelationshipAnnotation(BaseAnnotation):
2332
value: Relationship

libs/labelbox/src/labelbox/data/serialization/ndjson/relationship.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@ def to_common(
3131
source=source,
3232
target=target,
3333
type=Relationship.Type(annotation.relationship.type),
34+
readonly=annotation.relationship.readonly,
3435
),
3536
extra={"uuid": annotation.uuid},
3637
feature_schema_id=annotation.schema_id,

0 commit comments

Comments
 (0)