AsdfConfig
- class asdf.config.AsdfConfig[source]
Bases:
object
Container for ASDF configuration options. Users are not intended to construct this object directly; instead, use the
asdf.get_config
andasdf.config_context
module methods.Attributes Summary
Override the compression type on all binary blocks in the file.
Dictionary of keyword arguments provided to the compressor during block compression (or
None
for no keyword arguments)Override the array storage type of all blocks in the file immediately before writing.
Get the threshold below which arrays are automatically written as inline YAML literals instead of binary blocks.
Get configuration that controls if ndarray subclasses (subclasses that aren't otherwise handled by a specific converter) are serialized as ndarray.
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).
Get the default ASDF Standard version used for new files.
Get the list of registered extensions.
Get the block size used when reading and writing files.
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.
Get the configuration that controls filling defaults from schemas for older ASDF Standard versions.
Get the
asdf.resource.ResourceManager
instance.Get the list of registered resource mapping instances.
Get configuration that controls schema validation of ASDF files on read.
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 to the default list registered via entry points.
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 aasdf.extension.Compressor
:''
orNone
: 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.
- convert_unknown_ndarray_subclasses
Get configuration that controls if ndarray subclasses (subclasses that aren’t otherwise handled by a specific converter) are serialized as ndarray. If
True
, instances of these subclasses will appear in ASDF files as ndarrays and when loaded, will load as ndarrays.Note that these conversions will result in an AsdfConversionWarning being issued as this support for converting subclasses will be removed in a future version of ASDF.
- Returns:
- bool
- 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 Standard 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 forasdf.open
.- Returns:
- bool
- legacy_fill_schema_defaults
Get the configuration that controls filling defaults from schemas for older ASDF Standard versions. If
True
, missing default values will be filled from the schema when reading files from ASDF Standard <= 1.5.0. Later versions of the standard 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:
- 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
Methods Documentation
- add_extension(extension)[source]
Register a new extension. The new extension will take precedence over all previously registered extensions.
- Parameters:
- extensionasdf.extension.Extension
- add_resource_mapping(mapping)[source]
Register a new resource mapping. The new mapping will take precedence over all previously registered mappings.
- remove_extension(extension=None, *, package=None)[source]
Remove a registered extension.
- Parameters:
- extensionasdf.extension.Extension or str, optional
An extension instance or URI pattern to remove.
- packagestr, 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)[source]
Remove a registered resource mapping.
- Parameters:
- mappingcollections.abc.Mapping, optional
Mapping to remove.
- packagestr, optional
Remove only extensions provided by this package. If the
mapping
argument is omitted, then all mappings from this package will be removed.