hpcflow.sdk.core.utils#
Miscellaneous utilities.
Functions
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. |
|
Convert the first character of a string to upper case (if that makes sense). |
|
Decorator factory for the various from_spec class methods that have attributes that should be replaced by an object from an object list. |
|
Check a string is (roughly) a valid Python variable identifier and return it. |
|
Return a copy of a dict, where the values are processed by a callable that is to be called only once, and where the values may be single items or lists of items. |
|
Get the index of an item in a list and append the item if it is not in the list. |
|
Flatten an arbitrarily (but of uniform depth) nested list and return shape information to enable un-flattening. |
|
Get a list of all items in an iterable that appear more than once, assuming items are hashable. |
|
Retrieve an enum by name or value, assuming uppercase names and integer values. |
|
Follow a path (sequence of indices of appropriate type) into a container to obtain a "leaf" value. |
|
Get the repeat index for each item in a list. |
|
Compute the MD5 hash of an object. |
|
Generate the set of nested indices of length n that correspond to a global idx. |
|
Return a globally unique string identifying this process. |
|
Get relative path components between two paths. |
|
Get the current time in standard string form. |
|
Group a list of dicts according to specified equivalent key-values. |
|
Test if a URL appears to be one that can be understood by fsspec. |
|
Generate a linear space around a rectangle. |
|
Convert a list of dicts to a dict of lists. |
|
API function decorator to ensure the configuration has been loaded, and load if not. |
|
Generate a random ID for a workflow. |
|
Given a dict in some order, get the n'th key of that dict. |
|
Given a dict in some order, get the n'th value of that dict. |
|
Open a file or directory using the default system application. |
|
Walk through a nested data structure and process string nodes using a provided callable. |
|
Load a JSON file. |
|
Load a JSON string. |
|
Load a YAML file. |
|
Load a YAML string. |
|
Strip ANSI terminal escape codes from a string. |
|
Replaced a range of items in a list with items in another list. |
|
Reverse the destructuring of the |
|
Search recursively for files in a directory by a regex pattern and return matching file paths, relative to the given directory. |
|
Follow a path (sequence of indices of appropriate type) into a container to update a "leaf" value. |
|
Split a parameter path into the path and the label, if present. |
|
Scan |
|
Return a copy where top-level keys have been swapped with a second-level inner key. |
|
Write a basic object to a JSON file. |
|
Write a basic object to a YAML file. |
Classes
Overridden DirectorySnapshot from watchdog to allow saving and loading from JSON. |
|
A class that produces a nice readable version of itself with |
|
Metaclass that enforces that only one instance can exist of the classes to which it is applied. |
|
Simple class property decorator. |