Skip to content

Commit

Permalink
Refactor: Format using black
Browse files Browse the repository at this point in the history
  • Loading branch information
dileep-kishore committed Jan 11, 2022
1 parent 376d617 commit 9275186
Show file tree
Hide file tree
Showing 7 changed files with 318 additions and 318 deletions.
32 changes: 16 additions & 16 deletions micone/config/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,19 +15,19 @@

class Config:
"""
Class to extract, process and store pipeline settings
Class to extract, process and store pipeline settings
Parameters
----------
config_folder : pathlib.Path
The path to the folder containing the configuration files
Parameters
----------
config_folder : pathlib.Path
The path to the folder containing the configuration files
Attributes
----------
datatypes : DataTypes
The set of supported datatypes
params_set : ParamsSet
The dictionary containing process configurations
Attributes
----------
datatypes : DataTypes
The set of supported datatypes
params_set : ParamsSet
The dictionary containing process configurations
"""

def __init__(self, config_folder: pathlib.Path = CONFIG_FOLDER) -> None:
Expand All @@ -54,12 +54,12 @@ def __init__(self, config_folder: pathlib.Path = CONFIG_FOLDER) -> None:

def _check_io_integrity(self, params_set: ParamsSet) -> None:
"""
Verify whether all the datatypes in the params_set are valid
Verify whether all the datatypes in the params_set are valid
Parameters
----------
params_set : ParamsSet
The params to be verified
Parameters
----------
params_set : ParamsSet
The params to be verified
"""
for param in params_set:
for curr_input in param.input:
Expand Down
40 changes: 20 additions & 20 deletions micone/config/datatypes.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,21 +8,21 @@

class DataType(collections.Hashable):
"""
The class that stores a datatype of the pipeline constructor
Parameters
----------
data : Dict[str, Any]
The information about a particular datatype
Attributes
----------
name : str
DataType name
desc : str
DataType description
format : Set[str]
DataType allowed formats
The class that stores a datatype of the pipeline constructor
Parameters
----------
data : Dict[str, Any]
The information about a particular datatype
Attributes
----------
name : str
DataType name
desc : str
DataType description
format : Set[str]
DataType allowed formats
"""

def __init__(self, data: Tuple[str, Dict[str, Union[str, List[str]]]]) -> None:
Expand Down Expand Up @@ -64,12 +64,12 @@ def __str__(self) -> str:

class DataTypes(collections.Set):
"""
The set of all datatypes supported by the pipeline constructor
The set of all datatypes supported by the pipeline constructor
Parameters
----------
data : Dict[str, Dict[str, Any]]
A dictionary containing information about the pipeline datatypes
Parameters
----------
data : Dict[str, Dict[str, Any]]
A dictionary containing information about the pipeline datatypes
"""

def __init__(self, data: Dict[str, Dict[str, Union[str, List[str]]]]) -> None:
Expand Down
18 changes: 9 additions & 9 deletions micone/conversion/network_converter.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,15 +11,15 @@

def json_to_elist(in_file: pathlib.Path, out_file: pathlib.Path) -> None:
"""
Convert Network file from json to elist format
Note that only the edge attributes can be converted
Parameters
----------
in_file : pathlib.Path
The path to the json formatted network file
out_file : pathlib.Path
The path to the elist formatted network file
Convert Network file from json to elist format
Note that only the edge attributes can be converted
Parameters
----------
in_file : pathlib.Path
The path to the json formatted network file
out_file : pathlib.Path
The path to the elist formatted network file
"""
network = Network.load_json(in_file)
df = pd.DataFrame.from_dict(network.links)
Expand Down
152 changes: 76 additions & 76 deletions micone/pipelines/command.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,41 +10,41 @@

class Command:
"""
Class that wraps functionality for running subprocesses and jobs on the cluster
Parameters
----------
cmd : str
The command to be executed
profile : {'local', 'sge'}
The execution environment
timeout : int, optional
The time limit for the command
If a process exceeds this time then it will be terminated
Default is 1000
Other Parameters
----------------
project : str, optional
The project under which to run the pipeline on the 'sge'
Default value is None
Attributes
----------
cmd : str
The command that will be executed.
This includes the profile and resource specifics
profile : {'local', 'sge'}
The execution environment
project : str
The project under which to run the pipeline on the 'sge'
output : str
The 'stdout' of the command
error : str
The 'stderr' of the command
status : str
The status the the command
One of {'success', 'failure', 'in progress', 'not started'}
Class that wraps functionality for running subprocesses and jobs on the cluster
Parameters
----------
cmd : str
The command to be executed
profile : {'local', 'sge'}
The execution environment
timeout : int, optional
The time limit for the command
If a process exceeds this time then it will be terminated
Default is 1000
Other Parameters
----------------
project : str, optional
The project under which to run the pipeline on the 'sge'
Default value is None
Attributes
----------
cmd : str
The command that will be executed.
This includes the profile and resource specifics
profile : {'local', 'sge'}
The execution environment
project : str
The project under which to run the pipeline on the 'sge'
output : str
The 'stdout' of the command
error : str
The 'stderr' of the command
status : str
The status the the command
One of {'success', 'failure', 'in progress', 'not started'}
"""

