Skip to content

[BUG] Calculator availability check uses schema importability instead of engine availability, causing runtime failures #102

@tdpham2

Description

@tdpham2

Problem: When fairchem-core (or mace-torch) is not installed, ChemGraph still selects FAIRChem as the default calculator and advertises it as available. The workflow then fails at runtime with:
ERROR:chemgraph.agent.llm_agent:Error running workflow single_agent: fairchem is not installed.

The default calculator selection in src/chemgraph/schemas/ase_input.py:51-57 checks whether the Pydantic schema class (FAIRChemCalc) is importable:

if FAIRChemCalc:
    default_calculator = FAIRChemCalc
elif MaceCalc:
    default_calculator = MaceCalc
else:
    default_calculator = NWChemCalc

But FAIRChemCalc is always importable because it's a Pydantic BaseModel defined in ChemGraph(src/chemgraph/schemas/calculators/fairchem_calc.py:15). The only top-level dependency it needs is torch, which is a core dependency. The actual engine import (from fairchem.core import ...) is guarded by try/except inside fairchem_calc.py, so the schema class always exists regardless of whether fairchem-core is installed.

Same issue with MaceCalc.

Related problem: While config.toml defines [chemistry.calculators] default = "mace_mp", this value is never read by the calculator selection logic. It's only used for Streamlit UI display.

Metadata

Metadata

Assignees

Labels

bugSomething isn't working

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions