shapepipe.pipeline.file_handler
shapepipe.pipeline.file_handler¶
FILE HANDLER.
This module defines a class for handling pipeline files.
- Author
Samuel Farrens <samuel.farrens@cea.fr>
- class FileHandler(run_name, modules, config, verbose=True)[source]¶
Bases:
object
File Handler.
This class manages the files used and produced during a pipeline run.
- Parameters
run_name (str) – Run name
module_list (list) – List of modules to be run
config (CustomParser) – Configuaration parser instance
verbose (bool, optional) – Verbose setting, default is True
- property run_dir¶
Run Directory.
This method defines the run directory.
- property _input_dir¶
Input Directory.
This method defines the input directories.
- property _output_dir¶
Output Directory.
This method defines the output directory.
- static read_number_list(file_name)[source]¶
Read Number List.
Extract number strings to be processed from a file.
- Parameters
file_name (str) – Number list file name
- classmethod check_dir(dir_name, check_exists=False)[source]¶
Check Directory.
Raise error if directory exists.
- classmethod check_dirs(dir_list)[source]¶
Check Directories.
Check directories in list
- Parameters
dir_list (list) – Directory list
- classmethod mkdir(dir_name)[source]¶
Make Directory.
This method creates a directory at the specified path.
- Parameters
dir_name (str`) – Directory name with full path
- static setpath(path, name, ext='')[source]¶
Set Path Name.
This method appends the file/directory name to the input path.
- classmethod strip_slash_list(path_list)[source]¶
Strip Slash List.
This method removes the trailing slash from a list of paths.
- static _get_module_run_name(dir)[source]¶
Get Module Run Name.
Retrieve module run name, module name and search string from input string.
- _check_input_dir_list(dir_list)[source]¶
Check Input Directory List.
Check an input list to see if the directories exist or if the the run log should be serarched for an appropriate output directory.
- Parameters
dir_list (list) – List of directories
- Raises
ValueError – For invalid input directory value
- create_global_run_dirs()[source]¶
Create Global Run Directories.
This method creates the pipeline output directories for a given run.
- get_module_current_run(module)[source]¶
Get Module Current Run.
Get the run current run count for the module.
- get_module_run_prop(module, property)[source]¶
Get Module Run Property.
Return the requested property for a given module run.
- Parameters
- Returns
Module run property value
- Return type
any
- Raises
ValueError – For invalid module dictionary key
- get_module_config_sec(module)[source]¶
Get Module Configuration Section.
Get the name of section name in the configuration file for the module.
- get_add_module_property(run_name, property)[source]¶
Get Additional Module Properties.
Get a list of additional module property values.
- _set_module_property(module, run_name, property, get_type)[source]¶
Set Module Property.
Set a module property from either the configuration file or the module runner.
- Parameters
Notes
Module properties are set with the following hierarchy:
Look for properties in module section of the config file,
look for default properties in the file handler, which sources the
[FILE]
section of the config file,look for default properties in the module runner definition.
In other words, module runner definitions will only be used if the properties are not set in the confg file. File handler properties will be used for all modules, overriding all module runner definitions. Module specific properties from the config file will override all other definitions, but only for the module in question.
- _set_module_properties(module, run_name)[source]¶
Get Module Properties.
Get module properties defined in module runner wrapper.
- Parameters
module (str) – Module name
- _create_module_run_dirs(module, run_name)[source]¶
Create Module Run Directories.
This method creates the module output directories for a given run.
- Parameters
module (str) – Module name
- _set_module_input_dir(module, run_name)[source]¶
Set Module Input Directory.
Set the module input directory. If the module specified is the first module in the pipeline or does not have any input modules then only the
INPUT_DIR
from[FILE]
is used, otherwise the output directory from the preceding module is used.Additional input directories can be specified with
INPUT_DIR
from[MODULE]
.
- static _generate_re_pattern(match_pattern)[source]¶
Generate Regular Expression Pattern.
Generate a regular expression pattern from an input string.
- static _strip_dir_from_file(file_name, dir_list)[source]¶
Strip Directory from File Name.
Remove the directory string from the file name.
- classmethod _get_re(num_scheme)[source]¶
Get Regular Expression.
Return the regular expression corresponding to the numbering scheme.
- Parameters
num_scheme (str) – Numbering scheme
- Raises
ValueError – if num_scheme is None
- Returns
Regular Expression
- Return type
- _save_num_patterns(dir_list, re_pattern, pattern, ext, output_file)[source]¶
Save Number Patterns.
Save file number patterns to numpy binary, update file patterns and get correct file paths.
- static _save_match_patterns(output_file, mmap_list)[source]¶
Save Match Patterns.
Save matching number patterns to numpy binary.
- static _get_file_name(path, pattern, number, ext)[source]¶
Get File Name.
Get file name corresponding to the path, file pattern, number pattern and file extension.
- _format_process_list(patterns, memory_map, re_pattern, num_scheme, run_method)[source]¶
Format Process List.
Format the list of files to be processed.
- _save_process_list(dir_list, pattern_list, ext_list, num_scheme, run_method)[source]¶
Save Process List.
Save list of processes to a numpy binary.
- _get_module_input_files(module, run_name)[source]¶
Get Module Input Files.
Retrieve the module input files names from the input directory.
- Parameters
module (str) – Module name