Write auto generated input file to tmp#2148
Conversation
…le is used in from_input_file method
Memory benchmark result| Test Name | %Δ | Master (MB) | PR (MB) | Δ (MB) | Time PR (s) | Time Master (s) |
| -------------------------------------- | ------------ | ------------------ | ------------------ | ------------ | ------------------ | ------------------ |
test_objective_jac_w7x | -1.60 % | 3.917e+03 | 3.854e+03 | -62.84 | 30.43 | 28.42 |
test_proximal_jac_w7x_with_eq_update | 0.00 % | 6.568e+03 | 6.568e+03 | 0.15 | 148.52 | 148.30 |
test_proximal_freeb_jac | -0.29 % | 1.334e+04 | 1.330e+04 | -39.05 | 79.20 | 76.89 |
test_proximal_freeb_jac_blocked | 0.10 % | 7.707e+03 | 7.715e+03 | 7.55 | 67.06 | 68.18 |
test_proximal_freeb_jac_batched | -0.08 % | 7.621e+03 | 7.614e+03 | -6.28 | 66.76 | 66.66 |
test_proximal_jac_ripple | -0.46 % | 3.532e+03 | 3.515e+03 | -16.42 | 52.63 | 52.52 |
test_proximal_jac_ripple_bounce1d | -0.34 % | 3.749e+03 | 3.736e+03 | -12.62 | 66.58 | 66.00 |
test_eq_solve | 0.75 % | 1.919e+03 | 1.933e+03 | 14.34 | 56.64 | 56.36 |For the memory plots, go to the summary of |
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## master #2148 +/- ##
=======================================
Coverage 94.32% 94.32%
=======================================
Files 101 101
Lines 28866 28870 +4
=======================================
+ Hits 27228 27233 +5
+ Misses 1638 1637 -1
🚀 New features to boost your workflow:
|
| print("Converting VMEC input to DESC input") | ||
| path = self.input_path + "_desc" | ||
| basename = os.path.basename(self.input_path) + "_desc" | ||
| tmpdir = tempfile.mkdtemp() |
There was a problem hiding this comment.
When does the delete operation occur on tmpdir? Does it do so automatically when the function ends?
Another option is to use with, i.e.
with tempfile.TemporaryDirectory() as tmpdir:
path = os.path.join(tmpdir, basename = os.path.basename(self.input_path) + "_desc")
though it could be essentially the same.
There was a problem hiding this comment.
I think it should be cleared after the python process is terminated or the session on the cluster is closed or the system is rebooted on personal laptop, not immediately after the function call. These are the options listed on the web for "when the tmp is cleared?".
|
When I ran the test, the temp directory still existed after the code ran. |
|
Add a flag for tmp file option |
|
Try to pass a file-like object |
Did we want to try this? |
In a previous dev meeting, we said it doesn't worth the effort. |
I was bored and did this. If we decide we don't like it we can revert but was surprisingly easy and clean. |
Resolves #2139
InputReader.parse_inputsmethod now uses an in-memory buffer if it has to convert a vmec to a desc input, resulting in no files being written.