/python-tooling:kronos-pypi-collisionfrom python-tooling
Fix for `pip install kronos` returning the wrong package when trying to use the financial K-line foundation model. Use when: (1) you intend to use the Kronos OHLCV/K-line transformer from arXiv 2508.02739 (Shi et al., AAAI 2026), (2) `pip install kronos` succeeds but `import kronos` fails with `ModuleNotFoundError: No module named 'django'` (the unrelated PyPI package is a Django-based scheduler), (3) you can't find a `kronos` pip package that exposes `Kronos`/`KronosTokenizer`/`KronosPredictor`. The financial Kronos model has no published pip package under that name; install from the GitHub repo (`shiyu-coder/Kronos`) instead. Also covers Mac (Apple Silicon) usage: device must be `"cpu"` or `"mps"`, never `"cuda:0"`.
Ships in python-tooling. Installing the plugin adds it to Claude Code.
What the skill costs in Claude's context, stage by stage
Name and description: Claude knows it exists.
SKILL.md joins the conversation and stays.
None: SKILL.md is the whole skill.
The financial Kronos foundation model — a decoder-only transformer pretrained on 12B K-line records from 45 exchanges, specifically tokenized for OHLCV (Shi et al., AAAI 2026, arXiv 2508.02739) — does NOT have a published pip package under the name kronos. Running pip install kronos succeeds but installs a completely unrelated Django-based scheduler, which fails on import with ModuleNotFoundError: No module named 'django' if Django isn't already installed (and even if it were, you'd be importing the wrong code).
The actual Kronos model code lives only on GitHub at shiyu-coder/Kronos. HuggingFace checkpoints are under the NeoQuasar/ org. The importable package name is model, NOT kronos.
pip install kronos succeeds but import kronos doesn't expose Kronos / KronosTokenizer / KronosPredictor.ModuleNotFoundError: No module named 'django' after import kronos.from model import Kronos, KronosTokenizer, KronosPredictor and you can't make from kronos import ... work.Install from source:
git clone https://github.com/shiyu-coder/Kronos.git ~/.local/kronos
cd ~/.local/kronos
pip install -r requirements.txt
export PYTHONPATH=~/.local/kronos:$PYTHONPATH
Make the PYTHONPATH export persistent in shell rc (.zshrc / .bashrc) if Kronos is used regularly.
requirements.txt declares (as of 2026-05): numpy, pandas==2.2.2, torch>=2.0.0, einops==0.8.1, huggingface_hub==0.33.1, matplotlib==3.9.3, tqdm==4.67.1, safetensors==0.6.2. Python 3.10+.
Then in Python:
from model import Kronos, KronosTokenizer, KronosPredictor
import os
# Optional: share HF cache across multiple teams/projects
os.environ.setdefault("HF_HOME", os.path.expanduser("~/.cache/hf"))
# Load tokenizer + model from HuggingFace (NeoQuasar org).
# Tokenizer pairings are paired per-model-size — use the right one:
tokenizer = KronosTokenizer.from_pretrained("NeoQuasar/Kronos-Tokenizer-base")
model = Kronos.from_pretrained("NeoQuasar/Kronos-base")
# Build predictor. Device on Mac is "cpu" or "mps" — NEVER "cuda:0".
predictor = KronosPredictor(model, tokenizer, device="cpu", max_context=512)
| Model checkpoint | Tokenizer | Max context |
|---|---|---|
NeoQuasar/Kronos-mini (4M params) | NeoQuasar/Kronos-Tokenizer-2k | 2048 |
NeoQuasar/Kronos-small | NeoQuasar/Kronos-Tokenizer-base | 512 |
NeoQuasar/Kronos-base | NeoQuasar/Kronos-Tokenizer-base | 512 |
NeoQuasar/Kronos-large | NeoQuasar/Kronos-Tokenizer-base | 512 |
Pairing the wrong tokenizer with a model produces incorrect tokenizations silently — no exception, just bad forecasts. Verify before trusting outputs.
Quick smoke test (verified on macOS Darwin 25.x with Python 3.11):
git clone --depth 1 https://github.com/shiyu-coder/Kronos.git /tmp/kronos_smoke
uv run --python 3.11 \
--with torch>=2.0.0 --with numpy --with pandas==2.2.2 \
--with einops==0.8.1 --with huggingface_hub==0.33.1 \
--with tqdm==4.67.1 --with safetensors==0.6.2 \
python -c "
import sys; sys.path.insert(0, '/tmp/kronos_smoke')
from model import Kronos, KronosTokenizer, KronosPredictor
import torch
print(f'IMPORT_OK | torch={torch.__version__} | mps={torch.backends.mps.is_available()}')
"
Expected: IMPORT_OK | torch=2.11.0 | mps=True. The smoke test confirms imports only — it does NOT download checkpoints. For a full check, follow with a tiny Kronos.from_pretrained("NeoQuasar/Kronos-mini") (downloads ~16MB).
model (with files model/__init__.py, model/kronos.py, model/module.py). DO NOT try from kronos import Kronos — that's the wrong name.device="cpu" and device="mps" work. NEVER pass device="cuda:0" on Mac — silent fall-through can leave you on CPU without you realizing.Kronos.from_pretrained and KronosTokenizer.from_pretrained semantics — it is NOT a HuggingFace transformers.AutoModel. Don't try AutoModel.from_pretrained("NeoQuasar/Kronos-base").PYTHONPATH (e.g., some sandboxes), pip install -e ~/.local/kronos may work as an alternative, depending on the repo's setup.py shape.What SKILL.md sets; muted values are Claude Code's defaults
npx claudepluginhub cajias/claude-skills --plugin python-tooling5 skills in this plugin
/importlib-reload-class-identityDiagnose and fix the silent class-identity drift caused by `importlib.reload()`
on modules that define classes whose instances live elsewhere. Use when:
(1) a pytest fixture uses `importlib.reload(some_module)` to "flush caches"
and downstream tests then fail with `isinstance` checks rejecting objects
that LOOK correct; (2) you see a diagnostic warning of the form "expected X,
got X" — same class name, different class identity (`type(obj).__name__ ==
"X"` but `obj is not isinstance(X)`); (3) one fragile test fixture causes
dozens-to-hundreds of cascading failures in unrelated test files; (4) tests
pass in isolation but fail when run as part of the full suite, with order
dependence pointing at the reload site; (5) you have an entry-point /
plugin / discovery system whose post-reload registry is empty even though
the underlying entries still exist. Covers root cause (Python class objects
are first-class identities; reload mints new ones; pre-reload instances
keep old identity), the diagnostic signature, and the canonical fix
(subprocess isolation via `subprocess.run([sys.executable, "-c", ...])`
or `pytest-forked` — never `importlib.reload` for class-exposing modules).
/python-slots-mock-patch-objectFix for `AttributeError: '<ClassName>' object attribute '<method>' is
read-only` raised during `mock.patch.object()` teardown. Use when:
(1) a Python test using `unittest.mock.patch.object(instance, "method")`
passes the patched code but raises an AttributeError during context-exit
(visible in the stack as `mock.py:1635` calling `delattr(self.target,
self.attribute)`); (2) the target class declares `__slots__`; (3) the
test was working before someone added `__slots__` to a base class or
the target class itself; (4) a refactor introduced `__slots__` "for
efficiency" and broke a previously-green test suite. Covers root cause
(`__slots__` blocks `delattr` because it doesn't allocate `__dict__`,
so the attribute can't be removed after the patch sets it), the
diagnostic signature, the canonical fix (drop `__slots__` if the class
is a mock target), and when `__slots__` IS the right call (when memory
matters AND the class is never patched).
Other plugins' skills for the same job