Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

221.Add force checkout and compile functionality #236

Open
wants to merge 52 commits into
base: main
Choose a base branch
from

Conversation

singhd789
Copy link
Collaborator

@singhd789 singhd789 commented Oct 30, 2024

Describe your changes

This PR adds

  • force-checkout
  • force-compile
  • force-dockerfile

These make it easier to edit scripts in between steps. Previously, if steps were run to make scripts, then re-run, there would just be a print statement that the script existed already. However, if the user wanted to change something, let's say in the checkout script, then re-run to execute it, that functionality was not there. They would've had to edit something in their configuration and start over.

Issue ticket number and link (if applicable)

#221

Checklist before requesting a review

  • I ran my code
  • I tried to make my code readable
  • I tried to comment my code
  • I wrote a new test, if applicable
  • I wrote new instructions/documentation, if applicable
  • I ran pytest and inspected it's output
  • I ran pylint and attempted to implement some of it's feedback

…eckout-and-compile

-also fix decorator function in `run_fremake.py`
- code was repeated if `--force-compile` was used
- code was repeated if `--force-checkout`, `--force-compile` or `--force-dockerfile` was used
- code would be duplicated if `--force-dockerfile` option is used
@singhd789 singhd789 requested a review from rem1776 December 11, 2024 21:52
@singhd789 singhd789 marked this pull request as ready for review January 9, 2025 18:46
@ilaflott
Copy link
Member

Looks fairly well thought out to me here- any tests coming?

maybe add quick desc of what the PR adds in plain english when you can!

@singhd789
Copy link
Collaborator Author

singhd789 commented Jan 10, 2025

Looks fairly well thought out to me here- any tests coming?

maybe add quick desc of what the PR adds in plain english when you can!

Oh wait! I can totally add test to test_run_fremake since that's in there already. (I can also add to the compile test I have going in a PR and work with Avery to add tests for checkout). Maybe the compile test can be merged in first - then I can add to it to test this functionality. Also good idea on the description, I think I meant to add to it when I took it out of draft but then forgot

@singhd789 singhd789 marked this pull request as draft January 10, 2025 21:19
@singhd789
Copy link
Collaborator Author

@ilaflott Thanks for taking a look in your spare time btw

@singhd789 singhd789 marked this pull request as ready for review January 15, 2025 19:34
@ilaflott ilaflott self-requested a review January 17, 2025 22:50
@ilaflott
Copy link
Member

i'd help resolve these conflicts, approve+merge whenever you're ready.

@singhd789
Copy link
Collaborator Author

i'd help resolve these conflicts, approve+merge whenever you're ready.

Thanks @ilaflott. I'll work on merge conflicts and probably ping you when I think everything's good

Dana Singh added 10 commits January 21, 2025 10:54
…rce-checkout-and-compile

- resolve merge conflicts
- these changes will be done in another issue
- instead of passing fremake object to run function, just pass compile script path to run
- this allows an already created compile script to also run in parallel (if not being created or if no `force-compile` is used)
@singhd789
Copy link
Collaborator Author

@ilaflott @uramirez8707 @rem1776 Ooook, had to iron out some things that I was doing that I actually didn't want to be doing, but I think this PR should be ok for reviews/tests now 🤞

Copy link
Contributor

@uramirez8707 uramirez8707 left a comment

Choose a reason for hiding this comment

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

I tried these options and they seem to work.

Just have some comments.

if run:
if force_checkout:
# Remove previous checkout
print("\nRemoving previously checkout script and checked out source code")
Copy link
Contributor

Choose a reason for hiding this comment

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

I think rather than removing it you should back up the src and exec directory. This what bronx ouputs

WARNING: Since you've specified --force-compile (-F), existing compile and environment scripts have been renamed using timestamp '20250130.085825'
         New compile and environment scripts will be created...
         You can remove old scripts later by typing:
         rm -f /gpfs/f5/gfdl_f/scratch/Uriel.Ramirez/SPEAR_experiments_Q_2025.01-beta1/SPEAR_Q2025.01-beta1_nonsymMOM6_exec/ncrc5.intel23-classic-repro-openmp/exec/compile_SPEAR_Q2025.01-beta1_nonsymMOM6_exec.csh.20250130.085825
         rm -f /gpfs/f5/gfdl_f/scratch/Uriel.Ramirez/SPEAR_experiments_Q_2025.01-beta1/SPEAR_Q2025.01-beta1_nonsymMOM6_exec/ncrc5.intel23-classic-repro-openmp/exec/env.cshrc.20250130.085825

## If combined yaml exists, note message of its existence
## If combined yaml does not exist, combine model, compile, and platform yamls
combined = Path(f"combined-{name}.yaml")
full_combined = cy.combined_compile_existcheck(combined,yml,platform,target)
Copy link
Contributor

@uramirez8707 uramirez8707 Jan 30, 2025

Choose a reason for hiding this comment

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

I think if the combined yaml exists, it should combined them again and compare them and output a warning if they are not the same and suggest the --force* options

For example, if you change something in your yaml and you forget to delete the combined yaml, fre-canopy is going to use the combined-yaml that already exist and won't do what you expect (I have done this sooooo many times :/)

This is what bronx outpust:

WARNING: The existing checkout script '/gpfs/f5/gfdl_f/scratch/Uriel.Ramirez/SPEAR_experiments_Q_2025.01-beta1/SPEAR_Q2025.01-beta1_nonsymMOM6_exec/src/checkout.csh' doesn't match checkout instructions in the XML file!
         If you need a fresh checkout, please rerun the fremake with the --force-checkout (-f) option.

Copy link
Contributor

Choose a reason for hiding this comment

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

I agree with this 200%.

This is making me wonder though, why not go one step further and just not even write the combined yaml to a file?

I will admit, I never really understood why we combine the yamls and write it out in the first place, so maybe there's a better reason then I'm seeing.

But if the current fremake yamls (platform/compile/etc) are what we are going to be modifying and using in place of xmls, the combined yamls don't really need to exist as files, they can stay in memory. Otherwise, they just kinda get in the way of whatever yaml files the user specifies.

os.chmod(src_dir+"/checkout.sh", 0o744)
print(" Checkout script created in "+ src_dir + "/checkout.sh \n")

return fre_checkout
Copy link
Contributor

Choose a reason for hiding this comment

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

just curious, is this returned for a reason?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants