Coverage for python/gsfit/database_writers/interface.py: 100%

6 statements  

« prev     ^ index     » next       coverage.py v7.16.2, created at 2026-10-14 15:25 +0000

1from typing import TYPE_CHECKING 

2from typing import Any 

3from typing import Protocol 

4 

5if TYPE_CHECKING: 

6 from ..gsfit import Gsfit 

7 

8 

9class DatabaseWriterProtocol(Protocol): 

10 def map_results_to_database(self, gsfit_controller: "Gsfit") -> Any: 

11 """ 

12 Map the results to MDSplus structure. 

13 self.results is a NestedDict type which has a 1:1 mapping to the MDSplus tree. 

14 

15 The MDSplus writers fill `gsfit_controller.results` in place and return `None`. A writer 

16 which builds an object instead returns it, and `Gsfit.write_results_to_database` keeps it: 

17 the `imas` writer returns a populated IMAS `equilibrium` IDS. 

18 """ 

19 ... 

20 

21 def get_workflow_names(self, gsfit_controller: "Gsfit") -> list[str]: 

22 """ 

23 The names of the input codes which this writer will store under `INPUT.WORKFLOW`, 

24 or an empty list if it stores none. 

25 

26 GSFit needs these before it has any results, so that the MDSplus nodes can be created 

27 while the Grad-Shafranov equation is still being solved. 

28 """ 

29 ...