nv_dfm_core.api.PickledObject#

class nv_dfm_core.api.PickledObject(*, tag='__dfm__pickled__', value)[source]#

A class that can serialize and deserialize a Python object to a JSON string by pickling and base64 encoding it.

Parameters:
  • tag (Literal['__dfm__pickled__'])

  • value (Any)

model_config = {}#

Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].

model_dump(*args, **kwargs)[source]#

Serialize the object by pickling and base64 encoding it.

Parameters:
  • args (Any)

  • kwargs (Any)

Return type:

dict[str, Any]

model_dump_json(*args, **kwargs)[source]#
!!! abstract “Usage Documentation”

[model_dump_json](../concepts/serialization.md#json-mode)

Generates a JSON representation of the model using Pydantic’s to_json method.

Parameters:
  • indent – Indentation to use in the JSON output. If None is passed, the output will be compact.

  • ensure_ascii – If True, the output is guaranteed to have all incoming non-ASCII characters escaped. If False (the default), these characters will be output as-is.

  • include – Field(s) to include in the JSON output.

  • exclude – Field(s) to exclude from the JSON output.

  • context – Additional context to pass to the serializer.

  • by_alias – Whether to serialize using field aliases.

  • exclude_unset – Whether to exclude fields that have not been explicitly set.

  • exclude_defaults – Whether to exclude fields that are set to their default value.

  • exclude_none – Whether to exclude fields that have a value of None.

  • exclude_computed_fields – Whether to exclude computed fields. While this can be useful for round-tripping, it is usually recommended to use the dedicated round_trip parameter instead.

  • round_trip – If True, dumped values should be valid as input for non-idempotent types such as Json[T].

  • warnings – How to handle serialization errors. False/”none” ignores them, True/”warn” logs errors, “error” raises a [PydanticSerializationError][pydantic_core.PydanticSerializationError].

  • fallback – A function to call when an unknown value is encountered. If not provided, a [PydanticSerializationError][pydantic_core.PydanticSerializationError] error is raised.

  • serialize_as_any – Whether to serialize fields with duck-typing serialization behavior.

  • args (Any)

  • kwargs (Any)

Returns:

A JSON string representation of the model.

Return type:

str

classmethod model_validate(obj, *, strict=None, from_attributes=None, context=None, by_alias=None, by_name=None)[source]#

Deserialize the object by base64 decoding and unpickling it.

Parameters:
  • obj (Any)

  • strict (bool | None)

  • from_attributes (bool | None)

  • context (Any | None)

  • by_alias (bool | None)

  • by_name (bool | None)

Return type:

Self

classmethod model_validate_json(json_data, *, strict=None, context=None, by_alias=None, by_name=None)[source]#
!!! abstract “Usage Documentation”

[JSON Parsing](../concepts/json.md#json-parsing)

Validate the given JSON data against the Pydantic model.

Parameters:
  • json_data (str | bytes | bytearray) – The JSON data to validate.

  • strict (bool | None) – Whether to enforce types strictly.

  • extra – Whether to ignore, allow, or forbid extra data during model validation. See the [extra configuration value][pydantic.ConfigDict.extra] for details.

  • context (Any | None) – Extra variables to pass to the validator.

  • by_alias (bool | None) – Whether to use the field’s alias when validating against the provided input data.

  • by_name (bool | None) – Whether to use the field’s name when validating against the provided input data.

Returns:

The validated Pydantic model.

Raises:

ValidationError – If json_data is not a JSON string or the object could not be validated.

Return type:

Self

classmethod validate_value(data)[source]#

Validate that the value can be pickled before accepting it.

Parameters:

data (dict[str, Any] | Any)

Return type:

Any