Crates.io | nomy-data-models |
lib.rs | nomy-data-models |
version | 0.2.6 |
source | src |
created_at | 2025-03-23 09:59:48.365111+00 |
updated_at | 2025-03-29 12:34:48.257972+00 |
description | Data model definitions for Nomy wallet analysis data processing |
homepage | https://github.com/bcnmy/nomy-data-models |
repository | |
max_upload_size | |
id | 1602525 |
size | 394,493 |
This repository contains the data model definitions for Nomy wallet analysis data processing. These models are shared across multiple services:
The Nomy Data Models repository serves as a single source of truth for all data structures used in the Nomy wallet analysis ecosystem. By centralizing these models, we ensure consistency across different services and reduce duplication of code.
# Install from PyPI
pip install nomy-data-models
# Install from source
pip install -e .
Add to your Cargo.toml
:
[dependencies]
nomy-data-models = { version = "0.1.0", git = "https://github.com/bcnmy/nomy-data-models" }
from nomy_data_models.models import WalletState, ServiceState, RawTrade, EnrichedTrade, Position
# Use the models with SQLAlchemy
from sqlalchemy import create_engine
from sqlalchemy.orm import Session
engine = create_engine("sqlite:///nomy.db")
with Session(engine) as session:
wallet_state = WalletState(
wallet_address="0x1234567890abcdef1234567890abcdef12345678",
chain_id=1
)
session.add(wallet_state)
session.commit()
use nomy_data_models::models::{WalletState, ServiceState, RawTrade, EnrichedTrade, Position};
// Use the model
let wallet_state = WalletState {
wallet_address: "0x1234567890abcdef1234567890abcdef12345678".to_string(),
chain_id: 1,
// ... other fields
};
This repository uses pre-commit hooks to ensure code quality and consistency. After cloning the repository, install the pre-commit hooks:
# Make the script executable
chmod +x ./scripts/install-hooks.sh
# Install the hooks
./scripts/install-hooks.sh
The pre-commit hooks will automatically:
Important: Always ensure the pre-commit hooks are installed and up-to-date. They are essential for maintaining code quality and preventing CI failures.
poetry install
cargo build
./scripts/install-hooks.sh
This repository includes git hooks to automate certain tasks:
To install the git hooks, run:
./scripts/install-hooks.sh
This ensures that all Rust models are kept in sync with their Python counterparts and that they build correctly.
nomy_data_models/models/
__init__.py
files to export the new modelpython scripts/generate_rust.py
src/models/
# Run Python tests
pytest tests/python
# Run Rust tests
cargo test
Please follow these steps when contributing:
This repository includes a utility for automatically converting Python SQLAlchemy models to Rust structs. This ensures that the data models are consistent across both languages.
nomy_data_models/models
directorynomy_data_models/py_to_rust.py
module provides functions for converting these models to Rustscripts/generate_rust.py
script can be used to generate Rust code from the command lineTo generate Rust models from Python SQLAlchemy models:
python scripts/generate_rust.py [output_dir]
If output_dir
is not specified, the default is src/models
.
To test the conversion process:
python scripts/test_conversion.py
This will generate Rust code in the scripts/test_output/models
directory and run various tests to ensure the conversion is working correctly.