Repository navigation
The Python API
James Dunkerley edited this page Nov 20, 2026
·
3 revisions
Home · Architecture · Backend core
In short
-
tz_ps_conductorexportsProject,NetworkandComponentHandle. - A notebook or script calls them directly, and the HTTP routes call the same objects.
-
Projectowns every operation that names a network,Networkwraps one network and its version, andComponentHandleedits one component. - They sit over the plain models of the domain model.
Project owns every operation that names a network:
- create, read, save, copy, rename and delete;
- version history:
list_versions,compare_versions,restore_version; - series reads and writes;
- the partial edits:
update_components,update_timesteps,update_constraints, and the like; - results;
- file import and export.
Project.create, Project.get and Project.list_projects pull the warehouse from the composition root.
Object or record. A plain name answers an object to act on. The _record name answers the stored, frozen value without building a model.
- On
Projectthe pair isget_networkandget_network_record. - For projects themselves the record reads are on
ProjectFactory:list_project_recordsandget_project_record, beside itslist_projectsandget.
- It wraps a
NetworkModeland theVersionInfoit was loaded from or last saved as. - It offers the self-named call over each
Projectmethod (save,get_results,has_results,list_versions), andsolve. - It keeps a digest of the saved model, so
has_unsaved_changesneeds no read.
add_component, add_or_replace_component and set_timesteps answer the network, so they chain:
network = Network(name="dispatch", framework="PyPSA")
network.timesteps = ("t0", "t1", "t2")
network.add_component("Bus", "bus").add_component(
"Generator", "cheap", bus="bus", p_nom=100.0, marginal_cost=10.0
)Network.get_component_handle answers a handle that edits one component.
-
set(**attributes),set_curve(**curves)andclear(*attributes)answer the handle. -
find_valueandfind_curveread. - A handle refuses once its network no longer holds that component.
The conductor turns a framework's pydantic.ValidationError into its own InvalidComponentAttributesError, so a caller never has to catch a third-party error.
Using the app
Architecture
- Overview
- Python API
- Domain model
- Backend core
- Composition root and config
- Expression language internals
- Storage
- Execution
- Imports and exports
- Workflow engine
- HTTP API and contracts
- Frontend and desktop
- Build, CI and release
Contributing