Skip to content

Commit

Permalink
Merge pull request #340 from pyiron/typehints
Browse files Browse the repository at this point in the history
Fix type hints
  • Loading branch information
jan-janssen authored Sep 28, 2024
2 parents 2ad0c18 + 23b42c8 commit a0470e1
Show file tree
Hide file tree
Showing 5 changed files with 17 additions and 10 deletions.
4 changes: 2 additions & 2 deletions pysqa/ext/modular.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
from typing import Optional
from typing import Optional, Union

import pandas

Expand Down Expand Up @@ -55,7 +55,7 @@ def submit_job(
dependency_list: Optional[list[str]] = None,
command: Optional[str] = None,
**kwargs,
) -> int:
) -> Union[int, None]:
"""
Submit a job to the queue.
Expand Down
6 changes: 0 additions & 6 deletions pysqa/utils/basic.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,12 +20,6 @@ class BasisQueueAdapter(CoreQueueAdapter):
config (dict): Configuration for the QueueAdapter.
directory (str): Directory containing the queue.yaml files as well as corresponding jinja2 templates for the individual queues.
execute_command(funct): Function to execute commands.
Attributes:
config (dict): QueueAdapter configuration read from the queue.yaml file.
queue_list (list): List of available queues.
queue_view (pandas.DataFrame): Pandas DataFrame representation of the available queues, read from queue.yaml.
queues: Queues available for auto completion QueueAdapter().queues.<queue name> returns the queue name.
"""

def __init__(
Expand Down
9 changes: 9 additions & 0 deletions pysqa/utils/core.py
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,15 @@ def get_queue_commands(queue_type: str) -> Union[SchedulerCommands, None]:


class CoreQueueAdapter(object):
"""
The goal of the QueueAdapter class is to make submitting to a queue system as easy as starting another sub process
locally.
Args:
queue_type (str): Type of the queuing system in capital letters
execute_command (funct): Function to execute commands.
"""

def __init__(
self,
queue_type: str,
Expand Down
4 changes: 3 additions & 1 deletion pysqa/utils/validate.py
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,9 @@ def _is_memory_string(value: str) -> bool:


def _memory_spec_string_to_value(
value: str, default_magnitude: str = "m", target_magnitude: str = "b"
value: Union[str, int, float],
default_magnitude: str = "m",
target_magnitude: str = "b",
) -> Union[int, float]:
"""
Converts a valid memory string (tested by _is_memory_string) into an integer/float value of desired
Expand Down
4 changes: 3 additions & 1 deletion pysqa/wrapper/gent.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
from typing import Union

import pandas

from pysqa.wrapper.slurm import SlurmCommands
Expand Down Expand Up @@ -36,7 +38,7 @@ def get_queue_from_output(queue_submit_output: str) -> str:
return str(queue_submit_output.splitlines()[-1].rstrip().lstrip().split(";")[1])

@staticmethod
def convert_queue_status(queue_status_output: str) -> pandas.DataFrame:
def convert_queue_status(queue_status_output: str) -> Union[pandas.DataFrame, None]:
"""
Converts the queue status output into a pandas DataFrame.
Expand Down

0 comments on commit a0470e1

Please sign in to comment.