Commit 166f778f authored by David M. Rogers's avatar David M. Rogers
Browse files

Working command-line application (pmake).

parent 8be245a6
Loading
Loading
Loading
Loading
+2 −0
Original line number Diff line number Diff line
@@ -80,6 +80,8 @@ testing =
# And any other entry points, for example:
# pyscaffold.cli =
#     awesome = pyscaffoldext.awesome.extension:AwesomeExtension
console_scripts =
     pmake = pmake.make:run

[tool:pytest]
# Specify command line options as you would do when invoking pytest directly.
+2 −0
Original line number Diff line number Diff line
import logging, sys
from functools import wraps

import typer

@@ -17,6 +18,7 @@ def setup_logging(loglevel):
            )

def cmdline(main):
    @wraps(main)
    def run():
        setup_logging(logging.INFO)
        _logger.debug("Running program...")
+6 −5
Original line number Diff line number Diff line
@@ -21,17 +21,16 @@ from .manager import Manager

_logger = logging.getLogger(__name__)

@cmdline
def run(rules: Path = typer.Argument("rules.yaml", help="Make rules."),
        targets: Path = typer.Argument("targets.yaml", help="Make targets."),
def run1(rules: Path = typer.Argument(Path("rules.yaml"), help="Make rules."),
        targets: Path = typer.Argument(Path("targets.yaml"), help="Make targets."),
        minutes: float = typer.Argument(math.inf, help="Number of minutes available to run steps."),
        workdir : Optional[Path] = typer.Option(None, help="Store all jobscripts and job logs in this directory (instead of each target's dir).")
        workdir : Path = typer.Option(Path(), help="Store all jobscripts and job logs in this directory (instead of each target's dir)."),
        log : Optional[Path] = typer.Option(None, help="Output a debug-level logfile."),
        test : bool = typer.Option(False, help="List jobs, but do not create jobfiles or run anything.")
        ):
    if log is not None:
        logging.basicConfig(filename=str(log), level=logging.DEBUG)
    if work is not None:
    if workdir is not None:
        workdir.mkdir(exist_ok=True, parents=True)
        assert workdir.is_dir(), f"Unable to make directory {workdir}"

@@ -65,6 +64,8 @@ def run(rules: Path = typer.Argument("rules.yaml", help="Make rules."),

    R.run( G.get_work, test )

run = cmdline(run1)

if __name__=="__main__":
    import sys
    main(sys.argv)
+1 −1
Original line number Diff line number Diff line
import unittest
from fmatch import *
from pmake.fmatch import *

class TestFMatch(unittest.TestCase):
    def test_var(self):
+1 −1
Original line number Diff line number Diff line
import unittest
from machine import *
from pmake.machine import *

class TestMachine(unittest.TestCase):
    def test_alloc(self):
Loading