Skip to content

Commit

Permalink
Format black
Browse files Browse the repository at this point in the history
  • Loading branch information
pyiron-runner committed Mar 18, 2024
1 parent 1f94020 commit 4c8ed45
Show file tree
Hide file tree
Showing 8 changed files with 69 additions and 17 deletions.
4 changes: 3 additions & 1 deletion pysqa/cmd.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,9 @@
from pysqa.utils.execute import execute_command


def command_line(arguments_lst: list=None, execute_command: callable = execute_command):
def command_line(
arguments_lst: list = None, execute_command: callable = execute_command
):
"""
Parse the command line arguments.
Expand Down
6 changes: 4 additions & 2 deletions pysqa/executor/backend.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,9 @@
)


def execute_files_from_list(tasks_in_progress_dict: dict, cache_directory: str, executor):
def execute_files_from_list(
tasks_in_progress_dict: dict, cache_directory: str, executor
):
file_lst = os.listdir(cache_directory)
for file_name_in in file_lst:
key = file_name_in.split(".in.pl")[0]
Expand Down Expand Up @@ -58,7 +60,7 @@ def execute_tasks(cores: int, cache_directory: str):
)


def command_line(arguments_lst: list=None):
def command_line(arguments_lst: list = None):
if arguments_lst is None:
arguments_lst = sys.argv[1:]
cores_arg = arguments_lst[arguments_lst.index("--cores") + 1]
Expand Down
4 changes: 3 additions & 1 deletion pysqa/executor/executor.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,9 @@


class Executor(FutureExecutor):
def __init__(self, cwd: str=None, queue_adapter=None, queue_adapter_kwargs: dict=None):
def __init__(
self, cwd: str = None, queue_adapter=None, queue_adapter_kwargs: dict = None
):
self._task_queue = queue.Queue()
self._memory_dict = {}
self._cache_directory = os.path.abspath(os.path.expanduser(cwd))
Expand Down
4 changes: 3 additions & 1 deletion pysqa/executor/helper.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,9 @@ def read_from_file(file_name: str) -> dict:
return {name: f.read()}


def reload_previous_futures(future_queue: queue.Queue, future_dict: dict, cache_directory: str):
def reload_previous_futures(
future_queue: queue.Queue, future_dict: dict, cache_directory: str
):
file_lst = os.listdir(cache_directory)
for f in file_lst:
if f.endswith(".in.pl"):
Expand Down
7 changes: 6 additions & 1 deletion pysqa/ext/modular.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,12 @@


class ModularQueueAdapter(BasisQueueAdapter):
def __init__(self, config: dict, directory: str = "~/.queues", execute_command: callable = execute_command):
def __init__(
self,
config: dict,
directory: str = "~/.queues",
execute_command: callable = execute_command,
):
super(ModularQueueAdapter, self).__init__(
config=config, directory=directory, execute_command=execute_command
)
Expand Down
14 changes: 12 additions & 2 deletions pysqa/ext/remote.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,12 @@


class RemoteQueueAdapter(BasisQueueAdapter):
def __init__(self, config: dict, directory: str = "~/.queues", execute_command: callable = execute_command):
def __init__(
self,
config: dict,
directory: str = "~/.queues",
execute_command: callable = execute_command,
):
super(RemoteQueueAdapter, self).__init__(
config=config, directory=directory, execute_command=execute_command
)
Expand Down Expand Up @@ -191,7 +196,12 @@ def get_job_from_remote(self, working_directory: str):
if self._ssh_delete_file_on_remote:
self._execute_remote_command(command="rm -r " + remote_working_directory)

def transfer_file(self, file: str, transfer_back: bool = False, delete_file_on_remote: bool = False):
def transfer_file(
self,
file: str,
transfer_back: bool = False,
delete_file_on_remote: bool = False,
):
working_directory = os.path.abspath(os.path.expanduser(file))
remote_working_directory = self._get_remote_working_dir(
working_directory=working_directory
Expand Down
22 changes: 17 additions & 5 deletions pysqa/queueadapter.py
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,9 @@ class QueueAdapter(object):
Queues available for auto completion QueueAdapter().queues.<queue name> returns the queue name.
"""

