Skip to content

Commit

Permalink
minor version updates
Browse files Browse the repository at this point in the history
  • Loading branch information
akashdhruv committed Oct 1, 2023
1 parent d877f65 commit f32211e
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 30 deletions.
2 changes: 1 addition & 1 deletion jobrunner/__meta__.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
"""Metadata for jobrunner"""

__pkgname__ = "PyJobRunner"
__version__ = "2023.10"
__version__ = "2023.10.1"
__authors__ = "Akash Dhruv"
__license__ = "Apache Software License"
__copyright__ = "Copyright (c) Akash Dhruv 2023. All Rights Reserved."
Expand Down
30 changes: 13 additions & 17 deletions jobrunner/api/_commands.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ def setup(workdir_list, verbose=False):
# chdir to working directory and display tree
os.chdir(workdir)
workdir = os.getcwd()
lib.DisplayTree(workdir, basedir)
lib.DisplayTree(basedir, workdir)

# parse main dictionary
main_dict = lib.ParseJobConfig(basedir, workdir)
Expand All @@ -30,9 +30,7 @@ def setup(workdir_list, verbose=False):
print(f"\n{lib.Color.purple}SCRIPTS: {lib.Color.end}")
for value in main_dict["job"]["setup"]:
if value:
print(
f'- {lib.Color.blue}{value.replace(basedir,"ROOT")} {lib.Color.end}'
)
print(f'{" "*4}- {value.replace(basedir,"<ROOT>")}')

# run a bash process
lib.BashProcess(basedir, workdir, "job.setup", verbose)
Expand All @@ -54,7 +52,7 @@ def submit(workdir_list, verbose=False):
# chdir to working directory and display tree
os.chdir(workdir)
workdir = os.getcwd()
lib.DisplayTree(workdir, basedir)
lib.DisplayTree(basedir, workdir)

# parse main dictionary
main_dict = lib.ParseJobConfig(basedir, workdir)
Expand All @@ -64,23 +62,21 @@ def submit(workdir_list, verbose=False):
if main_dict["job"]["input"]:
print(f"\n{lib.Color.purple}INPUT: {lib.Color.end}")
for value in main_dict["job"]["input"]:
print(
f'- {lib.Color.blue}{value.replace(basedir,"ROOT")} {lib.Color.end}'
)
print(f'{" "*4}- {value.replace(basedir,"<ROOT>")}')

# Build targetfile
lib.CreateTargetFile(main_dict)
if main_dict["job"]["target"]:
print(
f"\n{lib.Color.purple}TARGET: "
+ f'{lib.Color.blue}{main_dict["job"]["target"].replace(basedir,"ROOT")} {lib.Color.end}'
f"\n{lib.Color.purple}TARGET:{lib.Color.end} "
+ f'{main_dict["job"]["target"].replace(basedir,"<ROOT>")}'
)

# Build submitfile
lib.CreateSubmitFile(main_dict)
print(f"\n{lib.Color.purple}SCRIPTS: {lib.Color.end}")
for value in main_dict["job"]["submit"]:
print(f'- {lib.Color.blue}{value.replace(basedir,"ROOT")} {lib.Color.end}')
print(f'{" "*4}- {value.replace(basedir,"<ROOT>")}')

# Submit job
if main_dict["schedular"]["command"] == "bash":
Expand All @@ -101,19 +97,19 @@ def clean(workdir_list):
"""
# Get base directory
basedir = os.getcwd()
print(os.get_terminal_size().columns * "—")

# run cleanup
for workdir in workdir_list:

# chdir to working directory and display tree
os.chdir(workdir)
workdir = os.getcwd()
lib.DisplayTree(workdir, basedir)

# parse main dictionary
main_dict = lib.ParseJobConfig(basedir, workdir)

print(f"\n{lib.Color.purple}CLEANING {lib.Color.end}")
print(f"{lib.Color.purple}CLEAN:{lib.Color.end} {workdir}")
lib.RemoveNodeFiles(main_dict, workdir)

os.chdir(basedir)
Expand All @@ -125,21 +121,21 @@ def archive(tag, workdir_list):
"""
# Get base directory
basedir = os.getcwd()
print(os.get_terminal_size().columns * "—")

