convert

hugr.cli.convert(hugr_bytes: bytes, *, format: str | None = None, text: bool = False, binary: bool = False, compress: bool = False, compression_level: int | None = None, no_std: bool = False, extensions: list[str] | None = None) bytes[source]

Convert between different HUGR envelope formats.

Parameters:
  • hugr_bytes – The HUGR package as bytes.

  • format – Output format. One of: json, model, model-exts, model-text, model-text-exts (default: None, meaning same format as input).

  • text – Use default text-based envelope configuration. Cannot be combined with format or binary (default: False).

  • binary – Use default binary envelope configuration. Cannot be combined with format or text (default: False).

  • compress – Enable zstd compression for the output (default: False).

  • compression_level – Zstd compression level (1-22, where 1 is fastest and 22 is best compression). (default None, uses the zstd default).

  • no_std – Don’t use standard extensions when validating hugrs. Prelude is still used (default: False).

  • extensions – Paths to additional serialised extensions needed to load the HUGR.

Returns:

Converted package as bytes.