Registry / ai-ml / model-index

model-index

JSON →
library0.1.11pypypi✓ verified 23d ago

The model-index library helps machine learning researchers and engineers maintain a single source of truth for their ML model metadata. It allows storing metadata flexibly in JSONs, YAMLs, or markdown annotations, and enables browsing and comparing models on Papers with Code. The library is currently at version 0.1.11 and appears to have an active, though not rapid, release cadence.

pip install model-index
INSTALL
IMPORT
SIG · MODEL-INDEX
M
model-index
ai-mlpythonv0.1.11
Install
2.0s avg
Import
326ms
Disk
21MB
Pass rate
10/ 10
Env Coverage10 / 10
glibc
3.93.13
musl
3.93.13
Install & Compatibility
Where this runs
tested against v0.1.11 · pip install
no network on importno background threads
Install × environment matrix
Each cell = how many times install + import succeeded across repeated harness runs. Partial = flaky.
glibc = Debian/Ubuntu slim · musl = Alpine Linux
musl
py 3.103.95 runs
installs and imports cleanly · install 0.0s · import 0.336s · 22MB
glibc
py 3.103.95 runs
installs and imports cleanly · install 2.0s · import 0.316s · 23MB
21MB installed
● package 21MB
Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

ModelIndex
from modelindex.models import ModelIndex
from modelindex.index import ModelIndex
Based on common Python package structure for data models. Explicit `models` submodule is standard for classes representing data schemas.

This quickstart demonstrates how to define a `model-index.yml` file and then programmatically load and inspect its contents using the `model-index` Python library. It highlights how the library facilitates reading structured model metadata into Python objects.

import os from pathlib import Path from modelindex.models import ModelIndex # 1. Create a dummy model-index.yml file for demonstration model_index_content = ''' Models: - Name: MyAwesomeModelV1 Metadata: Task: Image Classification Dataset: CIFAR-10 Metrics: Accuracy: 0.92 Paper: https://arxiv.org/abs/2301.00001 Code: https://github.com/myuser/myawesomemodel Weights: https://example.com/weights.pth License: MIT - Name: MyAwesomeModelV2 Metadata: Task: Image Classification Dataset: CIFAR-10 Metrics: Accuracy: 0.94 Paper: https://arxiv.org/abs/2302.00002 Code: https://github.com/myuser/myawesomemodel Weights: https://example.com/weights_v2.pth License: Apache-2.0 ''' index_file_path = "model-index.yml" Path(index_file_path).write_text(model_index_content) print(f"Created dummy {index_file_path}") try: # 2. Load the model index from the YAML file # Note: The exact loading method might vary; .load_from_file() is a common pattern. # The library's core is parsing these files. model_index = ModelIndex.load_from_file(index_file_path) print(f"\nSuccessfully loaded {len(model_index.models)} model(s).") # 3. Access data from the loaded index for i, model in enumerate(model_index.models): print(f"\n--- Model {i+1} ---") print(f"Name: {model.name}") print(f"Task: {model.metadata['Task']}") print(f"Accuracy: {model.metadata['Metrics']['Accuracy']}") print(f"Paper: {model.metadata['Paper']}") except Exception as e: print(f"An error occurred during loading or processing: {e}") finally: # Clean up the dummy file if Path(index_file_path).exists(): os.remove(index_file_path) print(f"\nCleaned up {index_file_path}")
Debug
Known issues
gotchaThe package name on PyPI is `model-index` (with a hyphen). An alias package `modelindex` (without a hyphen) exists but primarily serves as a dependency for `model-index`. Always use `pip install model-index` to ensure you get the correct, maintained library.
fix
Ensure installation is `pip install model-index` and not `pip install modelindex`.
affects: All versions
gotchaThe `model-index` library relies heavily on the correct structure and syntax of `model-index.yml` and referenced metadata files (YAML, JSON, Markdown). Incorrect formatting, broken relative paths, or non-adherence to the Papers with Code schema can lead to parsing errors or validation failures.
fix
Carefully review the official `model-index` documentation and examples for required YAML schema and file linking conventions. Utilize the `mi` command-line tool (if available) for validation.
affects: All versions
gotchaWhile a Python API exists for programmatic interaction (e.g., loading the index), much of the official documentation and usage examples emphasize defining metadata via `model-index.yml` files and processing them with the provided command-line interface (CLI) tool (`mi`). Explicit Python API quickstart examples for building an index programmatically from scratch are less prevalent.
fix
For basic usage, consider starting with the `model-index.yml` file approach and CLI tools. If programmatic generation or complex manipulation is needed, consult the library's source code or advanced documentation for API specifics.
affects: All versions
Errors
Common errors & fixes
ModuleNotFoundError: No module named 'model_index'
This error typically occurs when the `model-index` library is not installed correctly or an incorrect package name was used during installation (e.g., `pip install modelindex` instead of `pip install model-index`), or if the Python environment path is not configured to find the installed package.
fix
Ensure you install the library using the correct package name: `pip install model-index`. Verify the package is in your environment by running `pip list` and confirming `model-index` is present. If already installed, check your Python environment's path configuration.
yaml.scanner.ScannerError: mapping values are not allowed in this context
This is a common YAML parsing error indicating a structural issue in your `model-index.yml` file, such as incorrect indentation, missing colons, or other syntax mistakes that prevent the YAML parser from correctly interpreting the document.
fix
Review your `model-index.yml` file for precise YAML syntax. Pay close attention to indentation (using spaces, not tabs), correct placement of colons for key-value pairs, and proper list item indicators (`-`). Use a YAML linter tool to identify and fix specific syntax errors.
pydantic.ValidationError
The metadata within your `model-index.yml` or linked files (JSON, YAML, Markdown) does not conform to the expected schema defined by the `model-index` library, which uses Pydantic for validation. This means required fields might be missing, data types are incorrect, or values do not meet specified constraints.
fix
Consult the official `model-index` documentation for the precise schema requirements for your `model-index.yml` and associated metadata. Ensure all mandatory fields are present, values adhere to the specified data types, and any constraints (e.g., allowed ranges, patterns) are met.
Upgrade
Version history
0.1.11latest on PyPI · released Mar 22, 2021
Audit
Dependencies

No dependency data recorded yet.

Agent activity
1 hits · last 30 days
Resources
model-index — pip install model-index · libregistry