MatGraph abstracts away the complexity of deep learning for material properties. Designed for both Material Science researchers and ML engineers, it provides a seamless interface to fetch, featurize, predict, and export crystal structures—all powered by modern technologies like PyTorch, GraphQL, and uv.
Key Features (v0.3.0 Update)
- Dual Architecture Support: Integrated PyTorch architecture for both Crystal Graph Convolutional Neural Networks (CGCNN) and MatErials Graph Network (MEGNet).
- Multi-Property Predictions: Now predicts both Band Gap and Formation Energy per atom in real-time.
- Ultra-Fast Engine: Built on top of Astral's
uvfor lightning-fast environment management. - Advanced Filtering & Export: Filter structures by Band Gap and Crystal System, and instantly export feature-rich datasets to CSV or JSON.
- Modern Async GraphQL API: Fully asynchronous resolvers via
Strawberry&FastAPI, providing rich schemas and nested model metrics. - Sleek CLI: Beautiful, table-formatted terminal outputs powered by
TyperandRich.
Installation
We recommend using uv for the fastest installation experience.
# Install via uv (Recommended)
uv tool install matgraph-cli
# Or via standard pip
pip install matgraph-cli
Authentication Setup
To fetch high-fidelity data, you need a free API key from the Materials Project.
export MP_API_KEY="your_api_key_here"
Tip: You can verify your setup anytime by running matgraph setup <YOUR_KEY>.
Usage: The Productive CLI
MatGraph's CLI is designed to be highly intuitive.
Basic Prediction Pipeline (Defaults to CGCNN) Run the end-to-end pipeline (Fetch → Featurize → CGCNN Predict) for a specific chemical formula:
matgraph predict LiFePO4
Use MEGNet Architecture Switch models easily to use the MEGNet architecture for Formation Energy and Band Gap:
matgraph predict LiFePO4 --model megnet
Advanced Search & Filtering Filter materials based on physical constraints:
matgraph predict LiFePO4 --min-gap 1.5 --crystal-system Cubic --model megnet
Dataset Export for ML Engineers Save extracted structural features and predictions directly into a dataset for offline training:
matgraph predict LiFePO4 --min-gap 2.0 --save dataset.csv --format csv
Usage: The Modern GraphQL API
Integrate MatGraph into your own web applications seamlessly using our robust, async GraphQL engine.
Start the Server:
matgraph serve --port 8000
Navigate to http://localhost:8000/graphql to explore the interactive GraphiQL playground.
Example Query:
query {
predictMaterial(formula: "NaCl", minGap: 1.0, limit: 3, model: "megnet") {
materialId
formula
crystalSystem
trueBandGap
predictedBandGap
trueFormEnergy
predictedFormEnergy
features {
density
numElements
volume
}
metrics {
modelName
confidenceScore
}
}
}
Releases & Changelog
v0.3.x (Current - Multi-Property & MEGNet Update)
- Feature: Implemented PyTorch MEGNet model (
matgraph/megnet.py). - Feature: Support for Formation Energy predictions alongside Band Gap.
- Feature: Added
--model megnetflag and GraphQLmodel: "megnet"argument. - Feature: Integrated PyTorch architecture (
CrystalGraphConvNet) replacing legacy dummy models. - Feature: Advanced CLI filtering (
--min-gap,--max-gap,--crystal-system). - Feature: One-command dataset exporting (
--save,--format). - Improvement: GraphQL schema modernized with detailed
ModelMetricsand GraphQL pagination filters.
v0.1.x (Initial Release)
- Initial end-to-end pipeline with MP-API fetching and basic feature extraction.
- GraphQL Server & basic Typer CLI introduced.
- Project migrated to
uvbuild backend for maximum efficiency.
Contributing & Architecture
MatGraph is built on a robust, modern Python stack:
- ML & Science: PyTorch, PyMatGen, Scikit-Learn, MP-API
- API & CLI: FastAPI, Strawberry GraphQL, Typer, Rich
- Packaging: uv (Hatchling)
We welcome contributions! To set up for local development:
git clone https://github.com/Himan-D/matgraph-cli.git
cd matgraph-cli
uv sync
uv run pytest
Please open an issue before submitting major pull requests.
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file matgraph_cli-0.3.0.tar.gz.
File metadata
- Download URL: matgraph_cli-0.3.0.tar.gz
- Upload date:
- Size: 374.5 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: uv/0.11.23 {"installer":{"name":"uv","version":"0.11.23","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"macOS","version":null,"id":null,"libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
d4843d8facf2f09edbeeb5ea89a6a22d3102dd5956051ce18c6526392d66fb76
|
|
| MD5 |
99ce31114f02bd7e9845998af472544b
|
|
| BLAKE2b-256 |
f2e85368f26d5cef53685541b260523e3244c277bc4fa8dd145bcfccd0516bf5
|
File details
Details for the file matgraph_cli-0.3.0-py3-none-any.whl.
File metadata
- Download URL: matgraph_cli-0.3.0-py3-none-any.whl
- Upload date:
- Size: 9.9 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: uv/0.11.23 {"installer":{"name":"uv","version":"0.11.23","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"macOS","version":null,"id":null,"libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
84b70201994fa84f817cae822e0ca42e622f97f967c9fadc490e9cf8fe5270dd
|
|
| MD5 |
2e1ba025fc0d1a99ef60a796eaedd893
|
|
| BLAKE2b-256 |
92f8b10057661bddb63e6d11b9e044b16ef6635fa7375c342f9e5e8ab1180e4f
|