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). |
|
Check a string is (roughly) a valid Python variable identifier and return it. |
|
Get a UTC timestamp for the current time |
|
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. |
|
Find a file or directory in a package. |
|
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. |
|
Generate a random ID for a workflow. |
|
Force a timestamp to have UTC as its timezone, then convert to use the local timezone. |
|
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. |
|
Open a file in a package. |
|
Standard timestamp parsing. |
|
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. |
|
Apply a mapping to a structure of lists with ints (typically indices) as leaves to get a structure of lists with some objects as leaves. |
|
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. |
|
Convert time delta to string in standard form. |
|
Parse a string in standard form as a time delta. |
|
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 |