@@ -118,20 +118,24 @@ def rename_saved_analysis(old_analysis_name, new_analysis_name):
118
118
else :
119
119
raise Exception (f'Invalid rename, with old and new analysis are { old_analysis_name } and { new_analysis_name } ' )
120
120
121
-
122
- def write_saved_analysis (analysis_path : str , steps_data : List [Dict [str , Any ]], public_interface_version : int , args : List [str ], code_options : CodeOptions , version : str = __version__ ) -> None :
121
+ def get_saved_analysis_string (steps_manager : StepsManagerType ) -> str :
122
+ saved_analysis_string = json .dumps ({
123
+ 'version' : __version__ ,
124
+ 'steps_data' : get_steps_obj_for_saved_analysis (steps_manager .steps_including_skipped ),
125
+ 'public_interface_version' : steps_manager .public_interface_version ,
126
+ 'args' : steps_manager .original_args_raw_strings ,
127
+ 'code' : steps_manager .code (),
128
+ 'code_options' : steps_manager .code_options
129
+ }, cls = NpEncoder )
130
+ return saved_analysis_string
131
+
132
+ def _write_saved_analysis_file (analysis_path : str , steps_manager : StepsManagerType ) -> None :
133
+ saved_analysis_string = get_saved_analysis_string (steps_manager )
123
134
with open (analysis_path , 'w+' ) as f :
124
- saved_analysis = {
125
- 'version' : version ,
126
- 'steps_data' : steps_data ,
127
- 'public_interface_version' : public_interface_version ,
128
- 'args' : args ,
129
- 'code_options' : code_options
130
- }
131
- f .write (json .dumps (saved_analysis , cls = NpEncoder ))
135
+ f .write (saved_analysis_string )
132
136
133
137
134
- def make_steps_json_obj (
138
+ def get_steps_obj_for_saved_analysis (
135
139
steps : List [Step ]
136
140
) -> List [Dict [str , Any ]]:
137
141
"""
@@ -182,7 +186,7 @@ def make_steps_json_obj(
182
186
183
187
return steps_json_obj
184
188
185
- def write_analysis (steps_manager : StepsManagerType , analysis_name : Optional [str ]= None ) -> None :
189
+ def write_save_analysis_file (steps_manager : StepsManagerType , analysis_name : Optional [str ]= None ) -> None :
186
190
"""
187
191
Writes the analysis saved in steps_manager to
188
192
~/.mito/{analysis_name}. If analysis_name is none, gets the temporary
@@ -203,7 +207,4 @@ def write_analysis(steps_manager: StepsManagerType, analysis_name: Optional[str]
203
207
analysis_name = steps_manager .analysis_name
204
208
205
209
analysis_path = f'{ SAVED_ANALYSIS_FOLDER } /{ analysis_name } .json'
206
- steps = make_steps_json_obj (steps_manager .steps_including_skipped )
207
-
208
- # Actually write the file
209
- write_saved_analysis (analysis_path , steps , steps_manager .public_interface_version , steps_manager .original_args_raw_strings , steps_manager .code_options )
210
+ _write_saved_analysis_file (analysis_path , steps_manager )
0 commit comments