From cad6c6075681bde3aef11fb3f7a63ef503bdc87c Mon Sep 17 00:00:00 2001 From: Leonardo Schwarz Date: Tue, 7 May 2024 15:36:30 +0200 Subject: [PATCH] clean --- bfabric/scripts/bfabric_upload_resource.py | 2 +- .../bfabric_upload_submitter_executable.py | 37 +++++++------------ 2 files changed, 14 insertions(+), 25 deletions(-) diff --git a/bfabric/scripts/bfabric_upload_resource.py b/bfabric/scripts/bfabric_upload_resource.py index b74d9bca..be65650a 100755 --- a/bfabric/scripts/bfabric_upload_resource.py +++ b/bfabric/scripts/bfabric_upload_resource.py @@ -14,7 +14,7 @@ import json from pathlib import Path -from bfabric.bfabric2 import Bfabric, get_system_auth +from bfabric.bfabric2 import Bfabric def bfabric_upload_resource(filename: Path, workunit_id: int) -> None: diff --git a/bfabric/scripts/bfabric_upload_submitter_executable.py b/bfabric/scripts/bfabric_upload_submitter_executable.py index 238be7ec..8aa6ecad 100755 --- a/bfabric/scripts/bfabric_upload_submitter_executable.py +++ b/bfabric/scripts/bfabric_upload_submitter_executable.py @@ -1,6 +1,4 @@ #!/usr/bin/env python3 -# -*- coding: latin1 -*- - """ Uploader for B-Fabric """ @@ -53,29 +51,13 @@ from bfabric.bfabric2 import Bfabric -def setup(): - argparser = argparse.ArgumentParser( - description="Arguments for new submitter executable.\nFor more details run: ./bfabric_upload_submitter_executable.py --help" - ) - argparser.add_argument("filename", type=str, help="Bash executable of the submitter") - argparser.add_argument( - "engine", - type=str, - choices=["slurm", "gridengine"], - help="Valid engines for job handling are: slurm, gridengine", - ) - argparser.add_argument("--name", type=str, help="Name of the submitter", required=False) - argparser.add_argument("--description", type=str, help="Description about the submitter", required=False) - return argparser.parse_args() - - def main_upload_submitter_executable(options) -> None: executableFileName = options.filename engine = options.engine client = Bfabric.from_config(verbose=True) - with open(executableFileName, "r") as f: + with open(executableFileName) as f: executable = f.read() attr = { @@ -134,19 +116,26 @@ def main_upload_submitter_executable(options) -> None: if options.name: attr["name"] = options.name - else: - pass if options.description: attr["description"] = options.description - else: - pass res = client.save("executable", attr) print(yaml.dump(res)) def main() -> None: - options = setup() + """Parses command line arguments and calls `main_upload_submitter_executable`.""" + parser = argparse.ArgumentParser() + parser.add_argument("filename", type=str, help="Bash executable of the submitter") + parser.add_argument( + "engine", + type=str, + choices=["slurm", "gridengine"], + help="Valid engines for job handling are: slurm, gridengine", + ) + parser.add_argument("--name", type=str, help="Name of the submitter", required=False) + parser.add_argument("--description", type=str, help="Description about the submitter", required=False) + options = parser.parse_args() main(options)