reinvent_custom_scoring_component
Generate a REINVENT4 scoring component plugin (comp_*.py) from your scoring logic and automatically smoke-test it to ensure it works with sample SMILES.
Instructions
Generate a valid comp_*.py plugin file for REINVENT4.
Based on the canonical template from scoring_function.md. No reinstall needed — REINVENT4 discovers comp_*.py files at runtime.
IMPORTANT: Always provide implementation_code. Write the complete call body as plain unindented Python before calling this tool, then pass it here. Indentation is added automatically. This writes the full implementation in one atomic operation. If omitted, a TODO placeholder is written and the file cannot be edited afterward due to permissions.
When implementation_code is provided, the generated plugin is immediately smoke-tested (import, instantiate, call on sample SMILES, contract check). The test_result appears in the response; on failure, regenerate with corrected implementation_code.
Args: component_name: Python class name (e.g. 'MyQSARModel') description: What this component scores scoring_logic: How to compute the score — plain English, pseudocode, or code parameters: List of {name, type, description} dicts for user-configurable inputs component_tag: '_component' (standard), 'filter' (zeros total if 0), 'penalty' (multiplier) use_molcache: If True, call receives List[Chem.Mol]; else List[str] dependencies: External packages required output_dir: Where to write comp*.py (default: reinvent_plugins/components/) implementation_code: Complete body of call as unindented Python. test_after_generate: Run the smoke test after writing (default True). test_smiles: Override SMILES used by the smoke test. test_params: Per-endpoint parameter values for the smoke test, e.g. {"threshold": 0.5} — scalars are list-wrapped automatically.
Returns file path, source code, TOML snippet, and test_result (when tested).
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| output_dir | No | ||
| parameters | No | ||
| description | Yes | ||
| test_params | No | ||
| test_smiles | No | ||
| dependencies | No | ||
| use_molcache | No | ||
| component_tag | No | __component | |
| scoring_logic | Yes | ||
| component_name | Yes | ||
| implementation_code | No | ||
| test_after_generate | No |