# loop over workdir_list
for workdir in workdir_list:

# chdir to working directory and display tree
os.chdir(workdir)
workdir = os.getcwd()
lib.DisplayTree(workdir, basedir)

# parse main dictionary
main_dict = lib.ParseJobConfig(basedir, workdir)

# Create archive
print(
f"\n{lib.Color.purple}ARCHIVE: {lib.Color.blue}jobnode.archive/{tag} {lib.Color.end}"
f"{lib.Color.purple}ARCHIVE:{lib.Color.end} {workdir}/jobnode.archive/{tag}"
)

lib.CreateArchive(main_dict, tag)
Expand All @@ -163,13 +159,13 @@ def export(tag, workdir_list):
# chdir to working directory and display tree
os.chdir(workdir)
workdir = os.getcwd()
lib.DisplayTree(workdir, basedir)
lib.DisplayTree(basedir, workdir)

# parse main dictionary
main_dict = lib.ParseJobConfig(basedir, workdir)

# Create archive
print(f"\n{lib.Color.purple}EXPORT: {lib.Color.blue}{tag} {lib.Color.end}")
print(f"{lib.Color.purple}EXPORT:{lib.Color.end} {tag}")
lib.ExportTree(main_dict, tag)

# Return to base directory
Expand Down
20 changes: 8 additions & 12 deletions jobrunner/lib/_console.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
# Standard libraries
import os
import subprocess

# Feature libraries
Expand All @@ -8,26 +9,21 @@
from jobrunner import lib


def DisplayTree(workdir, basedir=None):
def DisplayTree(basedir, workdir):
"""
Display tree information on console
"""
print(
"#######################################################################################################"
)

print(f"{lib.Color.purple}NODE: {lib.Color.blue}{workdir} {lib.Color.end}")

if basedir:
print(f"{lib.Color.purple}ROOT: {lib.Color.blue}{basedir} {lib.Color.end}")
print(os.get_terminal_size().columns * "—")
print(f"{lib.Color.purple}ROOT:{lib.Color.end} {basedir}")
print(f'{lib.Color.purple}NODE:{lib.Color.end} {workdir.replace(basedir,"<ROOT>")}')


def SchedularProcess(basedir, workdir, command, script):
"""
Submit job using a schedular
"""
print(
f'\n{lib.Color.purple}SUBMIT: {lib.Color.blue}{workdir.replace(basedir,"ROOT")}/{script} {lib.Color.end}'
f'\n{lib.Color.purple}SUBMIT:{lib.Color.end} {workdir.replace(basedir,"<ROOT>")}/{script}'
)

process = subprocess.run(
Expand All @@ -42,7 +38,7 @@ def BashProcess(basedir, workdir, script, verbose=False):
Run a bash process based on input configuration
"""
print(
f'\n{lib.Color.purple}EXECUTE: {lib.Color.blue}{workdir.replace(basedir,"ROOT")}/{script} {lib.Color.end}'
f'\n{lib.Color.purple}EXECUTE:{lib.Color.end} {workdir.replace(basedir,"<ROOT>")}/{script}'
)

process = subprocess.Popen(
Expand Down Expand Up @@ -79,5 +75,5 @@ def BashProcess(basedir, workdir, script, verbose=False):
print(f"{lib.Color.green}SUCCESS {lib.Color.end}")

print(
f'\n{lib.Color.purple}OUTPUT: {lib.Color.blue}{workdir.replace(basedir,"ROOT")}/job.output {lib.Color.end}'
f'\n{lib.Color.purple}OUTPUT:{lib.Color.end} {workdir.replace(basedir,"<ROOT>")}/job.output'
)

0 comments on commit f32211e

Please sign in to comment.