-
Notifications
You must be signed in to change notification settings - Fork 2
initial claude setup #77
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
b86c1f2
255e95b
bb1da05
b458384
dd26101
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,11 @@ | ||
| --- | ||
| description: Enforce uv as the package manager for all Python operations | ||
| globs: | ||
| - "**/*.py" | ||
| - "**/pyproject.toml" | ||
| --- | ||
|
|
||
| - Always use `uv run` to execute commands — never bare `python`, `pytest`, `ruff`, or other tools. | ||
| - When working in this repo (local development, CI, or scripts), do not use `pip install`; use `uv sync` (with `--extra` or `--all-groups` flags) to manage dependencies. End-user installation docs may still reference `pip`. | ||
| - The `uv.lock` file is the source of truth for resolved dependency versions. | ||
| - When adding dependencies, add them to `pyproject.toml` and run `uv sync`. | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,15 @@ | ||
| { | ||
| "hooks": { | ||
| "PostToolUse": [ | ||
| { | ||
| "matcher": "Edit|Write", | ||
| "hooks": [ | ||
| { | ||
| "type": "command", | ||
| "command": "FILE=$(jq -r '.tool_input.file_path'); if [[ \"$FILE\" == *.py ]]; then cd \"$CLAUDE_PROJECT_DIR\" && uv run ruff format \"$FILE\" --quiet 2>/dev/null; fi" | ||
| } | ||
| ] | ||
| } | ||
| ] | ||
| } | ||
| } |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,19 +1,25 @@ | ||
| repos: | ||
| # Ruff linting and formatting | ||
| - repo: https://github.com/astral-sh/ruff-pre-commit | ||
| rev: v0.14.4 | ||
| rev: v0.14.13 | ||
| hooks: | ||
| - id: ruff | ||
| args: [--fix] | ||
| args: [--fix, --exit-non-zero-on-fix] | ||
| - id: ruff-format | ||
|
|
||
| # Pre-commit hooks | ||
| - repo: https://github.com/pre-commit/pre-commit-hooks | ||
| rev: v6.0.0 | ||
| hooks: | ||
| - id: trailing-whitespace | ||
| - id: end-of-file-fixer | ||
| - id: check-yaml | ||
| args: [--unsafe] # this helps with some MkDocs YAML files | ||
| exclude: ^mkdocs\.yml$ | ||
| - id: check-added-large-files | ||
| args: ['--maxkb=99900'] | ||
| - id: check-merge-conflict | ||
|
|
||
| - repo: https://github.com/pre-commit/mirrors-mypy | ||
| rev: v1.19.1 | ||
| hooks: | ||
| - id: mypy | ||
| args: [--no-strict-optional, --ignore-missing-imports] | ||
| additional_dependencies: [types-PyYAML] |
| Original file line number | Diff line number | Diff line change | ||||
|---|---|---|---|---|---|---|
| @@ -0,0 +1,138 @@ | ||||||
| # LANfactory — Project Context for Claude | ||||||
|
|
||||||
| ## What is LANfactory? | ||||||
|
|
||||||
| Lightweight Python package for training Likelihood Approximation Networks (LANs), Choice Probability Networks (CPNs), and Option Probability Networks (OPNs) using PyTorch or JAX/Flax backends. Trained networks are exported to ONNX format and uploaded to HuggingFace for consumption by HSSM. This package sits in the middle of the HSSM ecosystem: it depends on ssm-simulators for training data and produces the neural network artifacts that HSSM uses at inference time. For ecosystem-wide context, see the HSSMSpine repo. | ||||||
|
|
||||||
| ## Project Structure | ||||||
|
|
||||||
| ``` | ||||||
| src/lanfactory/ # Main package | ||||||
| cli/ # Typer CLIs: jaxtrain, torchtrain, transform-onnx, upload-hf, download-hf | ||||||
| config/ # Default network and training configs (LAN, CPN, OPN) | ||||||
| trainers/ # Training implementations (torch_mlp.py, jax_mlp.py) | ||||||
| onnx/ # PyTorch → ONNX export | ||||||
| hf/ # HuggingFace Hub integration (upload, download, model cards) | ||||||
| utils/ # Config save/load, MLflow utilities | ||||||
| tests/ # pytest suite (trainers, CLI, ONNX, HuggingFace, E2E) | ||||||
| docs/ # MkDocs documentation + tutorial notebooks | ||||||
| notebooks/ # Test notebooks | ||||||
| ``` | ||||||
|
|
||||||
| ## Build & Tooling | ||||||
|
|
||||||
| - **Build system:** setuptools (pure Python, no compiled extensions) | ||||||
| - **Package manager:** uv (with `uv.lock`) | ||||||
|
||||||
| - **Package manager:** uv (with `uv.lock`) | |
| - **Package manager:** uv (no `uv.lock` committed; dependencies resolved from `pyproject.toml`) |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -337,8 +337,9 @@ def TorchMLPFactory( | |
| """ | ||
| if isinstance(network_config, str): | ||
| with open(network_config, "rb") as f: | ||
| network_config = pickle.load(f) | ||
| network_config = pickle.load(f) # noqa: S301 | ||
|
|
||
|
Comment on lines
338
to
341
|
||
| assert isinstance(network_config, dict) | ||
|
||
| return TorchMLP( | ||
| network_config=network_config, | ||
| input_shape=input_dim, | ||
|
|
@@ -506,7 +507,7 @@ def __init__( | |
| elif isinstance(train_config, dict): | ||
| print("train_config is passed as dictionary: \n") | ||
| print(train_config) | ||
| self.train_config: dict = train_config | ||
| self.train_config = train_config | ||
|
|
||
| self.model: TorchMLP = model.to(self.dev) | ||
| self.allow_abs_path_folder_generation: bool = allow_abs_path_folder_generation | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This rule says
uv.lockis the source of truth, but the repository currently ignoresuv.lockin.gitignore(so it won’t be committed/reviewed). To make this enforceable, either stop ignoring and commituv.lock, or adjust the rule to reflect the current workflow (no checked-in lockfile).