mgnolia
Declarative filesystem structure and content validation for Python.
Define the expected layout of a directory using Dir and File nodes, optionally attach content validation rules, then call validate_all() to check a real directory against your schema. All errors are collected and returned as typed objects—nothing raises.
Installation
pip:
pip install mgnolia
uv:
uv add mgnolia
Quick Start
from mgnolia import Dir, File, Schema
# Define expected structure
schema = Schema(
children=[
Dir(
path="data",
description="Data directory",
children=[
File(path="input.csv"),
File(path="output.json"),
],
),
File(path="config.yaml"),
]
)
# Validate a directory
ok = schema.validate_all("/path/to/project")
if not ok:
for error in schema.errors:
print(error)
else:
print("All checks passed!")
Content Rules
Attach validation rules to files to check their contents:
from mgnolia import File
from mgnolia.content import FileNotEmptyRule, CSVSchemaRule
from pydantic import BaseModel
class UserRow(BaseModel):
id: int
name: str
email: str
File(
path="users.csv",
content_rules=[
FileNotEmptyRule(),
CSVSchemaRule(schema=UserRow),
],
)
Built-in rules:
FileNotEmptyRule()— fails if file is emptyCSVSchemaRule(schema=PydanticModel)— validates CSV against a Pydantic model using pandera
Error Types
When validation fails, schema.errors contains typed error objects:
- Structure errors:
FileMissingError,DirectoryMissingError,MinMatchError,MaxMatchError - Content errors:
FileEmptyError,ContentSchemaError
All inherit from ValidationError and have .path and .node attributes. Use str(error) to get a formatted message.
Pattern Matching
Dir and File paths support glob patterns to match multiple files or directories:
File(path="*.log", min_matches=1) # At least one .log file
Dir(path="test_*", max_matches=5) # At most 5 test_* directories
License
MIT
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 mgnolia-0.3.0.tar.gz.
File metadata
- Download URL: mgnolia-0.3.0.tar.gz
- Upload date:
- Size: 6.6 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via:
twine/7.0.0 CPython/3.13.14
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
a129849fc36d00527973077dbefe20af802cd36fc6893c235aa09f604a9c5560
|
|
| MD5 |
517a85d8207b9aa3e2eed08b1064e106
|
|
| BLAKE2b-256 |
72851e2220b77b39def52f21814a07bf322fb7496e23395c8de5d52d43de66e7
|
Provenance
The following attestation bundles were made for mgnolia-0.3.0.tar.gz:
Publisher:
release.yml on EBI-Metagenomics/mgnolia
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
mgnolia-0.3.0.tar.gz -
Subject digest:
a129849fc36d00527973077dbefe20af802cd36fc6893c235aa09f604a9c5560 - Sigstore transparency entry: 2335497459
- Sigstore integration time:
-
Permalink:
EBI-Metagenomics/mgnolia@b64250bd2c41e34de4f35e045e7d5d5b3822b4ed -
Branch / Tag:
refs/tags/v0.3.0 - Owner: https://github.com/EBI-Metagenomics
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
release.yml@b64250bd2c41e34de4f35e045e7d5d5b3822b4ed -
Trigger Event:
release
-
Statement type:
File details
Details for the file mgnolia-0.3.0-py3-none-any.whl.
File metadata
- Download URL: mgnolia-0.3.0-py3-none-any.whl
- Upload date:
- Size: 8.2 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via:
twine/7.0.0 CPython/3.13.14
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
c88389e756acb7731d3792ea5dcab4873697a9f7ca9bab359399de6a031ef2e1
|
|
| MD5 |
b96292ae4cf8caa50b5fe2aaf1e6661d
|
|
| BLAKE2b-256 |
4e1fde5bdf7db5f5b11f81666f0a5278e167411ff91ddc97daefbc0d666a4407
|
Provenance
The following attestation bundles were made for mgnolia-0.3.0-py3-none-any.whl:
Publisher:
release.yml on EBI-Metagenomics/mgnolia
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
mgnolia-0.3.0-py3-none-any.whl -
Subject digest:
c88389e756acb7731d3792ea5dcab4873697a9f7ca9bab359399de6a031ef2e1 - Sigstore transparency entry: 2335497468
- Sigstore integration time:
-
Permalink:
EBI-Metagenomics/mgnolia@b64250bd2c41e34de4f35e045e7d5d5b3822b4ed -
Branch / Tag:
refs/tags/v0.3.0 - Owner: https://github.com/EBI-Metagenomics
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
release.yml@b64250bd2c41e34de4f35e045e7d5d5b3822b4ed -
Trigger Event:
release
-
Statement type: