glotzerlab / signac-flow

Workflow management for signac-managed data spaces.
https://signac.io/
BSD 3-Clause "New" or "Revised" License
48 stars 37 forks source link

Move submit command to end of output. #805

Closed joaander closed 9 months ago

joaander commented 9 months ago

Description

Move the submit command comment (i.e. # Submit command: sbatch) to the end of the pretend output.

Motivation and Context

When testing, it is often convenient to save the output of submit --pretend and submit it manually. With # Submit command: sbatch as the first line of output, python project.py submit -n 1 --pretend > file.sh does produce a valid SLURM script. Moving the comment to the end preserves the information while creating a valid SLURM script that needs no further editing.

Checklist:

joaander commented 9 months ago

I tested this change with this script:

import signac
import flow

class Project(flow.FlowProject):
    pass

@Project.operation
def operation(job):
    pass

if __name__ == "__main__":
    project = Project()
    job = project.open_job({}).init()

    project.submit(pretend=True)

Output before the change:

# Submit command: sbatch
#!/bin/bash
#SBATCH --job-name="Project/99914b932bd37a50b983c5e7c90ae93b/operation/4660846d0ccf58930f85a67b721b8dac"
#SBATCH --partition=standard
#SBATCH --nodes=1-1
#SBATCH --ntasks=1
#SBATCH --cpus-per-task=1
#SBATCH --account=sglotzer9

set -e
set -u

cd /home/joaander/test/flow-submit-comment

# operation(99914b932bd37a50b983c5e7c90ae93b)
/home/joaander/miniforge3/bin/python /home/joaander/test/flow-submit-comment/submit.py run -o operation -j 99914b932bd37a50b983c5e7c90ae93b
# Eligible to run:
# /home/joaander/miniforge3/bin/python /home/joaander/test/flow-submit-comment/submit.py exec operation 99914b932bd37a50b983c5e7c90ae93b

Output after the change:

#!/bin/bash
#SBATCH --job-name="Project/99914b932bd37a50b983c5e7c90ae93b/operation/4660846d0ccf58930f85a67b721b8dac"
#SBATCH --partition=standard
#SBATCH --nodes=1-1
#SBATCH --ntasks=1
#SBATCH --cpus-per-task=1
#SBATCH --account=sglotzer9

set -e
set -u

cd /home/joaander/test/flow-submit-comment

# operation(99914b932bd37a50b983c5e7c90ae93b)
/home/joaander/miniforge3/bin/python /home/joaander/test/flow-submit-comment/submit.py run -o operation -j 99914b932bd37a50b983c5e7c90ae93b
# Eligible to run:
# /home/joaander/miniforge3/bin/python /home/joaander/test/flow-submit-comment/submit.py exec operation 99914b932bd37a50b983c5e7c90ae93b

# Submit command: sbatch

Is the extra blank line intentional? I left it.

codecov[bot] commented 9 months ago

Codecov Report

All modified and coverable lines are covered by tests :white_check_mark:

Comparison is base (eb67b3f) 69.27% compared to head (28f2dd9) 69.25%.

Additional details and impacted files ```diff @@ Coverage Diff @@ ## main #805 +/- ## ========================================== - Coverage 69.27% 69.25% -0.03% ========================================== Files 48 48 Lines 4397 4397 Branches 1065 1018 -47 ========================================== - Hits 3046 3045 -1 - Misses 1142 1143 +1 Partials 209 209 ```

:umbrella: View full report in Codecov by Sentry.
:loudspeaker: Have feedback on the report? Share it here.

joaander commented 9 months ago

codecov reports that processing failed, please ignore the failing report. This pull request does not change the test coverage.