{"id":3473,"library":"dvc-objects","title":"dvc-objects library","description":"dvc-objects provides filesystem and object-database level abstractions, serving as a core component for DVC (Data Version Control) and related data management tools. It handles operations like hashing files, managing object storage, and providing an fsspec-compatible interface for various backends. The library is actively maintained with frequent minor releases.","status":"active","version":"5.2.0","language":"en","source_language":"en","source_url":"https://github.com/treeverse/dvc-objects","tags":["dvc","data version control","filesystem","object storage","hashing","fsspec"],"install":[{"cmd":"pip install dvc-objects","lang":"bash","label":"Install latest version"}],"dependencies":[],"imports":[{"note":"A primary function for computing content hashes of files.","symbol":"hash_file","correct":"from dvc_objects.file import hash_file"},{"note":"Used for managing connections and operations with object databases.","symbol":"ObjectDBManager","correct":"from dvc_objects.db.manager import ObjectDBManager"},{"note":"Returns an fsspec-compliant filesystem instance based on a URL or path.","symbol":"get_fs","correct":"from dvc_objects.fs import get_fs"}],"quickstart":{"code":"import os\nimport tempfile\nfrom pathlib import Path\nfrom dvc_objects.file import hash_file\nfrom dvc_objects.hash_info import HashInfo\n\n# Create a temporary file for demonstration\nwith tempfile.TemporaryDirectory() as tmpdir:\n    test_file_path = Path(tmpdir) / \"my_data.txt\"\n    test_file_path.write_text(\"This is some sample data for hashing.\")\n\n    print(f\"Hashing file: {test_file_path}\")\n    # Hash the file using the default algorithm (e.g., MD5)\n    hash_info: HashInfo = hash_file(test_file_path)\n\n    print(f\"\\nFile path: {test_file_path}\")\n    print(f\"Hash Type: {hash_info.name}\")\n    print(f\"Hash Value: {hash_info.value}\")\n\n    # Example: Verify content based on hash\n    if hash_info.name == \"md5\" and hash_info.value == \"2efb72b834458f4a7c1b52b36e355745\":\n        print(\"Hash matches expected value!\")\n    else:\n        print(\"Hash does not match expected value or is not MD5.\")\n","lang":"python","description":"This quickstart demonstrates how to hash a local file using `dvc_objects.file.hash_file`, a fundamental operation within the library for content-addressable storage."},"warnings":[{"fix":"Upgrade Python to version 3.9 or higher. For example, use pyenv or update your virtual environment.","message":"Python 3.8 support was dropped in version 5.1.0. Users on Python 3.8 will need to upgrade their Python interpreter to 3.9 or newer.","severity":"breaking","affected_versions":">=5.1.0"},{"fix":"Remove direct dependencies on `TqdmCallback`. If custom progress reporting is needed, implement a new callback mechanism based on `dvc-objects`' current callback interfaces, or integrate with DVC's global progress reporting.","message":"The `tqdm` implementation and `TqdmCallback` were removed in version 5.0.0. This significantly changes how progress reporting is handled for file operations, requiring users to implement custom callbacks or rely on upstream DVC progress mechanisms.","severity":"breaking","affected_versions":">=5.0.0"},{"fix":"Review calls to `fs.info` and consider the impact of the `return_exceptions` parameter on error handling logic. Explicitly set it if specific exception handling is required.","message":"The `fs.info` method gained a `return_exceptions` parameter in version 5.2.0. Its default behavior or implications when `True` might alter how errors are handled when querying file system information.","severity":"gotcha","affected_versions":">=5.2.0"},{"fix":"While generally robust, be aware of these internal fallback strategies, especially when debugging performance or disk usage issues related to file storage. Ensure your environment supports efficient linking if performance is critical.","message":"Starting from versions 5.1.1 and 5.1.2, `dvc-objects` includes enhanced fallback mechanisms for file linking (e.g., copying if `os.link` is unavailable or if `EAGAIN` errors occur during linking). This can affect performance and disk space usage on certain platforms or under specific conditions.","severity":"gotcha","affected_versions":">=5.1.1"}],"env_vars":null,"last_verified":"2026-04-11T00:00:00.000Z","next_check":"2026-07-10T00:00:00.000Z"}