Table of Contents
Name | Direction | Type | Default | Description |
---|---|---|---|---|
PropertyManager | Input | string | name of a property manager from which properties are extracted from | |
Properties | Input | str list | A list of property names to be included | |
OtherProperties | Input | str list | A list of key=value strings for other properties not in the property manager | |
Prefix | Input | string | prefix to the output hash name | |
CacheDir | Input | string | the directory in which the cache file will be created | |
OutputFilename | Output | string | output filename | |
OutputSignature | Output | string | output signature |
The purpose of this algorithm is to create a unique filename for a cache so that a workflow can reuse results from previous computations.
The algorithm will accept a prefix, PropertyManager, list of properties to use from the property manager (empty is use all), and a string array (or List) of other properties to use, and a directory for cache files to exist in (default described below).
The list of property names will be used to select which of the properties in the PropertyManager will be used to calculate the hash and will be interpreted as globbing.
The string array of other_properties will be key/value pairs of properties that should be considered, but are not in the provided PropertyManager.
If a directory is not specified, cache files will go into a cache subdirectory of ConfigService::getUserPropertiesDir(). On unix this will be ~/.mantid/cache.
The algorithm will convert all properties to strings as “%s=%s” % (property.name, property.valueAsStr), sort the list, then convert it to a sha1.
A filename with the form <location>/<prefix>_<sha1>.nxs will be returned as the output property. If no prefix is specified then file result will be <location>/<sha1>.nxs.
Example:
import mantid
from mantid.kernel import PropertyManager
pm = PropertyManager()
aprops = ["a", "alibaba", "taa", "sa", "a75"]
props = aprops + ['b', 'c', 'd']
for p in props:
pm.declareProperty(p, '')
pm.setProperty(p, "fish")
continue
mantid.PropertyManagerDataService.add("excreatecachefilename", pm)
other_props = ["A=1", "B=2"]
# Execute
cache_path, signature = CreateCacheFilename(
PropertyManager = "excreatecachefilename",
Properties = ['*a*'],
OtherProperties = other_props,
)
Categories: Algorithms | Utility
Python: CreateCacheFilename.py