Skip to content
ASDF Projects Tutorials Community
Back to top
View this page

# AsdfConfig

class asdf.config.AsdfConfig

  Bases: `object`

  Container for ASDF configuration options. Users are not intended to construct this object directly; instead, use the `asdf.get_config` and `asdf.config_context` module methods.

  Attributes Summary

  `all_array_compression` | Override the compression type on all binary blocks in the file.
  `all_array_compression_kwargs` | Dictionary of keyword arguments provided to the compressor during block compression (or `None` for no keyword arguments)
  `all_array_storage` | Override the array storage type of all blocks in the file immediately before writing.
  `array_inline_threshold` | Get the threshold below which arrays are automatically written as inline YAML literals instead of binary blocks.
  `default_array_save_base` | Option to control if when saving arrays the base array should be saved (so views of the same array will refer to offsets/strides of the same block).
  `default_version` | Get the default ASDF core schemas version used for new files.
  `extensions` | Get the list of registered extensions.
  `io_block_size` | Get the block size used when reading and writing files.
  `lazy_tree` | Get configuration that controls if ASDF tree contents are lazily converted to custom objects or if all custom objects are created when the file is opened.
  `legacy_fill_schema_defaults` | Get the configuration that controls filling defaults from schemas for older ASDF core schemas versions.
  `resource_manager` | Get the `asdf.resource.ResourceManager` instance.
  `resource_mappings` | Get the list of registered resource mapping instances.
  `validate_on_read` | Get configuration that controls schema validation of ASDF files on read.
  `warn_on_failed_conversion` | Get configuration that controls if errors during conversion are converted to warnings.

  Methods Summary

  `add_extension`(extension) | Register a new extension.
  `add_resource_mapping`(mapping) | Register a new resource mapping.
  `remove_extension`([extension, package]) | Remove a registered extension.
  `remove_resource_mapping`([mapping, package]) | Remove a registered resource mapping.
  `reset_extensions`() | Reset extensions to the default list registered via entry points.
  `reset_resources`() | Reset registered resource mappings to the default list provided as entry points.

  Attributes Documentation

  all_array_compression

    Override the compression type on all binary blocks in the file. Must be one of the following strings, `None` or a label supported by a `asdf.extension.Compressor`:

    - `''` or `None`: No compression.

    - `zlib`: Use zlib compression.

    - `bzp2`: Use bzip2 compression.

    - `lz4`: Use lz4 compression.

    - `input`: Use the same compression as in the file read. If there is no prior file, acts as None

  all_array_compression_kwargs

    Dictionary of keyword arguments provided to the compressor during block compression (or `None` for no keyword arguments)

  all_array_storage

    Override the array storage type of all blocks in the file immediately before writing. Must be one of the following strings or `None`:

    - `internal`: The default. The array data will be stored in a binary block in the same ASDF file.

    - `external`: Store the data in a binary block in a separate ASDF file.

    - `inline`: Store the data as YAML inline in the tree.

  array_inline_threshold

    Get the threshold below which arrays are automatically written as inline YAML literals instead of binary blocks. This number is compared to number of elements in the array.

    Returns:
      int or None

        Integer threshold, or None to disable automatic selection of the array storage type.

  default_array_save_base

    Option to control if when saving arrays the base array should be saved (so views of the same array will refer to offsets/strides of the same block).

  default_version

    Get the default ASDF core schemas version used for new files.

    Returns:
      str
  extensions

    Get the list of registered extensions.

    Returns:
      list of asdf.extension.ExtensionProxy
  io_block_size

    Get the block size used when reading and writing files.

    Returns:
      int

        Block size, or -1 to use the filesystem’s preferred block size.

  lazy_tree

    Get configuration that controls if ASDF tree contents are lazily converted to custom objects or if all custom objects are created when the file is opened. See the `lazy_tree` argument for `asdf.open`.

    Returns:
      bool
  legacy_fill_schema_defaults

    Get the configuration that controls filling defaults from schemas for older ASDF core schemas versions. If `True`, missing default values will be filled from the schema when reading files from ASDF core schemas <= 1.5.0. Later versions of the core schemas do not support removing or filling schema defaults.

    Returns:
      bool
  resource_manager

    Get the `asdf.resource.ResourceManager` instance. Includes resources from registered resource mappings and any mappings added at runtime.

    Returns:
      `asdf.resource.ResourceManager`
  resource_mappings

    Get the list of registered resource mapping instances. Unless overridden by user configuration, this list contains every mapping registered with an entry point.

    Returns:
      list of asdf.resource.ResourceMappingProxy
  validate_on_read

    Get configuration that controls schema validation of ASDF files on read.

    Returns:
      bool
  warn_on_failed_conversion

    Get configuration that controls if errors during conversion are converted to warnings.

    Enabling this can be helpful when opening old files that contain tags that are no longer supported.

    Returns:
      bool

  Methods Documentation

  add_extension(extension)

    Register a new extension. The new extension will take precedence over all previously registered extensions.

    Parameters:
      extension asdf.extension.Extension
  add_resource_mapping(mapping)

    Register a new resource mapping. The new mapping will take precedence over all previously registered mappings.

    Parameters:
      mapping collections.abc.Mapping

        Map of `str` resource URI to `bytes` content

  remove_extension(extension=None, *, package=None)

    Remove a registered extension.

    Parameters:
      extension asdf.extension.Extension or str, optional

        An extension instance or URI pattern to remove.

      package str, optional

        Remove only extensions provided by this package. If the `extension` argument is omitted, then all extensions from this package will be removed.

  remove_resource_mapping(mapping=None, *, package=None)

    Remove a registered resource mapping.

    Parameters:
      mapping collections.abc.Mapping, optional

        Mapping to remove.

      package str, optional

        Remove only extensions provided by this package. If the `mapping` argument is omitted, then all mappings from this package will be removed.

  reset_extensions()

    Reset extensions to the default list registered via entry points.

  reset_resources()

    Reset registered resource mappings to the default list provided as entry points.