flytekit
flytekit copied to clipboard
Add to_string method to literal
Tracking issue
NA
Why are the changes needed?
It's hard to read Literal.__str__, especially when you have a nested list or dict.
What changes were proposed in this pull request?
Add to_string to Literal to customize the representational string
How was this patch tested?
int_literal = Literal(scalar=Scalar(primitive=Primitive(integer=1)))
print(int_literal)
large_dict = Literal(map=LiteralMap({str(i): Literal(scalar=Scalar(primitive=Primitive(integer=i))) for i in range(100)}))
print(large_dict)
union_literal = Literal(scalar=Scalar(union=Union(value=large_dict, stored_type=LiteralType(SimpleType.INTEGER))))
print(union_literal)
Before:
After: