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

add --execute option to run-fremake #271

Merged
merged 9 commits into from
Nov 27, 2024

Conversation

rem1776
Copy link
Contributor

@rem1776 rem1776 commented Nov 20, 2024

Describe your changes

Changes run-fremake to work more like bronx's fremake and require a -e/--execute flag to run build scripts.

If the --execute option is given, it'll work as it does currently without the flag and run the compile script/docker build command after it is created. If its not given, it'll print out a compile script path for the user to run.

Since container builds don't have a build script currently this also adds code to write out a short script with the container commands to build and transfer the format.

Issue ticket number and link (if applicable)

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

run the container; apptainer or singularity used
"""
os.system(containerBuild+" build -f Dockerfile -t "+self.e+":"+self.target.gettargetName())
os.system("rm -f "+self.e+".tar "+self.e+".sif")
os.system(containerBuild+" save -o "+self.e+"-"+self.target.gettargetName()+".tar localhost/"+self.e+":"+self.target.gettargetName())
os.system(containerRun+" build --disable-cache "+self.e+"-"+self.target.gettargetName()+".sif docker-archive://"+self.e+"-"+self.target.gettargetName()+".tar")

def createBuildScript(self,containerBuild,containerRun):
Copy link
Collaborator

Choose a reason for hiding this comment

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

Great idea, thanks for this! Takes a little bit more of the magic of how to build the actual container away. 🎉 Maybe we should actually make the creation of this script a default behavior in def build. (basically replacing def build with def createBuildScript)
Then in runFremake.py, instead of

if execute:
    dockerBuild.build(containerBuild,containerRun)
else:
    dockerBuild.createBuildScript(containerBuild, containerRun)
    print("Container build script created at "+dockerBuild.userScriptPath+"\n\n")

It would be:

#create the container build script
dockerBuild.createBuildScript(containerBuild, containerRun)

#print statement 
(ADD print statement somewhere about where the script is located)

if execute:
    subprocess.run(args=[dockerBuild.userScriptPath], check=True)
else:
    print("Container build script created at "+dockerBuild.userScriptPath+"\n\n")

What do you think? Or do you think it might be better to have one less script being made if it doesn't need to be (i.e. if execute is passed, no need to make the build script)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yeah I think always making the script is a good idea just cause it'll be a little more transparent and easier to debug build issues. I'll add those changes in!

@singhd789
Copy link
Collaborator

This is looking good! Do you think we can also add print statements for where the checkout and Makefile files are too? I think for checkout, we could put this on line 91 of runfremake.py:

print("\nCheckout script created in "+ srcDir + "/checkout.sh \n")

Then for the makefile, output around line 131 of runfremake.py:

print("\nMakefile created at " + bldDir + "/Makefile" + "\n")

@singhd789 singhd789 merged commit c8d940e into NOAA-GFDL:main Nov 27, 2024
2 checks passed
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.

2 participants