Utils

Identifiers

The functions within this module are used to select which files belong to a particular group based upon their filepath

gwcloud_python.utils.identifiers.config_file(file_path)

Checks to see if the given file path points towards the config file

Parameters:

file_path (Path) – File path to check

Returns:

True if path points to config file, False otherwise

Return type:

bool

gwcloud_python.utils.identifiers.corner_plot_file(file_path)

Checks to see if the given file path points towards a corner plot file

Parameters:

file_path (Path) – File path to check

Returns:

True if path points to corner plot file, False otherwise

Return type:

bool

gwcloud_python.utils.identifiers.data_dir(file_path)

Checks to see if the given file path starts with ‘data’ directory

Parameters:

file_path (Path) – File path to check

Returns:

True if path starts with ‘data’ directory, False otherwise

Return type:

bool

gwcloud_python.utils.identifiers.data_png_file(file_path)

Checks to see if the given file path points to a PNG file in the ‘data’ directory

Parameters:

file_path (Path) – File path to check

Returns:

True if path points to PNG file in ‘data’ directory, False otherwise

Return type:

bool

gwcloud_python.utils.identifiers.html_file(file_path)

Checks to see if the given file path points to a HTML file

Parameters:

file_path (Path) – File path to check

Returns:

True if path points to a HTML file, False otherwise

Return type:

bool

gwcloud_python.utils.identifiers.merged_json_file(file_path)

Checks to see if the given file path points towards a merged JSON file

Parameters:

file_path (Path) – File path to check

Returns:

True if path points to merged JSON file, False otherwise

Return type:

bool

gwcloud_python.utils.identifiers.png_file(file_path)

Checks to see if the given file path ends points to a PNG file

Parameters:

file_path (Path) – File path to check

Returns:

True if path points to a PNG file, False otherwise

Return type:

bool

gwcloud_python.utils.identifiers.result_dir(file_path)

Checks to see if the given file path starts with ‘result’ directory

Parameters:

file_path (Path) – File path to check

Returns:

True if path starts with ‘result’ directory, False otherwise

Return type:

bool

gwcloud_python.utils.identifiers.result_json_file(file_path)

Checks to see if the given file path points to a result JSON file in the ‘result’ directory.

Parameters:

file_path (Path) – File path to check

Returns:

True if path points to the desired JSON file in ‘result’ directory, False otherwise

Return type:

bool

gwcloud_python.utils.identifiers.result_merged_json_file(file_path)

Checks to see if the given file path points to a merged JSON file in the ‘result’ directory.

Parameters:

file_path (Path) – File path to check

Returns:

True if path points to the desired JSON file in ‘result’ directory, False otherwise

Return type:

bool

gwcloud_python.utils.identifiers.result_png_file(file_path)

Checks to see if the given file path points to a PNG file in the ‘result’ directory

Parameters:

file_path (Path) – File path to check

Returns:

True if path points to PNG file in ‘result’ directory, False otherwise

Return type:

bool

gwcloud_python.utils.identifiers.unmerged_json_file(file_path)

Checks to see if the given file path points towards the JSON file if not run in parallel

Parameters:

file_path (Path) – File path to check

Returns:

True if path points to JSON file, False otherwise

Return type:

bool

File list functions

The functions within this module are return lists of files based some identifiers

gwcloud_python.utils.file_filters.config_filter(file_list)

Takes an input file list and returns a subset of that file list containing:

  • Any file ending with ‘_config_complete.ini’

Parameters:

file_list (.FileReferenceList) – A list of FileReference objects which will be filtered

Returns:

Subset of the input FileReferenceList containing only the paths that match the above config file criteria

Return type:

.FileReferenceList

gwcloud_python.utils.file_filters.corner_plot_filter(file_list)

Takes an input file list and returns a subset of that file list containing:

  • Any file ending in ‘_corner.png’

Parameters:

file_list (.FileReferenceList) – A list of FileReference objects which will be filtered

Returns:

Subset of the input FileReferenceList containing only the paths that match the above corner plot file criteria

Return type:

.FileReferenceList

gwcloud_python.utils.file_filters.default_filter(file_list)

Takes an input file list and returns a subset of that file list containing:

  • Any HTML file

  • Any file ending with ‘_config_complete.ini’

  • Any PNG files in the ‘data’ directory

  • Any PNG files in the ‘result’ directory

  • Any file in the ‘result’ directory ending in ‘_merge_result.json’, or ‘_result.json’ if there is no merged file

Parameters:

file_list (.FileReferenceList) – A list of FileReference objects which will be filtered

Returns:

Subset of the input FileReferenceList containing only the paths that match the above default file criteria

Return type:

.FileReferenceList

gwcloud_python.utils.file_filters.png_filter(file_list)

Takes an input file list and returns a subset of that file list containing:

  • Any PNG file

Parameters:

file_list (.FileReferenceList) – A list of FileReference objects which will be filtered

Returns:

Subset of the input FileReferenceList containing only the paths that match the above png file criteria

Return type:

.FileReferenceList

gwcloud_python.utils.file_filters.result_json_filter(file_list)

Takes an input file list and returns a subset of that file list containing:

  • Any file in the ‘result’ directory ending in ‘_merge_result.json’

  • Or, any file in the ‘result’ directory ending in ‘_result.json’

Parameters:

file_list (.FileReferenceList) – A list of FileReference objects which will be filtered

Returns:

Subset of the input FileReferenceList containing only the paths that match the merged json file criteria

Return type:

.FileReferenceList

gwcloud_python.utils.file_filters.sort_file_list(file_list)

Sorts a file list based on the ‘path’ key of the dicts. Primarily used for equality checks.

Parameters:

file_list (.FileReferenceList) – A list of FileReference objects which will be filtered

Returns:

A FileReferenceList containing the same members as the input, sorted by the path attribute of the FileReference objects

Return type:

.FileReferenceList