hpcflow.sdk.core.utils#

Functions

bisect_slice

Given two sequences (the first of which of known length), get the two slices that are equivalent to a given slice if the two sequences were combined.

capitalise_first_letter

check_in_object_list

Decorator factory for the various from_spec class methods that have attributes that should be replaced by an object from an object list.

check_valid_py_identifier

Check a string is (roughly) a valid Python variable identifier and return it.

ensure_in

Get the index of an item in a list and append the item if it is not in the list.

flatten

Flatten an arbitrarily (but of uniform depth) nested list and return shape information to enable un-flattening.

get_duplicate_items

Get a list of all items in an iterable that appear more than once, assuming items are hashable.

get_enum_by_name_or_val

Retrieve an enum by name or value, assuming uppercase names and integer values.

get_in_container

get_item_repeat_index

Get the repeat index for each item in a list.

get_md5_hash

get_nested_indices

Generate the set of nested indices of length n that correspond to a global idx.

get_process_stamp

get_relative_path

Get relative path components between two paths.

get_time_stamp

group_by_dict_key_values

Group a list of dicts according to specified equivalent key-values.

is_fsspec_url

linspace_rect

Generate a linear space around a rectangle.

list_to_dict

load_config

API function decorator to ensure the configuration has been loaded, and load if not.

make_workflow_id

open_file

Open a file or directory using the default system application.

process_string_nodes

Walk through a nested data structure and process string nodes using a provided callable.

read_JSON_file

read_JSON_string

read_YAML

read_YAML_file

remove_ansi_escape_sequences

replace_items

Replaced a range of items in a list with items in another list.

reshape

search_dir_files_by_regex

Search recursively for files in a directory by a regex pattern and return matching file paths, relative to the given directory.

sentry_wrap

set_in_container

split_param_label

Split a parameter path into the path and the label, if present.

swap_nested_dict_keys

Return a copy where top-level keys have been swapped with a second-level inner key.

write_JSON_file

write_YAML_file

Classes

JSONLikeDirSnapShot

Overridden DirectorySnapshot from watchdog to allow saving and loading from JSON.

PrettyPrinter

Singleton

classproperty