LDMX-Software / ldmx-sw

The Light Dark Matter eXperiment simulation and reconstruction framework.
https://ldmx-software.github.io
GNU General Public License v3.0
21 stars 19 forks source link

just adopt a task runner #1377

Closed tomeichlersmith closed 6 days ago

tomeichlersmith commented 1 month ago

After I started looking into adopting denv within ldmx-sw I realized that I was just writing custom shell scripts to run various common commands that ldmx-sw developers run. In the software biz, this is called "task running" and there are a plethora of solutions already available. After some browsing, I can across the task runner just which I find to be beneficial for a few reasons:

On the branch associated with this issue, I've included a justfile that I haven't thoroughly tested but shows what I'm imagining could be used. The terminal output of running just without any arguments (and the default task being just --list) gives the help message.

tom@appa:~/code/ldmx/ldmx-sw$ just
just --list
Available recipes:
    build             # compile and install ldmx-sw
    check             # check that the necessary programs for running ldmx-sw are present
    configure *CONF   # configure how ldmx-sw will be built
    fire config *ARGS # run ldmx-sw with the input configuration script
    init              # initialize a containerized development environment
    mount *DIR        # mount a directory into the denv
    pull *IMAGE       # make sure the image is pulled down
    setenv *ENVVAR    # pass an environment variable into the denv
    use *IMAGE        # change which image is used for the denv

I also want to include an image of this because it is :sparkles: pretty :sparkles:

image

In the SW Dev Meeting where I first brought up just, the request was made to include the possibility of still have ldmx be the root command. I also like this and so the solution I'm imagining is to simply have ldmx be an alias for just.

tom@appa:~/code/ldmx/ldmx-sw$ alias ldmx=just
tom@appa:~/code/ldmx/ldmx-sw$ ldmx
just --list
Available recipes:
    build             # compile and install ldmx-sw
    check             # check that the necessary programs for running ldmx-sw are present
    configure *CONF   # configure how ldmx-sw will be built
    fire config *ARGS # run ldmx-sw with the input configuration script
    init              # initialize a containerized development environment
    mount *DIR        # mount a directory into the denv
    pull *IMAGE       # make sure the image is pulled down
    setenv *ENVVAR    # pass an environment variable into the denv
    use *IMAGE        # change which image is used for the denv

Related Discussions for Background

tvami commented 1 month ago

ldmx be an alias for just.

and that's something we can do when sourcing the environment, right? I think this will make it almost transparent to most users.

Also can you add the compile and the recompFire commands to your justfile, please?

tomeichlersmith commented 1 month ago

can you add the compile and the recompFire commands to your justfile, please?

Just did :+1: https://github.com/LDMX-Software/ldmx-sw/commit/d084d1e2a43c354e64608a074da998142dc18687

we can do when sourcing the environment, right?

yes, I think the ldmx-env.sh would evolve into only alias ldmx=just after some time allowing for folks to transition. I could add a check for denv and just to the header of ldmx-env.sh and then if they both pass, we would alias ldmx=just and if they don't there would be a warning.

tvami commented 1 month ago

Just did

thanks, but recompFire only does fire like this now, no?

I could add a check for

yeah I think that sounds good!

tomeichlersmith commented 1 month ago

It calls the fire task which calls the build task as a dependency so both build and fire will be run.

I may want to rewrite this if I find while testing that recompiling before firing every time is too onerous.

tomeichlersmith commented 1 month ago

Testing Notes

tomeichlersmith commented 1 month ago

image

New screenshot with updates. Want to look into deducing argv[0] so the help message can have ldmx or just depending on user's choice. Not sure if that is possible though.

tomeichlersmith commented 1 month ago

More thoughts while on the train, mostly in regards to environment variables we can define in the justfile to apply to all the recipes it runs.

:stop_sign: Will Not :stop_sign: