Skip to content

Commit

Permalink
Merge pull request #397 from mishaschwartz/v2.2.1
Browse files Browse the repository at this point in the history
v2.2.1
  • Loading branch information
mishaschwartz authored Sep 6, 2022
2 parents 7ac38d2 + 44d5ac2 commit e6f319f
Show file tree
Hide file tree
Showing 4 changed files with 39 additions and 18 deletions.
4 changes: 4 additions & 0 deletions Changelog.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,10 @@
# CHANGELOG
All notable changes to this project will be documented here.

## [v2.2.1]
- Raise error if rq or supervisord executables can't be found when running start_stop.py (#390)
- Bump python-ta version to 2.3.2 (#391)

## [v2.2.0]
- Support dependencies on specific package versions and non-CRAN sources for R tester (#323)
- Testers no longer generate automated content for feedback files (#375)
Expand Down
4 changes: 2 additions & 2 deletions server/autotest_server/testers/pyta/pyta_tester.py
Original file line number Diff line number Diff line change
Expand Up @@ -49,9 +49,9 @@ def add_annotations(self, data: List[Dict]) -> None:
"filename": result["filename"],
"content": msg["msg"],
"line_start": msg["line"],
"line_end": msg["line_end"],
"line_end": msg["end_line"],
"column_start": msg["column"],
"column_end": msg["column_end"],
"column_end": msg["end_column"],
}
)

Expand Down
2 changes: 1 addition & 1 deletion server/autotest_server/testers/pyta/requirements.txt
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
python-ta==1.4.2;python_version<"3.8"
python-ta==2.1.0; python_version>="3.8"
python-ta==2.3.2; python_version>="3.8"
isort<5;python_version<"3.8"
47 changes: 32 additions & 15 deletions server/start_stop.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,8 @@
_THIS_DIR = os.path.dirname(os.path.realpath(__file__))
_PID_FILE = os.path.join(_THIS_DIR, "supervisord.pid")
_CONF_FILE = os.path.join(_THIS_DIR, "supervisord.conf")
_SUPERVISORD = os.path.join(os.path.dirname(sys.executable), "supervisord")
_RQ = os.path.join(os.path.dirname(sys.executable), "rq")
_SUPERVISORD = shutil.which(os.path.join(os.path.dirname(sys.executable), "supervisord")) or shutil.which("supervisord")
_RQ = shutil.which(os.path.join(os.path.dirname(sys.executable), "rq")) or shutil.which("rq")

SECONDS_PER_DAY = 86400

Expand Down Expand Up @@ -48,13 +48,13 @@ def redis_connection() -> redis.Redis:
return redis.Redis.from_url(config["redis_url"], decode_responses=True)


def create_enqueuer_wrapper():
def create_enqueuer_wrapper(rq):
with open(_CONF_FILE, "w") as f:
f.write(HEADER)
for worker_data in config["workers"]:
c = CONTENT.format(
worker_user=worker_data["user"],
rq=_RQ,
rq=rq,
worker_args=f'--url {config["redis_url"]}',
queues=" ".join(worker_data["queues"]),
numprocs=1,
Expand All @@ -63,9 +63,9 @@ def create_enqueuer_wrapper():
f.write(c)


def start(extra_args):
create_enqueuer_wrapper()
subprocess.run([_SUPERVISORD, "-c", _CONF_FILE, *extra_args], check=True, cwd=_THIS_DIR)
def start(rq, supervisord, extra_args):
create_enqueuer_wrapper(rq)
subprocess.run([supervisord, "-c", _CONF_FILE, *extra_args], check=True, cwd=_THIS_DIR)


def stop():
Expand All @@ -77,8 +77,8 @@ def stop():
sys.stderr.write("supervisor is already stopped")


def stat(extra_args):
subprocess.run([_RQ, "info", "--url", config["redis_url"], *extra_args], check=True)
def stat(rq, extra_args):
subprocess.run([rq, "info", "--url", config["redis_url"], *extra_args], check=True)


def clean(age, dry_run):
Expand All @@ -98,14 +98,21 @@ def clean(age, dry_run):
shutil.rmtree(dir_path)


def _exec_type(path):
exec_path = shutil.which(path)
if exec_path:
return exec_path
raise argparse.ArgumentTypeError(f"no executable found at: '{path}'")


if __name__ == "__main__":
parser = argparse.ArgumentParser()
subparsers = parser.add_subparsers(dest="command")

subparsers.add_parser("start", help="start the autotester")
start_parser = subparsers.add_parser("start", help="start the autotester")
subparsers.add_parser("stop", help="stop the autotester")
subparsers.add_parser("restart", help="restart the autotester")
subparsers.add_parser("stat", help="display current status of the autotester queues")
restart_parser = subparsers.add_parser("restart", help="restart the autotester")
stat_parser = subparsers.add_parser("stat", help="display current status of the autotester queues")
clean_parser = subparsers.add_parser("clean", help="clean up old/unused test scripts")

clean_parser.add_argument(
Expand All @@ -115,15 +122,25 @@ def clean(age, dry_run):
"-d", "--dry-run", action="store_true", help="list files that will be deleted without actually removing them"
)

for parser_ in (start_parser, restart_parser, stat_parser):
parser_.add_argument("--rq", default=_RQ, type=_exec_type, help=f"path to rq executable, default={_RQ}")
if parser_ is not stat_parser:
parser_.add_argument(
"--supervisord",
default=_SUPERVISORD,
type=_exec_type,
help=f"path to supervisord executable, default={_SUPERVISORD}",
)

args, remainder = parser.parse_known_args()
if args.command == "start":
start(remainder)
start(args.rq, args.supervisord, remainder)
elif args.command == "stop":
stop()
elif args.command == "restart":
stop()
start(remainder)
start(args.rq, args.supervisord, remainder)
elif args.command == "stat":
stat(remainder)
stat(args.rq, remainder)
elif args.command == "clean":
clean(args.age, args.dry_run)

0 comments on commit e6f319f

Please sign in to comment.