ZnTrack - Data as Code

Fabian Zills, Moritz Schäfer, Samuel Tovey, Johannes Kästner, Christian HolmarXiv 2024

TL;DR

This paper introduces ZnTrack, a Python package that implements the "Data as Code" (DaC) paradigm. ZnTrack leverages Git and DVC to provide a user-friendly interface for tracking experiments, managing data, and building reproducible computational workflows, aiming to simplify data management in scientific research.

What Problem Does This Paper Address?

The rapid growth in computational power and machine learning has led to an explosion of data in scientific research. This presents significant challenges in managing, sharing, and tracking complex datasets, simulation parameters, and experimental workflows. Existing solutions often require specialized setup, are database-dependent, or lack a unified approach for integrating code and data. This makes reproducibility and collaboration difficult, hindering scientific progress. The authors aim to address this by providing a streamlined, code-centric approach to data management.

Methods

ZnTrack builds upon established version control systems, Git and Data Version Control (DVC), to implement the "Data as Code" (DaC) paradigm. The core idea is to treat data generation and management as code, making it versionable and reproducible alongside the code that produces it.

Key methodological components include:

  • Git and DVC Integration: ZnTrack uses Git for code versioning and DVC for managing large data files and their associated metadata. This allows for tracking experiments as commits, where both code and data are versioned together.
  • Python-Centric Interface: ZnTrack provides a Python API for defining and managing computational workflows. This offers a more flexible and user-friendly approach compared to command-line interfaces (CLIs) often associated with DVC.
  • Computational Graphs (DAGs): Workflows are represented as directed acyclic graphs (DAGs), where nodes represent operations or variables, and edges represent data dependencies. This structure facilitates efficient execution and parallelization.
  • Nodes and Projects: ZnTrack introduces Node objects, which encapsulate individual steps in a workflow, and Project objects, which manage the overall computational graph.
  • Data Serialization: ZnTrack supports both manual (MDS) and automatic (ADS) data serialization, allowing users to manage file paths or have ZnTrack handle data serialization and deserialization.
  • Parallelization with dask4dvc: For executing computational graphs in parallel, ZnTrack integrates with the dask4dvc package, enabling efficient utilization of computational resources and deployment on clusters.
  • Experiment Management: ZnTrack allows for running experiments with different parameters, leveraging DVC's experiment tracking capabilities and offering Python-based control for greater customization.

Datasets

The paper does not explicitly mention specific datasets used for training machine learning models within ZnTrack itself. However, it demonstrates ZnTrack's application with:

  • Atomistic Simulation Data: Molecular dynamics simulations of molten sodium chloride were used to showcase ZnTrack's capabilities in managing simulation parameters and results.
  • StackOverflow Questions and Tags: A dataset of StackOverflow questions and their respective tags was used to demonstrate training a random forest classifier. This dataset is adapted from a DVC example repository.
  • Structural Database Repository (SDR): The paper introduces the concept of an SDR, a Git repository with a public DVC remote for accessing, commenting on, and expanding first-principle simulation data. Data is stored in the H5MD format.

Key Insights and Ideas

  • "Data as Code" Paradigm: The central idea is that by treating data generation and management as code, we can achieve unprecedented levels of reproducibility, accessibility, and collaboration. This shifts the burden of data management from end-users to developers.
  • Unified Workflow and Data Management: ZnTrack bridges the gap between code versioning (Git) and data versioning (DVC) with a user-friendly Python interface, creating a cohesive system for managing complex scientific workflows.
  • Simplifying Reproducibility: By versioning code, parameters, and data together, ZnTrack makes it significantly easier to reproduce experiments and share results, addressing a critical challenge in scientific research.
  • FAIR Data Principles: The DaC paradigm, as implemented by ZnTrack, inherently supports FAIR (Findable, Accessible, Interoperable, Reusable) data principles by making data directly linked to its generating code and versioned.
  • Reduced Overhead: ZnTrack aims to minimize the setup and maintenance overhead associated with data management, making it more accessible to researchers without extensive software engineering backgrounds.

Key Results

  • Demonstrated Applicability: ZnTrack was successfully demonstrated for managing atomistic simulations (molecular dynamics) and machine learning tasks (random forest classification).
  • Code Simplification: The paper shows that converting existing code to the DaC paradigm using ZnTrack can reduce lines of code and McCabe complexity while maintaining functionality.
  • High Code Similarity: An analysis of code similarity between original Python scripts and their ZnTrack-adapted versions showed high cosine similarity, indicating that ZnTrack is not overly invasive and preserves the core logic.
  • Parallel Execution: The integration with dask4dvc allows for efficient parallel execution of computational graphs, speeding up simulations and analyses.
  • Reproducible Workflows: The framework enables the creation of fully reproducible workflows, which is crucial for data-driven fields like machine learning and atomistic simulations.

Limitations and Future Work

  • Initial Setup: While ZnTrack aims to reduce overhead, an initial setup involving Git and DVC is still required.
  • Dependency on Git/DVC: The functionality of ZnTrack is inherently tied to the capabilities and limitations of Git and DVC.
  • Future Work: The authors suggest building further tools on top of ZnTrack to enhance usability, such as the ZnDraw package for visualization and direct access to the SDR. They also highlight the potential for integrating ZnTrack with parameter optimization libraries like Optuna and Ray Tune for automated hyperparameter tuning. The development of more specialized nodes and further integration with CI/CD pipelines for automated deployment are also implied.

Summary updated

BibTeX
@misc{zills2024zntrack,
  author = {Fabian Zills and Moritz Schäfer and Samuel Tovey and Johannes Kästner and Christian Holm},
  title = {{ZnTrack - Data as Code}},
  year = {2024},
  eprint = {2401.10603},
  archivePrefix = {arXiv},
  url = {https://arxiv.org/abs/2401.10603},
}
Figure