-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
core: add core of transform layer with steps
This is for Flux, which probably is not as important as other use cases since it understands a jobspec, but it demonstrates the basic staging, writing, and submit of a script. I will add other steps I need now, and then likely other transformers for things that are not flux. Signed-off-by: vsoch <[email protected]>
- Loading branch information
Showing
33 changed files
with
1,282 additions
and
70 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
FROM fluxrm/flux-sched:jammy | ||
|
||
LABEL maintainer="Vanessasaurus <@vsoch>" | ||
|
||
# Match the default user id for a single system so we aren't root | ||
ARG USERNAME=vscode | ||
ARG USER_UID=1000 | ||
ARG USER_GID=1000 | ||
ENV USERNAME=${USERNAME} | ||
ENV USER_UID=${USER_UID} | ||
ENV USER_GID=${USER_GID} | ||
USER root | ||
RUN apt-get update && apt-get install -y less python3-pip | ||
|
||
# Add the group and user that match our ids | ||
RUN groupadd -g ${USER_GID} ${USERNAME} && \ | ||
adduser --disabled-password --uid ${USER_UID} --gid ${USER_GID} --gecos "" ${USERNAME} && \ | ||
echo "${USERNAME} ALL=(ALL) NOPASSWD: ALL" > /etc/sudoers | ||
|
||
USER $USERNAME |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
{ | ||
"name": "Jobspec Developer Environment", | ||
"dockerFile": "Dockerfile", | ||
"context": "../", | ||
|
||
"customizations": { | ||
"vscode": { | ||
"settings": { | ||
"terminal.integrated.defaultProfile.linux": "bash" | ||
}, | ||
"extensions": [ | ||
"ms-vscode.cmake-tools", | ||
"golang.go" | ||
] | ||
} | ||
}, | ||
"postStartCommand": "git config --global --add safe.directory /workspaces/jobspec" | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
# TODO test these out on on x86, then create arm specs | ||
version: 1 | ||
resources: | ||
- count: 4 | ||
type: node | ||
with: | ||
- count: 1 | ||
label: hello-world | ||
type: slot | ||
with: | ||
- count: 4 | ||
type: core | ||
|
||
task: | ||
command: ["/bin/bash", "job.sh"] | ||
transform: | ||
- step: write | ||
filename: job.sh | ||
executable: true | ||
|
||
# This is only provided as an example - in the devcontainer it's just one physicap machine! | ||
#- step: stage | ||
# filename: install.sh | ||
|
||
- step: submit | ||
filename: job.sh | ||
|
||
scripts: | ||
- name: job.sh | ||
content: | | ||
#!/bin/bash | ||
echo hello world from $(hostname) | ||
count: | ||
per_slot: 1 | ||
resources: | ||
hardware: | ||
hardware.gpu.available: 'no' | ||
io.archspec: | ||
cpu.target: amd64 | ||
slot: hello-world |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
# TODO test these out on on x86, then create arm specs | ||
version: 1 | ||
resources: | ||
- count: 4 | ||
type: node | ||
with: | ||
- count: 1 | ||
label: hello-world | ||
type: slot | ||
with: | ||
- count: 4 | ||
type: core | ||
|
||
task: | ||
command: ["/bin/bash", "job.sh"] | ||
transform: | ||
- step: write | ||
filename: job.sh | ||
executable: true | ||
|
||
# This is only provided as an example - in the devcontainer it's just one physicap machine! | ||
#- step: stage | ||
# filename: install.sh | ||
|
||
- step: submit | ||
filename: job.sh | ||
wait: true | ||
|
||
scripts: | ||
- name: job.sh | ||
content: | | ||
#!/bin/bash | ||
echo hello world from $(hostname) | ||
count: | ||
per_slot: 1 | ||
resources: | ||
hardware: | ||
hardware.gpu.available: 'no' | ||
io.archspec: | ||
cpu.target: amd64 | ||
slot: hello-world |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,106 @@ | ||
#!/usr/bin/env python | ||
|
||
import argparse | ||
import os | ||
import sys | ||
|
||
import jobspec | ||
from jobspec.logger import setup_logger | ||
|
||
|
||
def get_parser(): | ||
parser = argparse.ArgumentParser( | ||
description="Jobspec", | ||
formatter_class=argparse.RawTextHelpFormatter, | ||
) | ||
|
||
# Global Variables | ||
parser.add_argument( | ||
"--debug", | ||
dest="debug", | ||
help="use verbose logging to debug.", | ||
default=False, | ||
action="store_true", | ||
) | ||
|
||
parser.add_argument( | ||
"--quiet", | ||
dest="quiet", | ||
help="suppress additional output.", | ||
default=False, | ||
action="store_true", | ||
) | ||
parser.add_argument( | ||
"--version", | ||
dest="version", | ||
help="show software version.", | ||
default=False, | ||
action="store_true", | ||
) | ||
|
||
subparsers = parser.add_subparsers( | ||
help="actions", | ||
title="actions", | ||
description="actions", | ||
dest="command", | ||
) | ||
subparsers.add_parser("version", description="show software version") | ||
|
||
# Maybe this warrants a better name, but this seems to be what we'd want to do - | ||
# run a jobspec | ||
run = subparsers.add_parser( | ||
"run", | ||
formatter_class=argparse.RawTextHelpFormatter, | ||
description="receive and run a jobpsec", | ||
) | ||
run.add_argument("-t", "--transform", help="transformer to use", default="flux") | ||
run.add_argument("jobspec", help="jobspec yaml file", default="jobspec.yaml") | ||
return parser | ||
|
||
|
||
def run_jobspec(): | ||
""" | ||
this is the main entrypoint. | ||
""" | ||
parser = get_parser() | ||
|
||
def help(return_code=0): | ||
"""print help, including the software version and active client | ||
and exit with return code. | ||
""" | ||
version = jobspec.__version__ | ||
|
||
print("\nJobspec v%s" % version) | ||
parser.print_help() | ||
sys.exit(return_code) | ||
|
||
# If the user didn't provide any arguments, show the full help | ||
if len(sys.argv) == 1: | ||
help() | ||
|
||
# If an error occurs while parsing the arguments, the interpreter will exit with value 2 | ||
args, extra = parser.parse_known_args() | ||
|
||
if args.debug is True: | ||
os.environ["MESSAGELEVEL"] = "DEBUG" | ||
|
||
# Show the version and exit | ||
if args.command == "version" or args.version: | ||
print(jobspec.__version__) | ||
sys.exit(0) | ||
|
||
setup_logger( | ||
quiet=args.quiet, | ||
debug=args.debug, | ||
) | ||
|
||
# Here we can assume instantiated to get args | ||
if args.command == "run": | ||
from .run import main | ||
else: | ||
help(1) | ||
main(args, extra) | ||
|
||
|
||
if __name__ == "__main__": | ||
run_jobspec() |
Binary file not shown.
Binary file not shown.
Oops, something went wrong.