def __init__(self, directory: str = "~/.queues", execute_command: callable = execute_command):
def __init__(
self, directory: str = "~/.queues", execute_command: callable = execute_command
):
queue_yaml = os.path.join(directory, "queue.yaml")
clusters_yaml = os.path.join(directory, "clusters.yaml")
self._adapter = None
Expand Down Expand Up @@ -202,7 +204,10 @@ def get_job_from_remote(self, working_directory: str):
self._adapter.get_job_from_remote(working_directory=working_directory)

def transfer_file_to_remote(
self, file: str, transfer_back: bool = False, delete_file_on_remote: bool = False
self,
file: str,
transfer_back: bool = False,
delete_file_on_remote: bool = False,
):
"""
Transfer file from remote host to local host
Expand Down Expand Up @@ -240,7 +245,7 @@ def delete_job(self, process_id: int) -> str:
"""
return self._adapter.delete_job(process_id=process_id)

def get_queue_status(self, user: str=None) -> pandas.DataFrame:
def get_queue_status(self, user: str = None) -> pandas.DataFrame:
"""
Args:
Expand Down Expand Up @@ -282,7 +287,12 @@ def get_status_of_jobs(self, process_id_lst: list[int]) -> list[str]:
return self._adapter.get_status_of_jobs(process_id_lst=process_id_lst)

def check_queue_parameters(
self, queue: str, cores: int = 1, run_time_max: int = None, memory_max: int = None, active_queue: dict = None
self,
queue: str,
cores: int = 1,
run_time_max: int = None,
memory_max: int = None,
active_queue: dict = None,
):
"""
Expand All @@ -305,7 +315,9 @@ def check_queue_parameters(
)


def set_queue_adapter(config: dict, directory: str, execute_command: callable=execute_command):
def set_queue_adapter(
config: dict, directory: str, execute_command: callable = execute_command
):
"""
Initialize the queue adapter
Expand Down
25 changes: 21 additions & 4 deletions pysqa/utils/basic.py
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,12 @@ class BasisQueueAdapter(object):
Queues available for auto completion QueueAdapter().queues.<queue name> returns the queue name.
"""

def __init__(self, config: dict, directory: str = "~/.queues", execute_command: callable = execute_command):
def __init__(
self,
config: dict,
directory: str = "~/.queues",
execute_command: callable = execute_command,
):
self._config = config
self._fill_queue_dict(queue_lst_dict=self._config["queues"])
self._load_templates(queue_lst_dict=self._config["queues"], directory=directory)
Expand Down Expand Up @@ -182,7 +187,9 @@ def submit_job(
else:
return None

def _list_command_to_be_executed(self, dependency_list: list[str], queue_script_path: str) -> list:
def _list_command_to_be_executed(
self, dependency_list: list[str], queue_script_path: str
) -> list:
return (
self._commands.submit_job_command
+ self._commands.dependencies(dependency_list)
Expand Down Expand Up @@ -295,11 +302,21 @@ def get_job_from_remote(self, working_directory: str):
def convert_path_to_remote(self, path: str):
raise NotImplementedError

def transfer_file(self, file: str, transfer_back: bool = False, delete_file_on_remote: bool = False):
def transfer_file(
self,
file: str,
transfer_back: bool = False,
delete_file_on_remote: bool = False,
):
raise NotImplementedError

def check_queue_parameters(
self, queue: str, cores: int = 1, run_time_max: int = None, memory_max: int = None, active_queue: dict = None
self,
queue: str,
cores: int = 1,
run_time_max: int = None,
memory_max: int = None,
active_queue: dict = None,
) -> list:
"""
Expand Down

0 comments on commit 4c8ed45

Please sign in to comment.