diff --git a/alice-ci/setup.cfg b/alice-ci/setup.cfg index 39eeec0d5494794c814887c509a74a8a61cde1db..58768c074c696c6467e3d1ba7b07b9d149c0e90c 100644 --- a/alice-ci/setup.cfg +++ b/alice-ci/setup.cfg @@ -1,6 +1,6 @@ [metadata] name = alice-ci -version = 0.0.2 +version = 0.0.3 author = Daniel Gyulai description = Alice CI framework long_description = file: README.md diff --git a/alice-ci/src/alice/__init__.py b/alice-ci/src/alice/__init__.py index 39328d3d4114a4d6044006dc7c68071c92eda864..1181dd0717d2ca5ffb70d21f112afb5c335494c2 100644 --- a/alice-ci/src/alice/__init__.py +++ b/alice-ci/src/alice/__init__.py @@ -1,5 +1,11 @@ # flake8: noqa F401 -from .cli import App -from .jobparser import Job, JobParser -from .exceptions import NonZeroRetcode -from .pythonrunner import PythonRunner \ No newline at end of file +from alice.utils import ConfigParser +from alice.exceptions import NonZeroRetcode +from alice.runnerfactory import Factory +from alice.runners.pythonrunner import PythonRunner +from alice.exceptions import NonZeroRetcode +from alice.exceptions import RunnerError +from alice.exceptions import ConfigException +from alice.__main__ import main + +name = "alice" \ No newline at end of file diff --git a/alice-ci/src/alice/__main__.py b/alice-ci/src/alice/__main__.py index d92dc907a810043197423691cdf4bd8381a91d36..41aa9b87a0672b7ced7b984930e3b3ea1d3ffbd7 100644 --- a/alice-ci/src/alice/__main__.py +++ b/alice-ci/src/alice/__main__.py @@ -1,3 +1,3 @@ -from cli import main +from alice.cli import main main() diff --git a/alice-ci/src/alice/cli.py b/alice-ci/src/alice/cli.py index ed9cf3f57d858e5c9a3c78e222f0123fcba7b146..24308b4773d383776803d54c69a9d37f091142ee 100644 --- a/alice-ci/src/alice/cli.py +++ b/alice-ci/src/alice/cli.py @@ -1,9 +1,9 @@ import os import argparse -from utils import ConfigParser -from runnerfactory import Factory -from exceptions import ConfigException, NonZeroRetcode, RunnerError +from alice.utils import ConfigParser +from alice.runnerfactory import Factory +from alice.exceptions import ConfigException, NonZeroRetcode, RunnerError def gen_env(self, param_list): diff --git a/alice-ci/src/alice/runnerfactory.py b/alice-ci/src/alice/runnerfactory.py index 834139e2e85c45548244a409d6d8de5c3e0089df..a9290e27d87105e71872e66670aabc458b01e0dd 100644 --- a/alice-ci/src/alice/runnerfactory.py +++ b/alice-ci/src/alice/runnerfactory.py @@ -1,6 +1,8 @@ -from runners.pythonrunner import PythonRunner from os import getcwd +from alice.runners.pythonrunner import PythonRunner +from alice.exceptions import ConfigException + class Factory(): def __init__(self) -> None: @@ -30,5 +32,8 @@ class Factory(): def get_runner(self, runnertype): if runnertype not in self.runners: - self.runners[runnertype] = self.runnertypes[runnertype](self.workdir, self.globals) + if runnertype in self.runnertypes: + self.runners[runnertype] = self.runnertypes[runnertype](self.workdir, self.globals) + else: + raise ConfigException(f"Invalid runner type: {runnertype}") return self.runners[runnertype] diff --git a/alice-ci/src/alice/runners/__init__.py b/alice-ci/src/alice/runners/__init__.py new file mode 100644 index 0000000000000000000000000000000000000000..e6df5eae891e89e2710577b8549ba3a384c4b0c7 --- /dev/null +++ b/alice-ci/src/alice/runners/__init__.py @@ -0,0 +1,3 @@ +from alice.runners.pythonrunner import PythonRunner + +__all__ = ["PythonRunner"] diff --git a/alice-ci/src/alice/runners/pythonrunner.py b/alice-ci/src/alice/runners/pythonrunner.py index 498298aa635ef99ddd248e3c8a54c445bc1d15b3..776094b0799585660f6ab086424b029555bd2e9a 100644 --- a/alice-ci/src/alice/runners/pythonrunner.py +++ b/alice-ci/src/alice/runners/pythonrunner.py @@ -3,7 +3,7 @@ import os import sys import shlex -from exceptions import NonZeroRetcode, RunnerError, ConfigException +from alice.exceptions import NonZeroRetcode, RunnerError, ConfigException # same venv across all runs! diff --git a/alice-ci/src/alice/utils.py b/alice-ci/src/alice/utils.py index b99dc057ff8c544e9f2dcaa4f702c1904246a8da..b9cd3510fcf12516c7376d933df84d8cb863c3b0 100644 --- a/alice-ci/src/alice/utils.py +++ b/alice-ci/src/alice/utils.py @@ -1,41 +1,6 @@ import yaml -from runners.pythonrunner import PythonRunner -from exceptions import NonZeroRetcode, ConfigException - -class DummyRunner(): - def __init__(self, type) -> None: - self.type = type - - def run(self, command, workdir=None, env=None): - raise Exception(f"Invalid runner type in config: {self.type}") - - -class Job(): - def __init__(self, type, repoDir, vpython, workspace, env={}) -> None: - self.runner = self.__get_runner(type, repoDir, vpython) - self.commands = [] - self.workspace = workspace - self.env = env - - def __get_runner(self, type, repoDir, vpython): - if type == "python": - return PythonRunner(repoDir, vpython) - else: - return DummyRunner(type) - - def run_commands(self, _env={}): - try: - if self.env is None: - env = _env.copy() - else: - env = self.env.copy() - env.update(_env) - for command in self.commands: - self.runner.run(command, self.workspace, env) - except NonZeroRetcode as n: - print(n) - exit(1) +from alice.exceptions import ConfigException class ConfigParser: