Skip to content

Updated the yaml output to reference the toml file in the output#4264

Open
AmanKashyap0807 wants to merge 1 commit intoCliMA:mainfrom
AmanKashyap0807:main
Open

Updated the yaml output to reference the toml file in the output#4264
AmanKashyap0807 wants to merge 1 commit intoCliMA:mainfrom
AmanKashyap0807:main

Conversation

@AmanKashyap0807
Copy link

directory to prevent restart failures when original files are moved

Purpose

This PR addresses issue #4040. Currently, the output YAML file generated after a simulation references the paths of the original input TOML files. If those original files are moved or deleted, restarting the simulation from the output YAML fails.

This change ensures that the output YAML points to the absolute path of the parameters TOML file that is automatically saved in the output directory ( <job_id>_parameters.toml ). This makes the output folder self-contained and allows for robust restarts even if the original input files are modified or removed.

To-do

  • Modify get_simulation in type_getters.jl to update the toml path in output config
  • use abspath to ensure the path is unambiguous regardless of the execution directory

Content

The fix is implemented in type_getters.jl withing the get_simulation function.
Prior to writing the output YAML file, I created a copy of config.parsed_args to avoid modifying the runtime configuration object (which seemed safer than in-place mutation). In this copy, I updated the toml key to be a list containing the absolute path to the local *_parameters.toml file.

As suggested by @haakon-e and @nefrathenrici , I used the full absolute path (abspath(...)) for the new TOML entry. This avoids potential ambiguity with relative paths depending on where the Julia process is launched.

Verification Step:

I verified this manually using a small "box" simulation configuration:

  1. Ran a simulation using an existing TOML file ( box_density_current_test.toml ) as input.
  2. Verified that the generated output YAML now points to the file in the output directory instead of the original input file.
  3. Renamed the original input TOML file to simulate deletion.
  4. Successfully restarted the simulation using the generated output YAML

Let me know if any adjustment are needed, or if you want any test script.


  • I have read and checked the items on the review checklist.

Copy link
Contributor

@github-actions github-actions bot left a comment

Choose a reason for hiding this comment

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

⚠️ Contributor License Agreement required

The following contributor(s) must sign the CLA before this PR can be merged:

Please visit https://ecodesign.clima.caltech.edu/cla/ to review and sign the CLA.

How to sign: Authenticate with GitHub then click the "I agree" button.

Once completed, re-run the checks on this PR.

Copy link
Member

@haakon-e haakon-e left a comment

Choose a reason for hiding this comment

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

Thank you again for working on this, @AmanKashyap0807!

I left a comment with minor improvements for you to consider.

Could you also write a unit test that verifies this behavior? It may be easiest to make a new file, as I don't see any existing tests call get_simulation.

You'll also need to sign the contributor license agreement, if you haven't done so already.


@nefrathenrici This PR makes me realize that because this functionality is contained within get_simulation, it is not called when we create the simulation through a runscript (ref #4236); as is the case for YAML.write_file. I wonder if it would be cleaner if the functionality is put into a separate function that both get_simulation and AtmosSimulation calls. What do you think?

@@ -995,7 +995,11 @@ function get_simulation(config::AtmosConfig)
joinpath(output_dir, "$(job_id)_parameters.toml"),
Copy link
Member

Choose a reason for hiding this comment

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

It looks like you could make a variable name like:

output_toml_file = joinpath(output_dir, "$(job_id)_parameters.toml")

and reference that both in the call to CP.log_parameter_information, and the code you wrote below (but with abspath(output_toml_file). That way, it's slightly clearer that we're referring to the same file.

Copy link
Author

Choose a reason for hiding this comment

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

Thanks for the suggestion, That makes sense
I’ll update the code to introduce output_toml_file and reuse it in both places.

@AmanKashyap0807
Copy link
Author

I have added a unit test that run minimal simulation using get_simulation and checks that the generated output YAML points to the absolute path of the parameter TOML stored in the output directory rather than the original input TOML.

Please let me know if you’d like any changes to the test or implementation. I’m also happy to help with other issues.

Copy link
Member

@haakon-e haakon-e left a comment

Choose a reason for hiding this comment

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

Thanks for the updates! A few comments about tests, then this should be good to go.

@AmanKashyap0807
Copy link
Author

AmanKashyap0807 commented Feb 7, 2026

Hi @haakon-e,
I have addressed the changes you suggested and pushed two follow up commits:

The first commit simplifies the test_output_yaml_path test and adds it to runtests.jl so it runs as part of CI,
The second commit fixes a CI-only failure in test_output_yaml_path.jl. The test was previously referencing the input TOML via a relative path, but CI runners do not execute tests from the repository root. I updated the test to explicitly resolve the TOML file from the project root, so it is found consistently across all CI environments.

@haakon-e
Copy link
Member

haakon-e commented Feb 8, 2026

@AmanKashyap0807 Thanks! Can you rebase to latest main and squash your changes into one commit?

…ded test_output_yaml_path for it and added it in CI
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Output yaml file should point to output toml file

2 participants