euromod_linking.session¶
Shared, long-lived EUROMOD connector session.
Owns the single process-wide euromod.Model object and the lock that serializes all connector access (reads and simulation runs). No business logic and no mutation helpers — the model is used read-only at runtime; the only simulation overrides go through System.run() kwargs, which do not mutate the model.
Attributes¶
Exceptions¶
Raised when a country/system is not found. |
Functions¶
|
Make the model behind system the one this process reads from. |
|
Return the live Country object, or raise ModelLookupError(available=[...]). |
|
Return the cached euromod.Model, loading it once per process. |
|
Return the live System object, or raise ModelLookupError(available=[...]). |
Module Contents¶
- exception euromod_linking.session.ModelLookupError(message: str, available: list | None = None)[source]¶
Raised when a country/system is not found.
.availablelists the names that would have worked, so a caller can report them.- available = []¶
- euromod_linking.session.adopt(system) bool[source]¶
Make the model behind system the one this process reads from.
Callers hand apply_scenario a live System they built themselves; the read helpers underneath resolve the model from here. Adopting the caller’s own model closes that gap, so nobody has to load the model twice or through a particular door for income-list expansion to work.
Returns True when a model was adopted. Silent False when system is not a live connector object — the caller may have loaded a model already, and this is a convenience, not a precondition.
- euromod_linking.session.get_country(country_code: str, model_path: str | None = None)[source]¶
Return the live Country object, or raise ModelLookupError(available=[…]).
- euromod_linking.session.get_model(model_path: str | None = None)[source]¶
Return the cached euromod.Model, loading it once per process.
Pass model_path to load (or switch to) a model; omit it to reuse the one already loaded, which is how callers deep in a call chain avoid threading the path through every function. Loading is expensive (.NET + the whole model graph), so a genuinely different path is the only thing that reloads.
- euromod_linking.session.get_system(country_code: str, system_name: str, model_path: str | None = None)[source]¶
Return the live System object, or raise ModelLookupError(available=[…]).
- euromod_linking.session.model_lock¶