Metadata-Version: 2.4
Name: juniper-cascor-model
Version: 0.1.0
Summary: Shared CasCor candidate-training core (CandidateUnit + activation registry + utils + logging + candidate constants) for the Juniper ML platform — the importable model code the distributed worker needs, decoupled from the cascor server stack.
Author: Paul Calnon
License: MIT
Project-URL: Homepage, https://github.com/pcalnon/juniper-cascor
Project-URL: Repository, https://github.com/pcalnon/juniper-cascor
Project-URL: Issues, https://github.com/pcalnon/juniper-cascor/issues
Keywords: juniper,cascor,cascade-correlation,candidate-unit,neural-network,distributed-training
Classifier: Development Status :: 4 - Beta
Classifier: Intended Audience :: Science/Research
Classifier: License :: OSI Approved :: MIT License
Classifier: Programming Language :: Python :: 3
Classifier: Programming Language :: Python :: 3.11
Classifier: Programming Language :: Python :: 3.12
Classifier: Programming Language :: Python :: 3.13
Classifier: Programming Language :: Python :: 3.14
Classifier: Topic :: Scientific/Engineering :: Artificial Intelligence
Requires-Python: >=3.11
Description-Content-Type: text/markdown
Requires-Dist: numpy>=1.24
Requires-Dist: torch>=2.10.0
Requires-Dist: PyYAML>=6.0
Provides-Extra: full
Requires-Dist: dill>=0.3.7; extra == "full"
Requires-Dist: columnar>=1.4.0; extra == "full"
Provides-Extra: test
Requires-Dist: pytest>=8.0; extra == "test"
Requires-Dist: pytest-cov>=5.0; extra == "test"

# juniper-cascor-model

Shared **CasCor candidate-training core** for the Juniper ML platform — the importable
model code a distributed CasCor worker needs to execute a candidate unit, decoupled from
the cascor server / training stack.

## Why this exists

`juniper-cascor-worker` executes candidate-training tasks dispatched by `juniper-cascor`.
To do that it must be able to import `CandidateUnit` and its dependencies — but the worker
container historically had **no** cascor codebase, no candidate-training deps, and several
environment mismatches, so every remote candidate crashed on import
(`ModuleNotFoundError: candidate_unit`). See
[juniper-cascor-worker#97 (CW-05)](https://github.com/pcalnon/juniper-cascor-worker/issues/97).

`juniper-cascor-model` is the canonical fix (CW-05 Approach A): a single PyPI package the
worker depends on, instead of needing the cascor source tree on `sys.path`.

## What's inside

Extracted verbatim from `juniper-cascor/src` (zero coupling to the server/training stack —
no FastAPI, no `cascade_correlation`, no `api`):

- `candidate_unit/` — `CandidateUnit` (the trainable candidate node).
- `utils/` — `utils` helpers + `activation` (the full `ActivationWithDerivative.ACTIVATION_MAP`).
- `log_config/` — the shared logger (made deployment-agnostic, see below).
- `cascor_constants/` — candidate-relevant constants.

Per the migration plan these ship under the **same top-level package names** cascor uses,
so the canonical imports resolve verbatim.

## Install

```bash
pip install juniper-cascor-model           # core (numpy, torch, PyYAML)
pip install juniper-cascor-model[full]     # + optional dev/debug helpers (dill, columnar)
```

## Usage

```python
from candidate_unit.candidate_unit import CandidateUnit
from utils.activation import ActivationWithDerivative

assert "Tanh" in ActivationWithDerivative.ACTIVATION_MAP   # 33 activations, both casings
```

## Deployment-agnostic logging

The shared logger writes a log file under a source-relative `logs/` directory by default.
In containers where that path is not writable, set **`JUNIPER_CASCOR_LOG_DIR`** to a
writable directory — or leave it unset and file logging degrades to console-only rather
than raising (a missing log file never fails a candidate-training task). Log level is
controlled by `JUNIPER_CASCOR_LOG_LEVEL` (legacy `CASCOR_LOG_LEVEL` still honored).

## Relationship to juniper-cascor

This package is **extracted from** `juniper-cascor/src` and kept byte-identical to it by a
drift-guard test (the candidate-critical modules), pending `juniper-cascor` itself adopting
the package (CW-05 plan Wave 2). Until then, cascor remains the upstream source of truth for
the candidate-training code.

## License

MIT — see [LICENSE](LICENSE).
