Jump to content

Connect Leeroopedia MCP: Equip your AI agents to search best practices, build plans, verify code, diagnose failures, and look up hyperparameter defaults.

Implementation:Sdv dev SDV Metadata Load From Json

From Leeroopedia
Knowledge Sources
Domains Data_Science, Schema_Management
Last Updated 2026-02-14 00:00 GMT

Overview

Concrete tool for loading a Metadata object from a JSON file, provided by the SDV library.

Description

The Metadata.load_from_json class method reads a JSON file and reconstructs a Metadata instance. It supports both current multi-table format and legacy single-table format (SINGLE_TABLE_V1), automatically converting legacy format with a user warning.

Usage

Import Metadata and call load_from_json when you have a previously saved metadata JSON file.

Code Reference

Source Location

  • Repository: SDV
  • File: sdv/metadata/metadata.py
  • Lines: L19-43

Signature

@classmethod
def load_from_json(cls, filepath, single_table_name=None):
    """Create a Metadata instance from a json file.

    Args:
        filepath (str): Path to the json file.
        single_table_name (str or None): Table name for legacy single-table format.

    Returns:
        Metadata: A Metadata instance.
    """

Import

from sdv.metadata import Metadata

I/O Contract

Inputs

Name Type Required Description
filepath str Yes Path to the JSON metadata file
single_table_name str or None No Table name for legacy format conversion

Outputs

Name Type Description
return value Metadata Metadata instance with tables, columns, and relationships

Usage Examples

from sdv.metadata import Metadata

# Load metadata from a saved file
metadata = Metadata.load_from_json('my_metadata.json')

# Inspect the loaded metadata
print(metadata)
metadata.visualize()

Related Pages

Implements Principle

Requires Environment

Page Connections

Double-click a node to navigate. Hold to expand connections.
Principle
Implementation
Heuristic
Environment