Skip to content

Write auto generated input file to tmp#2148

Draft
YigitElma wants to merge 7 commits intomasterfrom
yge/writing-inputfiles
Draft

Write auto generated input file to tmp#2148
YigitElma wants to merge 7 commits intomasterfrom
yge/writing-inputfiles

Conversation

@YigitElma
Copy link
Copy Markdown
Collaborator

@YigitElma YigitElma commented Mar 31, 2026

Resolves #2139

InputReader.parse_inputs method now writes the DESC input file to a temporary file where users have write access.

@YigitElma YigitElma self-assigned this Mar 31, 2026
@YigitElma YigitElma added the easy Short and simple to code or review label Mar 31, 2026
@github-actions
Copy link
Copy Markdown
Contributor

github-actions bot commented Mar 31, 2026

Memory benchmark result

|               Test Name                |      %Δ      |    Master (MB)     |      PR (MB)       |    Δ (MB)    |    Time PR (s)     |  Time Master (s)   |
| -------------------------------------- | ------------ | ------------------ | ------------------ | ------------ | ------------------ | ------------------ |
  test_objective_jac_w7x                 |    0.59 %    |     4.107e+03      |     4.131e+03      |    24.38     |       43.66        |       39.15        |
  test_proximal_jac_w7x_with_eq_update   |   -0.16 %    |     6.664e+03      |     6.653e+03      |    -10.80    |       160.32       |       160.25       |
  test_proximal_freeb_jac                |   -0.04 %    |     1.340e+04      |     1.340e+04      |    -5.49     |       88.74        |       89.24        |
  test_proximal_freeb_jac_blocked        |   -0.17 %    |     7.785e+03      |     7.771e+03      |    -13.37    |       78.19        |       77.91        |
  test_proximal_freeb_jac_batched        |   -0.21 %    |     7.719e+03      |     7.703e+03      |    -16.37    |       77.30        |       77.30        |
  test_proximal_jac_ripple               |   -0.04 %    |     3.671e+03      |     3.670e+03      |    -1.34     |       66.18        |       67.10        |
  test_proximal_jac_ripple_bounce1d      |    2.07 %    |     3.843e+03      |     3.923e+03      |    79.57     |       78.65        |       78.44        |
  test_eq_solve                          |    1.13 %    |     2.211e+03      |     2.237e+03      |    25.07     |       98.03        |       98.74        |

For the memory plots, go to the summary of Memory Benchmarks workflow and download the artifact.

@YigitElma YigitElma marked this pull request as draft March 31, 2026 05:22
@codecov
Copy link
Copy Markdown

codecov bot commented Mar 31, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 94.48%. Comparing base (f8c0ec0) to head (7cb2ec5).

Additional details and impacted files
@@           Coverage Diff           @@
##           master    #2148   +/-   ##
=======================================
  Coverage   94.48%   94.48%           
=======================================
  Files         102      102           
  Lines       28721    28724    +3     
=======================================
+ Hits        27137    27141    +4     
+ Misses       1584     1583    -1     
Files with missing lines Coverage Δ
desc/input_reader.py 92.15% <100.00%> (+0.02%) ⬆️

... and 3 files with indirect coverage changes

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@YigitElma YigitElma marked this pull request as ready for review March 31, 2026 19:07
print("Converting VMEC input to DESC input")
path = self.input_path + "_desc"
basename = os.path.basename(self.input_path) + "_desc"
tmpdir = tempfile.mkdtemp()
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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?".

@mishapadidar
Copy link
Copy Markdown

When I ran the test, the temp directory still existed after the code ran.

@YigitElma
Copy link
Copy Markdown
Collaborator Author

Add a flag for tmp file option

@YigitElma
Copy link
Copy Markdown
Collaborator Author

Try to pass a file-like object

@YigitElma YigitElma marked this pull request as draft April 6, 2026 16:30
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

easy Short and simple to code or review

Projects

None yet

Development

Successfully merging this pull request may close these issues.

from_input_file writing file without permissions

2 participants