diff --git a/pysqa/__main__.py b/pysqa/__main__.py new file mode 100644 index 00000000..4c6cd70a --- /dev/null +++ b/pysqa/__main__.py @@ -0,0 +1,6 @@ +import sys +from pysqa.cmd import command_line + + +if __name__ == "__main__": + command_line(sys.argv[1:]) diff --git a/pysqa/ext/__init__.py b/pysqa/ext/__init__.py new file mode 100644 index 00000000..e69de29b diff --git a/pysqa/utils/modular.py b/pysqa/ext/modular.py similarity index 100% rename from pysqa/utils/modular.py rename to pysqa/ext/modular.py diff --git a/pysqa/utils/remote.py b/pysqa/ext/remote.py similarity index 100% rename from pysqa/utils/remote.py rename to pysqa/ext/remote.py diff --git a/pysqa/queueadapter.py b/pysqa/queueadapter.py index a1b92169..a43c3516 100644 --- a/pysqa/queueadapter.py +++ b/pysqa/queueadapter.py @@ -2,7 +2,10 @@ # Copyright (c) Jan Janssen import os -from pysqa.utils.functs import read_config, set_queue_adapter +from pysqa.utils.basic import BasisQueueAdapter +from pysqa.ext.modular import ModularQueueAdapter +from pysqa.ext.remote import RemoteQueueAdapter +from pysqa.utils.config import read_config __author__ = "Jan Janssen" __copyright__ = "Copyright 2019, Jan Janssen" @@ -288,3 +291,21 @@ def check_queue_parameters( memory_max=memory_max, active_queue=active_queue, ) + + +def set_queue_adapter(config, directory): + """ + Initialize the queue adapter + + Args: + config (dict): configuration for one cluster + directory (str): directory which contains the queue configurations + """ + if config["queue_type"] in ["SGE", "TORQUE", "SLURM", "LSF", "MOAB"]: + return BasisQueueAdapter(config=config, directory=directory) + elif config["queue_type"] in ["GENT"]: + return ModularQueueAdapter(config=config, directory=directory) + elif config["queue_type"] in ["REMOTE"]: + return RemoteQueueAdapter(config=config, directory=directory) + else: + raise ValueError diff --git a/pysqa/utils/config.py b/pysqa/utils/config.py new file mode 100644 index 00000000..a831ea72 --- /dev/null +++ b/pysqa/utils/config.py @@ -0,0 +1,14 @@ +import yaml + + +def read_config(file_name="queue.yaml"): + """ + + Args: + file_name (str): + + Returns: + dict: + """ + with open(file_name, "r") as f: + return yaml.load(f, Loader=yaml.FullLoader) diff --git a/pysqa/utils/functs.py b/pysqa/utils/functs.py deleted file mode 100644 index 75fb2e7d..00000000 --- a/pysqa/utils/functs.py +++ /dev/null @@ -1,35 +0,0 @@ -import yaml -from pysqa.utils.basic import BasisQueueAdapter -from pysqa.utils.remote import RemoteQueueAdapter -from pysqa.utils.modular import ModularQueueAdapter - - -def read_config(file_name="queue.yaml"): - """ - - Args: - file_name (str): - - Returns: - dict: - """ - with open(file_name, "r") as f: - return yaml.load(f, Loader=yaml.FullLoader) - - -def set_queue_adapter(config, directory): - """ - Initialize the queue adapter - - Args: - config (dict): configuration for one cluster - directory (str): directory which contains the queue configurations - """ - if config["queue_type"] in ["SGE", "TORQUE", "SLURM", "LSF", "MOAB"]: - return BasisQueueAdapter(config=config, directory=directory) - elif config["queue_type"] in ["GENT"]: - return ModularQueueAdapter(config=config, directory=directory) - elif config["queue_type"] in ["REMOTE"]: - return RemoteQueueAdapter(config=config, directory=directory) - else: - raise ValueError diff --git a/pysqa/wrapper/torque.py b/pysqa/wrapper/torque.py index 59e1b759..6fa259d4 100644 --- a/pysqa/wrapper/torque.py +++ b/pysqa/wrapper/torque.py @@ -2,9 +2,9 @@ # Copyright (c) Max-Planck-Institut für Eisenforschung GmbH - Computational Materials Design (CM) Department # Distributed under the terms of "New BSD License", see the LICENSE file. -from pysqa.wrapper.generic import SchedulerCommands import re import pandas as pd +from pysqa.wrapper.generic import SchedulerCommands __author__ = "Jan Janssen" __copyright__ = ( @@ -33,7 +33,8 @@ def get_queue_status_command(self): @staticmethod def get_job_id_from_output(queue_submit_output): - # strip last line from output, leading and trailing whitespaces, and separates the queue id from the stuff after "." + # strip last line from output, leading and trailing whitespaces, + # and separates the queue id from the stuff after "." # Adjust if your system doesn't have output like below! # e.g. qsub run_queue.sh -> "12347673.gadi-pbs", the below returns 12347673 # It must return an integer for it to not raise an exception later. @@ -44,7 +45,8 @@ def get_job_id_from_output(queue_submit_output): @staticmethod def convert_queue_status(queue_status_output): # # Run the qstat -f command and capture its output - # output = subprocess.check_output(["qstat", "-f"]) -> output is the queue_status_output that goes into this function + # output = subprocess.check_output(["qstat", "-f"]) -> output is the + # queue_status_output that goes into this function # Split the output into lines lines = queue_status_output.split("\n") # .decode().split("\n") diff --git a/setup.py b/setup.py index 07043d87..9ac73d82 100644 --- a/setup.py +++ b/setup.py @@ -36,4 +36,9 @@ 'pyyaml==6.0', 'tqdm==4.65.0'], cmdclass=versioneer.get_cmdclass(), + entry_points={ + "console_scripts": [ + 'pysqa=pysqa:main' + ] + } ) diff --git a/tests/LICENSE b/tests/LICENSE deleted file mode 100644 index d4fc75fe..00000000 --- a/tests/LICENSE +++ /dev/null @@ -1,29 +0,0 @@ -BSD 3-Clause License - -Copyright (c) 2019, Jan Janssen -All rights reserved. - -Redistribution and use in source and binary forms, with or without -modification, are permitted provided that the following conditions are met: - -* Redistributions of source code must retain the above copyright notice, this - list of conditions and the following disclaimer. - -* Redistributions in binary form must reproduce the above copyright notice, - this list of conditions and the following disclaimer in the documentation - and/or other materials provided with the distribution. - -* Neither the name of the copyright holder nor the names of its - contributors may be used to endorse or promote products derived from - this software without specific prior written permission. - -THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" -AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE -IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE -FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL -DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR -SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER -CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, -OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.