{"id":7007,"library":"asdf-standard","title":"ASDF Standard Schemas","description":"asdf-standard is a Python package that provides the schemas and specification for the Advanced Scientific Data Format (ASDF). It defines the structure and requirements for creating, editing, and reading ASDF files. The package itself primarily distributes YAML schema files; the actual Python implementation for interacting with ASDF files is provided by the separate 'asdf' library. It is currently at version 1.5.0 and releases are made as the ASDF standard evolves.","status":"active","version":"1.5.0","language":"en","source_language":"en","source_url":"https://github.com/asdf-format/asdf-standard","tags":["scientific data","data format","schema","YAML","JSON Schema","astronomy"],"install":[{"cmd":"pip install asdf-standard","lang":"bash","label":"Install stable version"}],"dependencies":[{"reason":"Used by the 'asdf' library for validation against the provided schemas.","package":"jsonschema","optional":false},{"reason":"Schemas are YAML files; used by schema loaders (e.g., in 'asdf' library) to parse schema definitions.","package":"pyyaml","optional":false}],"imports":[{"note":"asdf-standard primarily provides data (schema files); direct Python API imports for general use are not common. Schemas are typically accessed as package resources or via the 'asdf' library's schema resolver.","symbol":"files","correct":"import importlib.resources as resources\n# To access schema data files"}],"quickstart":{"code":"import importlib.resources as resources\nimport yaml\n\n# Asdf-standard provides schemas as data files.\n# This example shows how to locate and load a core schema.\n\ntry:\n    # For Python 3.9+ (or importlib_resources backport)\n    schema_path = resources.files('asdf_standard.schemas.stsci.edu.asdf') / 'core-1.6.0.yaml'\n    with open(schema_path, 'r') as f:\n        core_schema = yaml.safe_load(f)\n    print(\"Successfully loaded core-1.6.0.yaml schema.\")\nexcept Exception as e:\n    print(f\"Could not load schema: {e}\")\n    print(\"This might happen if the path or filename is incorrect, or if `asdf` library is expected for schema access.\")\n\n# In typical usage, the 'asdf' library internally manages these schemas.\n# For example, to validate an ASDF tree against schemas, you'd use the 'asdf' library:\n# import asdf\n# with asdf.open('my_file.asdf') as af:\n#     # Validation happens automatically on open and write\n#     pass\n","lang":"python","description":"Demonstrates how to programmatically locate and load a core ASDF schema file provided by the `asdf-standard` package using `importlib.resources`. This package is primarily a source of schema definitions, which are consumed by the `asdf` library for validation and serialization, rather than directly by end-user applications."},"warnings":[{"fix":"Upgrade your Python environment to 3.10 or higher. For earlier Python versions, use `asdf-standard<1.5.0`.","message":"Starting with `asdf-standard` version 1.5.0, Python 3.9 is no longer supported. Ensure your environment uses Python 3.10 or newer.","severity":"breaking","affected_versions":">=1.5.0"},{"fix":"When referencing schemas or tags, update URIs from `http://stsci.edu/schemas/asdf/...` to `asdf://asdf-format.org/...`. The `asdf` Python library is designed to handle this change gracefully for reading older files, but new schemas or extensions should use the new URI format.","message":"The URI authority for ASDF Standard schemas has changed from `stsci.edu` to `asdf-format.org` in ASDF Standard 1.5. This affects the `id` field within schema files and tag URIs.","severity":"breaking","affected_versions":">=1.5.0"},{"fix":"If you intend to work with ASDF files (e.g., create, read, write, validate), you should install and use the `asdf` library (`pip install asdf`). Use `asdf-standard` if you are developing against the ASDF specification or creating custom extensions that rely on its schemas.","message":"It is a common misconception that `asdf-standard` is the primary library for creating and reading ASDF files. `asdf-standard` provides the schema *definitions*, while the `asdf` library provides the Python *implementation* to interact with ASDF files.","severity":"gotcha","affected_versions":"all"}],"env_vars":null,"last_verified":"2026-04-16T00:00:00.000Z","next_check":"2026-07-15T00:00:00.000Z","problems":[{"fix":"Install the `asdf` library: `pip install asdf`.","cause":"Attempting to import `asdf` functionality without installing the correct package. `asdf-standard` does not include the `asdf` library itself.","error":"ModuleNotFoundError: No module named 'asdf'"},{"fix":"Use `importlib.resources.files('asdf_standard.schemas.stsci.edu.asdf') / 'core-1.6.0.yaml'` (or similar for other schemas) to reliably locate schema files within the installed package. Ensure the schema version and filename are correct.","cause":"Incorrect path or access method when trying to load a schema file directly from the `asdf-standard` package. The internal layout of package resources can change, or the method used to access them might be incorrect.","error":"asdf_standard.schemas.stsci.edu.asdf.core-1.6.0.yaml is not found or cannot be opened"}]}