1818
1919
2020class COMcheckClient :
21- """COMcheck Client class for simplified project operations."""
21+ """High-level client for the COMcheck Web API.
22+
23+ Provides user-friendly methods that accept Pydantic models as inputs
24+ and return either :class:`~comcheck_api.types.core_types.ComBuilding`
25+ models, primitives, or raw dicts depending on the operation.
26+
27+ Can be used as a context manager to ensure the underlying HTTP
28+ connection is closed::
29+
30+ with COMcheckClient(api_key="your-key") as client:
31+ project = client.get_project("123")
32+
33+ Example:
34+ ```python
35+ client = COMcheckClient(api_key="your-key")
36+ projects = client.list_projects()
37+ project = client.get_project(projects[0]["projectId"])
38+ client.close()
39+ ```
40+ """
2241
2342 def __init__ (self , api_key : Optional [str ] = None ) -> None :
2443 """Initialize COMcheck client.
@@ -116,15 +135,21 @@ def update_project(
116135 ) -> ComBuilding | dict [str , Any ] | None :
117136 """Update a project by ID.
118137
138+ The existing project is fetched first to preserve server-assigned IDs
139+ and the ``userProject`` reference. Envelope component IDs that are
140+ ``None`` (auto-generated by Pydantic) are stripped before submission.
141+
119142 Args:
120- project_id: The project ID to update
121- project_data: The project data to send in the request body
143+ project_id: The project ID to update.
144+ project_data: A ``ComBuilding`` model with the desired state.
145+ mode: ``"python"`` returns a ``ComBuilding`` model;
146+ ``"json"`` returns a raw dict.
122147
123148 Returns:
124- API response data as dictionary
149+ The refreshed project after the update, in the requested format.
125150
126151 Raises:
127- COMCheckProjectNotFoundError: If project is not found
152+ COMCheckProjectNotFoundError: If the project does not exist.
128153 """
129154 # Get existing project
130155 old_project = self .get_project (project_id , mode = "json" )
@@ -222,13 +247,22 @@ def _parse_data(self, data, mode):
222247 def start_run_simulation (
223248 self , project : ComBuilding , project_id : Optional [int ] = None
224249 ) -> str :
225- """Start a simulation run for a given project.
250+ """Start a compliance simulation run for a project.
251+
252+ If *project_id* is supplied the project is persisted via
253+ :meth:`update_project` before the simulation is launched.
226254
227255 Args:
228- project: The project data to run the simulation
229- project_id: Optional project ID, if not provided, project won't be saved
256+ project: The project data to simulate.
257+ project_id: Optional server-side project ID. When given, the
258+ project is saved before the simulation starts.
259+
230260 Returns:
231- Simulation session ID
261+ The simulation session ID that can be passed to
262+ :meth:`get_simulation_status` and :meth:`get_simulation_result`.
263+
264+ Raises:
265+ COMCheckSimulationError: If the API returns no session data.
232266 """
233267 logger = logging .getLogger (__name__ )
234268
@@ -245,13 +279,16 @@ def start_run_simulation(
245279 return run_result .data .sessionId
246280
247281 def get_simulation_status (self , session_id : str ) -> Dict [str , Any ]:
248- """Get the status of a simulation run by session ID .
282+ """Get the status of a running or completed simulation .
249283
250284 Args:
251- session_id: The simulation session ID
285+ session_id: The session ID returned by :meth:`start_run_simulation`.
252286
253287 Returns:
254- Simulation status information
288+ A dict containing ``sessionId``, ``status``, and optional ``message``.
289+
290+ Raises:
291+ COMCheckSimulationError: If the status cannot be retrieved.
255292 """
256293 status_response = self ._service .get_simulation_status (session_id )
257294 if status_response .data is None :
@@ -261,13 +298,18 @@ def get_simulation_status(self, session_id: str) -> Dict[str, Any]:
261298 return status_response .data .model_dump (mode = "python" )
262299
263300 def get_simulation_result (self , session_id : str ) -> Dict [str , Any ]:
264- """Get the result of a simulation run by session ID .
301+ """Get the result metrics of a completed simulation .
265302
266303 Args:
267- session_id: The simulation session ID
304+ session_id: The session ID returned by :meth:`start_run_simulation`.
268305
269306 Returns:
270- Simulation result information
307+ A dict containing ``sessionId``, ``performanceRating``,
308+ ``energyCreditPerformanceRating``, ``proposedBpf``, and
309+ ``baselineBpf``.
310+
311+ Raises:
312+ COMCheckSimulationError: If the result cannot be retrieved.
271313 """
272314 result_response = self ._service .get_simulation_result (session_id )
273315 if result_response .data is None :
0 commit comments