_stdout: Optional[str] = None
Expand All @@ -63,17 +63,17 @@ def __init__(self, cmd: str, profile: str, timeout: int = 1000, **kwargs) -> Non

def _build_cmd(self, cmd: str) -> List[str]:
"""
Builds the `cmd` for the current Command instance
Builds the `cmd` for the current Command instance
Parameters
----------
cmd : str
The command to be executed
Parameters
----------
cmd : str
The command to be executed
Returns
-------
str
The final command to be executed
Returns
-------
str
The final command to be executed
"""
command: List[str] = []
if self.profile == "local":
Expand All @@ -95,23 +95,23 @@ def __repr__(self) -> str:

@property
def cmd(self) -> str:
""" The command that will be executed """
"""The command that will be executed"""
return " ".join(self._cmd)

def run(self, cwd: Optional[str] = None) -> subprocess.Popen:
"""
Executes the command with the correct profile and resources
Parameters
----------
cwd : str, optional
The directory in which the command is to be run
Default is None which uses the current working directory
Returns
-------
int
The exit status of the command
Executes the command with the correct profile and resources
Parameters
----------
cwd : str, optional
The directory in which the command is to be run
Default is None which uses the current working directory
Returns
-------
int
The exit status of the command
"""
# QUESTION: Replace this with asyncio.subprocess.create_subprocess_shell
self.process = subprocess.Popen(
Expand All @@ -124,14 +124,14 @@ def run(self, cwd: Optional[str] = None) -> subprocess.Popen:
return self.process

def wait(self) -> None:
""" Wait for the process to complete or terminate """
"""Wait for the process to complete or terminate"""
if self.process:
stdout, stderr = self.process.communicate(timeout=self._timeout)
self._stderr = stderr.decode("utf-8")
self._stdout = stdout.decode("utf-8")

def log(self) -> None:
""" Logs the stdout and stderr of the command execution to the log_file """
"""Logs the stdout and stderr of the command execution to the log_file"""
LOG.logger.info(f"Running command: {self.cmd}")
LOG.logger.info("-" * 4 + " [STDOUT] " + "-" * 4)
LOG.logger.success(self.output)
Expand All @@ -140,12 +140,12 @@ def log(self) -> None:

def proc_cmd_sync(self) -> bool:
"""
Check whether the Command instance and subprocess.Popen process are in sync
Check whether the Command instance and subprocess.Popen process are in sync
Returns
-------
bool
True if both the `cmd` and `process` are the same
Returns
-------
bool
True if both the `cmd` and `process` are the same
"""
if self._cmd == self.process.args:
return True
Expand All @@ -154,7 +154,7 @@ def proc_cmd_sync(self) -> bool:

@property
def output(self) -> str:
""" Returns the output generated during execution of the command """
"""Returns the output generated during execution of the command"""
if self._stdout is not None:
stdout = self._stdout
else:
Expand All @@ -170,7 +170,7 @@ def output(self) -> str:

@property
def error(self) -> str:
""" Returns the error generated during execution of the command """
"""Returns the error generated during execution of the command"""
if self._stderr is not None:
stderr = self._stderr
else:
Expand All @@ -186,12 +186,12 @@ def error(self) -> str:

def update(self, cmd: str) -> None:
"""
Update the `cmd` of the current Command instance
Update the `cmd` of the current Command instance
Parameters
----------
cmd : str
The new command to be executed
Parameters
----------
cmd : str
The new command to be executed
"""
self._cmd = self._build_cmd(cmd)
if self.process:
Expand All @@ -206,12 +206,12 @@ def update(self, cmd: str) -> None:
@property
def status(self) -> str:
"""
Return the status of the command execution
Return the status of the command execution
Returns
-------
str
One of {'success', 'failure', 'in progress', 'not started'}
Returns
-------
str
One of {'success', 'failure', 'in progress', 'not started'}
"""
if self.process:
poll = self.process.poll()
Expand Down

0 comments on commit 9275186

Please sign in to comment.