Lancet consists of three fundamental class types: Argument Specifiers, Command Templates and Launchers. The review_and_launch decorator is a helper utility that helps coordinate the use of these objects.
Argument specifiers are intended to offer a succinct, declarative and composable way of specifying large parameter sets. High-dimensional parameter sets are typical of large-scale scientific models and can make specifying such models and simulations difficult. Using argument specifiers, you can document how the parameters of your model vary across runs without extended lists of arguments or requiring deeply nested loops.
Argument specifiers can be freely intermixed with Python code, simplifying the use of scientific software with a Python interface. They also invoke commandline programs using CommandTemplate objects to build commands and Launcher objects to execute them. Argument specifiers can compose together using Cartesian Products or Concatenation to express huge numbers of argument sets concisely. In this way they can help simplify the management of simulation, analysis and visualisation tools with Python.
When working with external tools, a command template is needed to turn an argument specifier into an executable command. These objects are designed to be customisable with sensible defaults to reduce boilerplate. They may require argument specifiers with a certain structure (certain argument names and value types) to operate correctly.
A Launcher is designed to execute commands on a given computational platform, making use of as much concurrency where possible. The default Launcher class executes commands locally while the QLauncher class is designed to launch commands on Sun Grid Engine clusters.
This decorator helps codify a pattern of Lancet use that checks for consistency and offers an in-depth review of all settings before launch. The goal is to help users identify mistakes early before consuming computational time and resources.
IPython pretty printing support (optional). To load the extension you may execute the following in IPython:
%load_ext lancet
Bases: param.parameterized.ParameterizedFunction
params(commands=Dict, paths=List, name=String)
Simple utility to capture basic version control information for Git, SVN and Mercurial. Returns a dictionary with the version, latest commit message and the diffs relative to the current working directories. Can be customized by setting the commands dictionary at the class level.
[0m [1;31mParameters changed from their default values are marked in red.[0m [1;36mSoft bound values are marked in cyan.[0m C/V= Constant/Variable, RO/RW = ReadOnly/ReadWrite, AN=Allow None
[1;34mName Value Type Bounds Mode [0m
commands {‘.hg’: ([‘hg’, ‘parents’, ‘–templat... Dict V RW paths [] List (0, None) V RW
[1;32mParameter docstrings: =====================[0m
[1;34mcommands: The subprocess command lists to get the version, commit[0m [1;34m message and diffs for different version control systems. The[0m [1;34m commands are executed if a subdirectory matching the dictionary[0m [1;34m key exists[0m [1;31mpaths: List of repositories to generate version control information from.[0m
Print msg merged with args as a debugging statement.
See Python’s logging module for details of message formatting.
Return {parameter_name:parameter.default} for all non-constant Parameters.
Note that a Parameter for which instantiate==True has its default instantiated.
Return a list of name,value pairs for all Parameters of this object.
If onlychanged is True, will only return values that are not equal to the default value.
Print msg merged with args as a message.
See Python’s logging module for details of message formatting.
Return the Parameters of this class as the dictionary {name: parameter_object}
Includes Parameters from this class and its superclasses.
Same as Parameterized.pprint, except that X.classname(Y is replaced with X.classname.instance(Y
Print the default values of all cls’s Parameters.
Print the values of all this object’s Parameters.
Same as Parameterized.script_repr, except that X.classname(Y is replaced with X.classname.instance(Y
Set the default value of param_name.
Equivalent to setting param_name on the class.
Restore the most recently saved state.
See state_push() for more details.
Save this instance’s state.
For Parameterized instances, this includes the state of dynamically generated values.
Subclasses that maintain short-term state should additionally save and restore that state using state_push() and state_pop().
Generally, this method is used by operations that need to test something without permanently altering the objects’ state.
Print msg merged with args as a verbose message.
See Python’s logging module for details of message formatting.
Print msg merged with args as a warning, unless module variable warnings_as_exceptions is True, then raise an Exception containing the arguments.
See Python’s logging module for details of message formatting.
Bases: lancet.core.Arguments
params(specs=List, fp_precision=Integer, name=String)
An Arguments class that supports statically specified or precomputed argument sets. It may be used directly to specify argument values but also forms the base class for a family of more specific static Argument classes. Each subclass is less flexible and general but allows arguments to be easily and succinctly specified. For instance, the Range subclass allows parameter ranges to be easily declared.
The constructor of Args accepts argument definitions in two different formats. The keyword format allows constant arguments to be specified directly and easily. For instance:
>>> v1 = Args(a=2, b=3) >>> v1 Args(fp_precision=4,a=2,b=3)The alternative input format takes an explicit list of the argument specifications:
>>> v2 = Args([{'a':2, 'b':3}]) # Equivalent behaviour to above >>> v1.specs == v2.specs TrueThis latter format is completely flexible and general, allowing any arbitrary list of arguments to be specified as desired. This is not generally recommended however as the structure of a parameter space is often expressed more clearly by composing together simpler, more succinct Args objects with the CartesianProduct (*) or Concatenation (+) operators.
[0m [1;31mParameters changed from their default values are marked in red.[0m [1;36mSoft bound values are marked in cyan.[0m C/V= Constant/Variable, RO/RW = ReadOnly/ReadWrite, AN=Allow None
[1;34mName Value Type Bounds Mode [0m
fp_precision 4 Integer C RW specs [] List (0, None) C RW
[1;32mParameter docstrings: =====================[0m
[1;34mfp_precision: The floating point precision to use for floating point[0m [1;34m values. Unlike other basic Python types, floats need care[0m [1;34m with their representation as you only want to display up to[0m [1;34m the precision actually specified. A floating point precision[0m [1;34m of 0 casts number to integers before representing them.[0m [1;31mspecs: The static list of specifications (ie. dictionaries) to be[0m [1;31m returned by the specifier. Float values are rounded[0m [1;31m according to fp_precision.[0m
Convenience method to avoid using the specifier without exhausting it.
Print msg merged with args as a debugging statement.
See Python’s logging module for details of message formatting.
Return {parameter_name:parameter.default} for all non-constant Parameters.
Note that a Parameter for which instantiate==True has its default instantiated.
Return a list of name,value pairs for all Parameters of this object.
If onlychanged is True, will only return values that are not equal to the default value.
The lexical sort order is specified by a list of string arguments. Each string is a key name prefixed by ‘+’ or ‘-‘ for ascending and descending sort respectively. If the key is not found in the operand’s set of varying keys, it is ignored.
Print msg merged with args as a message.
See Python’s logging module for details of message formatting.
Return the Parameters of this class as the dictionary {name: parameter_object}
Includes Parameters from this class and its superclasses.
(Experimental) Pretty printed representation that may be evaluated with eval. See pprint() function for more details.
Method to define the positional arguments and keyword order for pretty printing.
Print the default values of all cls’s Parameters.
Print the values of all this object’s Parameters.
Variant of __repr__ designed for generating a runnable script.
Set the default value of param_name.
Equivalent to setting param_name on the class.
Convenience method to inspect the available argument values in human-readable format. The ordering of keys is determined by how quickly they vary.
The exclude list allows specific keys to be excluded for readability (e.g. to hide long, absolute filenames).
Formats the elements of an argument set appropriately
Restore the most recently saved state.
See state_push() for more details.
Save this instance’s state.
For Parameterized instances, this includes the state of dynamically generated values.
Subclasses that maintain short-term state should additionally save and restore that state using state_push() and state_pop().
Generally, this method is used by operations that need to test something without permanently altering the objects’ state.
A succinct summary of the argument specifier. Unlike the repr, a summary does not have to be complete but must supply the most relevant information about the object to the user.
Print msg merged with args as a verbose message.
See Python’s logging module for details of message formatting.
Print msg merged with args as a warning, unless module variable warnings_as_exceptions is True, then raise an Exception containing the arguments.
See Python’s logging module for details of message formatting.
Bases: lancet.core.PrettyPrinted, param.parameterized.Parameterized
params(fp_precision=Integer, name=String)
The abstract, base class that defines the core interface and methods for all members of the Arguments family of classes, including either the simple, static members of Args below, or the sophisticated parameter exploration algorithms subclassing from DynamicArgs defined in dynamic.py.
The Args subclass may be used directly and forms the root of one family of classes that have statically defined or precomputed argument sets (defined below). The second subfamily are the DynamicArgs, designed to allow more sophisticated, online parameter space exploration techniques such as hill climbing, bisection search, genetic algorithms and so on.
[0m [1;31mParameters changed from their default values are marked in red.[0m [1;36mSoft bound values are marked in cyan.[0m C/V= Constant/Variable, RO/RW = ReadOnly/ReadWrite, AN=Allow None
[1;34mName Value Type Mode [0m
fp_precision 4 Integer C RW
[1;32mParameter docstrings: =====================[0m
[1;34mfp_precision: The floating point precision to use for floating point[0m [1;34m values. Unlike other basic Python types, floats need care[0m [1;34m with their representation as you only want to display up to[0m [1;34m the precision actually specified. A floating point precision[0m [1;34m of 0 casts number to integers before representing them.[0m
Returns the set of constant items as a list of tuples. This allows easy conversion to dictionary format. Note, the items should be supplied in the same key ordering as for constant_keys for consistency.
Returns the list of parameter names whose values are constant as the argument specifier is iterated. Note that the union of constant and varying_keys should partition the entire set of keys in the case where there are no unsortable keys.
Print msg merged with args as a debugging statement.
See Python’s logging module for details of message formatting.
Return {parameter_name:parameter.default} for all non-constant Parameters.
Note that a Parameter for which instantiate==True has its default instantiated.
Return a list of name,value pairs for all Parameters of this object.
If onlychanged is True, will only return values that are not equal to the default value.
Print msg merged with args as a message.
See Python’s logging module for details of message formatting.
Called to get a list of specifications: dictionaries with parameter name keys and string values.
Return the Parameters of this class as the dictionary {name: parameter_object}
Includes Parameters from this class and its superclasses.
(Experimental) Pretty printed representation that may be evaluated with eval. See pprint() function for more details.
Method to define the positional arguments and keyword order for pretty printing.
Print the default values of all cls’s Parameters.
Print the values of all this object’s Parameters.
Variant of __repr__ designed for generating a runnable script.
Set the default value of param_name.
Equivalent to setting param_name on the class.
Restore the most recently saved state.
See state_push() for more details.
Save this instance’s state.
For Parameterized instances, this includes the state of dynamically generated values.
Subclasses that maintain short-term state should additionally save and restore that state using state_push() and state_pop().
Generally, this method is used by operations that need to test something without permanently altering the objects’ state.
A succinct summary of the argument specifier. Unlike the repr, a summary does not have to be complete but must supply the most relevant information about the object to the user.
Returns the list of parameters whose values vary as the argument specifier is iterated. Whenever it is possible, keys should be sorted from those slowest to faster varying and sorted alphanumerically within groups that vary at the same rate.
Print msg merged with args as a verbose message.
See Python’s logging module for details of message formatting.
Print msg merged with args as a warning, unless module variable warnings_as_exceptions is True, then raise an Exception containing the arguments.
See Python’s logging module for details of message formatting.
Bases: lancet.core.Args
params(first=ClassSelector, second=ClassSelector, specs=List, fp_precision=Integer, name=String)
CartesianProduct is the Cartesian product of two specifiers. The specifier created by the compositon (firsts * second) generates the cartesian produce of the arguments in first followed by the arguments in second. Note that len(first * second) = len(first)*len(second)
[0m [1;31mParameters changed from their default values are marked in red.[0m [1;36mSoft bound values are marked in cyan.[0m C/V= Constant/Variable, RO/RW = ReadOnly/ReadWrite, AN=Allow None
[1;34mName Value Type Bounds Mode [0m
first None ClassSelector C RW AN fp_precision 4 Integer C RW second None ClassSelector C RW AN specs [] List (0, None) C RW
[1;32mParameter docstrings: =====================[0m
[1;34mfirst: The first specifier in the Cartesian product.[0m [1;31mfp_precision: The floating point precision to use for floating point[0m [1;31m values. Unlike other basic Python types, floats need care[0m [1;31m with their representation as you only want to display up to[0m [1;31m the precision actually specified. A floating point precision[0m [1;31m of 0 casts number to integers before representing them.[0m [1;34msecond: The second specifier in the Cartesian product.[0m [1;31mspecs: The static list of specifications (ie. dictionaries) to be[0m [1;31m returned by the specifier. Float values are rounded[0m [1;31m according to fp_precision.[0m
Convenience method to avoid using the specifier without exhausting it.
Print msg merged with args as a debugging statement.
See Python’s logging module for details of message formatting.
Return {parameter_name:parameter.default} for all non-constant Parameters.
Note that a Parameter for which instantiate==True has its default instantiated.
Return a list of name,value pairs for all Parameters of this object.
If onlychanged is True, will only return values that are not equal to the default value.
The lexical sort order is specified by a list of string arguments. Each string is a key name prefixed by ‘+’ or ‘-‘ for ascending and descending sort respectively. If the key is not found in the operand’s set of varying keys, it is ignored.
Print msg merged with args as a message.
See Python’s logging module for details of message formatting.
Return the Parameters of this class as the dictionary {name: parameter_object}
Includes Parameters from this class and its superclasses.
(Experimental) Pretty printed representation that may be evaluated with eval. See pprint() function for more details.
Method to define the positional arguments and keyword order for pretty printing.
Print the default values of all cls’s Parameters.
Print the values of all this object’s Parameters.
Variant of __repr__ designed for generating a runnable script.
Set the default value of param_name.
Equivalent to setting param_name on the class.
Convenience method to inspect the available argument values in human-readable format. The ordering of keys is determined by how quickly they vary.
The exclude list allows specific keys to be excluded for readability (e.g. to hide long, absolute filenames).
Formats the elements of an argument set appropriately
Restore the most recently saved state.
See state_push() for more details.
Save this instance’s state.
For Parameterized instances, this includes the state of dynamically generated values.
Subclasses that maintain short-term state should additionally save and restore that state using state_push() and state_pop().
Generally, this method is used by operations that need to test something without permanently altering the objects’ state.
A succinct summary of the argument specifier. Unlike the repr, a summary does not have to be complete but must supply the most relevant information about the object to the user.
Print msg merged with args as a verbose message.
See Python’s logging module for details of message formatting.
Print msg merged with args as a warning, unless module variable warnings_as_exceptions is True, then raise an Exception containing the arguments.
See Python’s logging module for details of message formatting.
Bases: lancet.core.Args
params(first=ClassSelector, second=ClassSelector, specs=List, fp_precision=Integer, name=String)
Concatenate is the sequential composition of two specifiers. The specifier created by the compositon (firsts + second) generates the arguments in first followed by the arguments in second.
[0m [1;31mParameters changed from their default values are marked in red.[0m [1;36mSoft bound values are marked in cyan.[0m C/V= Constant/Variable, RO/RW = ReadOnly/ReadWrite, AN=Allow None
[1;34mName Value Type Bounds Mode [0m
first None ClassSelector C RW AN fp_precision 4 Integer C RW second None ClassSelector C RW AN specs [] List (0, None) C RW
[1;32mParameter docstrings: =====================[0m
[1;34mfirst: The first specifier in the concatenation.[0m [1;31mfp_precision: The floating point precision to use for floating point[0m [1;31m values. Unlike other basic Python types, floats need care[0m [1;31m with their representation as you only want to display up to[0m [1;31m the precision actually specified. A floating point precision[0m [1;31m of 0 casts number to integers before representing them.[0m [1;34msecond: The second specifier in the concatenation.[0m [1;31mspecs: The static list of specifications (ie. dictionaries) to be[0m [1;31m returned by the specifier. Float values are rounded[0m [1;31m according to fp_precision.[0m
Convenience method to avoid using the specifier without exhausting it.
Print msg merged with args as a debugging statement.
See Python’s logging module for details of message formatting.
Return {parameter_name:parameter.default} for all non-constant Parameters.
Note that a Parameter for which instantiate==True has its default instantiated.
Return a list of name,value pairs for all Parameters of this object.
If onlychanged is True, will only return values that are not equal to the default value.
The lexical sort order is specified by a list of string arguments. Each string is a key name prefixed by ‘+’ or ‘-‘ for ascending and descending sort respectively. If the key is not found in the operand’s set of varying keys, it is ignored.
Print msg merged with args as a message.
See Python’s logging module for details of message formatting.
Return the Parameters of this class as the dictionary {name: parameter_object}
Includes Parameters from this class and its superclasses.
(Experimental) Pretty printed representation that may be evaluated with eval. See pprint() function for more details.
Method to define the positional arguments and keyword order for pretty printing.
Print the default values of all cls’s Parameters.
Print the values of all this object’s Parameters.
Variant of __repr__ designed for generating a runnable script.
Set the default value of param_name.
Equivalent to setting param_name on the class.
Convenience method to inspect the available argument values in human-readable format. The ordering of keys is determined by how quickly they vary.
The exclude list allows specific keys to be excluded for readability (e.g. to hide long, absolute filenames).
Formats the elements of an argument set appropriately
Restore the most recently saved state.
See state_push() for more details.
Save this instance’s state.
For Parameterized instances, this includes the state of dynamically generated values.
Subclasses that maintain short-term state should additionally save and restore that state using state_push() and state_pop().
Generally, this method is used by operations that need to test something without permanently altering the objects’ state.
A succinct summary of the argument specifier. Unlike the repr, a summary does not have to be complete but must supply the most relevant information about the object to the user.
Print msg merged with args as a verbose message.
See Python’s logging module for details of message formatting.
Print msg merged with args as a warning, unless module variable warnings_as_exceptions is True, then raise an Exception containing the arguments.
See Python’s logging module for details of message formatting.
Bases: lancet.core.Args
params(filetype=ClassSelector, ignore=List, key=String, source=ClassSelector, specs=List, fp_precision=Integer, name=String)
Loads metadata from a set of filenames. For instance, you can load metadata associated with a series of image files given by a FilePattern. Unlike other explicit instances of Args, this object extends the values of an existing Args object. Once you have loaded the metadata, FileInfo allows you to load the file data into a pandas DataFrame or a HoloViews Table.
[0m [1;31mParameters changed from their default values are marked in red.[0m [1;36mSoft bound values are marked in cyan.[0m C/V= Constant/Variable, RO/RW = ReadOnly/ReadWrite, AN=Allow None
[1;34mName Value Type Bounds Mode [0m
filetype None ClassSelector C RW AN fp_precision 4 Integer C RW ignore [] List (0, None) C RW key ‘’ String C RW source None ClassSelector V RW AN specs [] List (0, None) C RW
[1;32mParameter docstrings: =====================[0m
[1;34mfiletype: A FileType object to be applied to each file path.[0m [1;31mfp_precision: The floating point precision to use for floating point[0m [1;31m values. Unlike other basic Python types, floats need care[0m [1;31m with their representation as you only want to display up to[0m [1;31m the precision actually specified. A floating point precision[0m [1;31m of 0 casts number to integers before representing them.[0m [1;34mignore: Metadata keys that are to be explicitly ignored. [0m [1;31mkey: The key used to find the file paths for inspection.[0m [1;34msource: The argument specifier that supplies the file paths.[0m [1;31mspecs: The static list of specifications (ie. dictionaries) to be[0m [1;31m returned by the specifier. Float values are rounded[0m [1;31m according to fp_precision.[0m
Convenience method to avoid using the specifier without exhausting it.
Print msg merged with args as a debugging statement.
See Python’s logging module for details of message formatting.
Return {parameter_name:parameter.default} for all non-constant Parameters.
Note that a Parameter for which instantiate==True has its default instantiated.
Convenience method to directly chain a pattern processed by FilePattern into a FileInfo instance.
Note that if a default filetype has been set on FileInfo, the filetype argument may be omitted.
Return a list of name,value pairs for all Parameters of this object.
If onlychanged is True, will only return values that are not equal to the default value.
The lexical sort order is specified by a list of string arguments. Each string is a key name prefixed by ‘+’ or ‘-‘ for ascending and descending sort respectively. If the key is not found in the operand’s set of varying keys, it is ignored.
Load the file contents into the supplied pandas dataframe or HoloViews Table. This allows a selection to be made over the metadata before loading the file contents (may be slow).
Load the file contents into the supplied dataframe using the specified key and filetype.
Load the file contents into the supplied Table using the specified key and filetype. The input table should have the filenames as values which will be replaced by the loaded data. If data_key is specified, this key will be used to index the loaded data to retrive the specified item.
Print msg merged with args as a message.
See Python’s logging module for details of message formatting.
Return the Parameters of this class as the dictionary {name: parameter_object}
Includes Parameters from this class and its superclasses.
(Experimental) Pretty printed representation that may be evaluated with eval. See pprint() function for more details.
Method to define the positional arguments and keyword order for pretty printing.
Print the default values of all cls’s Parameters.
Print the values of all this object’s Parameters.
Variant of __repr__ designed for generating a runnable script.
Set the default value of param_name.
Equivalent to setting param_name on the class.
Convenience method to inspect the available argument values in human-readable format. The ordering of keys is determined by how quickly they vary.
The exclude list allows specific keys to be excluded for readability (e.g. to hide long, absolute filenames).
Formats the elements of an argument set appropriately
Restore the most recently saved state.
See state_push() for more details.
Save this instance’s state.
For Parameterized instances, this includes the state of dynamically generated values.
Subclasses that maintain short-term state should additionally save and restore that state using state_push() and state_pop().
Generally, this method is used by operations that need to test something without permanently altering the objects’ state.
A succinct summary of the argument specifier. Unlike the repr, a summary does not have to be complete but must supply the most relevant information about the object to the user.
Print msg merged with args as a verbose message.
See Python’s logging module for details of message formatting.
Print msg merged with args as a warning, unless module variable warnings_as_exceptions is True, then raise an Exception containing the arguments.
See Python’s logging module for details of message formatting.
Bases: lancet.core.Args
params(key=String, pattern=String, root=String, specs=List, fp_precision=Integer, name=String)
A FilePattern specifier allows files to be matched and information encoded in filenames to be extracted via an extended form of globbing. This object may be used to specify filename arguments to CommandTemplates when launching jobs but it also very useful for collating files for analysis.
For instance, you can find the absolute filenames of all npz files in a ‘data’ subdirectory (relative to the root) that start with ‘timeseries’ using the pattern ‘data/timeseries*.npz’.
In addition to globbing supported by the glob module, patterns can extract metadata encoded in filenames using a subset of the Python format specification syntax. To illustrate, you can use ‘data/timeseries-{date}.npz’ to record the date strings associated with matched files. Note that a particular named fields can only be used in a particular pattern once.
By default metadata is extracted as strings but format types are supported in the usual manner eg. ‘data/timeseries-{day:d}-{month:d}.npz’ will extract the day and month from the filename as integer values. Only field names and types are recognised with other format specification syntax ignored. Type codes supported: ‘d’, ‘b’, ‘o’, ‘x’, ‘e’,’E’,’f’, ‘F’,’g’, ‘G’, ‘n’ (if ommited, result is a string by default).
Note that ordering is determined via ascending alphanumeric sort and that actual filenames should not include any globbing characters, namely: ‘?’,’*’,’[‘ and ‘]’ (general good practice for filenames anyway).
[0m [1;31mParameters changed from their default values are marked in red.[0m [1;36mSoft bound values are marked in cyan.[0m C/V= Constant/Variable, RO/RW = ReadOnly/ReadWrite, AN=Allow None
[1;34mName Value Type Bounds Mode [0m
fp_precision 4 Integer C RW key None String C RW AN pattern None String C RW AN root None String C RW AN specs [] List (0, None) C RW
[1;32mParameter docstrings: =====================[0m
[1;34mfp_precision: The floating point precision to use for floating point[0m [1;34m values. Unlike other basic Python types, floats need care[0m [1;34m with their representation as you only want to display up to[0m [1;34m the precision actually specified. A floating point precision[0m [1;34m of 0 casts number to integers before representing them.[0m [1;31mkey: The key name given to the matched file path strings.[0m [1;34mpattern: The pattern files are to be searched against.[0m [1;31mroot: The root directory from which patterns are to be loaded.[0m [1;31m The root is set relative to os.getcwd().[0m [1;34mspecs: The static list of specifications (ie. dictionaries) to be[0m [1;34m returned by the specifier. Float values are rounded[0m [1;34m according to fp_precision.[0m
Convenience method to avoid using the specifier without exhausting it.
Print msg merged with args as a debugging statement.
See Python’s logging module for details of message formatting.
Return {parameter_name:parameter.default} for all non-constant Parameters.
Note that a Parameter for which instantiate==True has its default instantiated.
Load all the files in a given directory selecting only files with the given extension if specified. The given kwargs are passed through to the normal constructor.
Return the fields specified in the pattern using Python’s formatting mini-language.
Return a list of name,value pairs for all Parameters of this object.
If onlychanged is True, will only return values that are not equal to the default value.
The lexical sort order is specified by a list of string arguments. Each string is a key name prefixed by ‘+’ or ‘-‘ for ascending and descending sort respectively. If the key is not found in the operand’s set of varying keys, it is ignored.
Print msg merged with args as a message.
See Python’s logging module for details of message formatting.
Return the Parameters of this class as the dictionary {name: parameter_object}
Includes Parameters from this class and its superclasses.
(Experimental) Pretty printed representation that may be evaluated with eval. See pprint() function for more details.
Method to define the positional arguments and keyword order for pretty printing.
Print the default values of all cls’s Parameters.
Print the values of all this object’s Parameters.
Variant of __repr__ designed for generating a runnable script.
Set the default value of param_name.
Equivalent to setting param_name on the class.
Convenience method to inspect the available argument values in human-readable format. The ordering of keys is determined by how quickly they vary.
The exclude list allows specific keys to be excluded for readability (e.g. to hide long, absolute filenames).
Formats the elements of an argument set appropriately
Restore the most recently saved state.
See state_push() for more details.
Save this instance’s state.
For Parameterized instances, this includes the state of dynamically generated values.
Subclasses that maintain short-term state should additionally save and restore that state using state_push() and state_pop().
Generally, this method is used by operations that need to test something without permanently altering the objects’ state.
A succinct summary of the argument specifier. Unlike the repr, a summary does not have to be complete but must supply the most relevant information about the object to the user.
Print msg merged with args as a verbose message.
See Python’s logging module for details of message formatting.
Print msg merged with args as a warning, unless module variable warnings_as_exceptions is True, then raise an Exception containing the arguments.
See Python’s logging module for details of message formatting.
Bases: lancet.core.Arguments
params(fp_precision=Integer, name=String)
The identity element for any Arguments object ‘args’ under the * operator (CartesianProduct) and + operator (Concatenate). The following identities hold:
args is (Identity() * args) args is (args * Identity())
args is (Identity() + args) args is (args + Identity())
Note that the empty Args() object can also fulfill the role of Identity under the addition operator.
[0m [1;31mParameters changed from their default values are marked in red.[0m [1;36mSoft bound values are marked in cyan.[0m C/V= Constant/Variable, RO/RW = ReadOnly/ReadWrite, AN=Allow None
[1;34mName Value Type Mode [0m
fp_precision 4 Integer C RW AN
[1;32mParameter docstrings: =====================[0m
[1;34mfp_precision: fp_precision is disabled as Identity() never contains any[0m [1;34m arguments.[0m
Returns the set of constant items as a list of tuples. This allows easy conversion to dictionary format. Note, the items should be supplied in the same key ordering as for constant_keys for consistency.
Returns the list of parameter names whose values are constant as the argument specifier is iterated. Note that the union of constant and varying_keys should partition the entire set of keys in the case where there are no unsortable keys.
Convenience method to avoid using the specifier without exhausting it.
Print msg merged with args as a debugging statement.
See Python’s logging module for details of message formatting.
Return {parameter_name:parameter.default} for all non-constant Parameters.
Note that a Parameter for which instantiate==True has its default instantiated.
Return a list of name,value pairs for all Parameters of this object.
If onlychanged is True, will only return values that are not equal to the default value.
Print msg merged with args as a message.
See Python’s logging module for details of message formatting.
Called to get a list of specifications: dictionaries with parameter name keys and string values.
Return the Parameters of this class as the dictionary {name: parameter_object}
Includes Parameters from this class and its superclasses.
(Experimental) Pretty printed representation that may be evaluated with eval. See pprint() function for more details.
Method to define the positional arguments and keyword order for pretty printing.
Print the default values of all cls’s Parameters.
Print the values of all this object’s Parameters.
Variant of __repr__ designed for generating a runnable script.
Set the default value of param_name.
Equivalent to setting param_name on the class.
Formats the elements of an argument set appropriately
Restore the most recently saved state.
See state_push() for more details.
Save this instance’s state.
For Parameterized instances, this includes the state of dynamically generated values.
Subclasses that maintain short-term state should additionally save and restore that state using state_push() and state_pop().
Generally, this method is used by operations that need to test something without permanently altering the objects’ state.
A succinct summary of the argument specifier. Unlike the repr, a summary does not have to be complete but must supply the most relevant information about the object to the user.
Returns the list of parameters whose values vary as the argument specifier is iterated. Whenever it is possible, keys should be sorted from those slowest to faster varying and sorted alphanumerically within groups that vary at the same rate.
Print msg merged with args as a verbose message.
See Python’s logging module for details of message formatting.
Print msg merged with args as a warning, unless module variable warnings_as_exceptions is True, then raise an Exception containing the arguments.
See Python’s logging module for details of message formatting.
Bases: lancet.core.Args
params(key=String, values=List, specs=List, fp_precision=Integer, name=String)
An argument specifier that takes its values from a given list.
[0m [1;31mParameters changed from their default values are marked in red.[0m [1;36mSoft bound values are marked in cyan.[0m C/V= Constant/Variable, RO/RW = ReadOnly/ReadWrite, AN=Allow None
[1;34mName Value Type Bounds Mode [0m
fp_precision 4 Integer C RW key ‘default’ String C RW specs [] List (0, None) C RW values [] List (0, None) C RW
[1;32mParameter docstrings: =====================[0m
[1;34mfp_precision: The floating point precision to use for floating point[0m [1;34m values. Unlike other basic Python types, floats need care[0m [1;34m with their representation as you only want to display up to[0m [1;34m the precision actually specified. A floating point precision[0m [1;34m of 0 casts number to integers before representing them.[0m [1;31mkey: The key assigned to the elements of the supplied list.[0m [1;34mspecs: The static list of specifications (ie. dictionaries) to be[0m [1;34m returned by the specifier. Float values are rounded[0m [1;34m according to fp_precision.[0m [1;31mvalues: The list values that are to be returned by the specifier[0m
Convenience method to avoid using the specifier without exhausting it.
Print msg merged with args as a debugging statement.
See Python’s logging module for details of message formatting.
Return {parameter_name:parameter.default} for all non-constant Parameters.
Note that a Parameter for which instantiate==True has its default instantiated.
Return a list of name,value pairs for all Parameters of this object.
If onlychanged is True, will only return values that are not equal to the default value.
The lexical sort order is specified by a list of string arguments. Each string is a key name prefixed by ‘+’ or ‘-‘ for ascending and descending sort respectively. If the key is not found in the operand’s set of varying keys, it is ignored.
Print msg merged with args as a message.
See Python’s logging module for details of message formatting.
Return the Parameters of this class as the dictionary {name: parameter_object}
Includes Parameters from this class and its superclasses.
(Experimental) Pretty printed representation that may be evaluated with eval. See pprint() function for more details.
Method to define the positional arguments and keyword order for pretty printing.
Print the default values of all cls’s Parameters.
Print the values of all this object’s Parameters.
Variant of __repr__ designed for generating a runnable script.
Set the default value of param_name.
Equivalent to setting param_name on the class.
Convenience method to inspect the available argument values in human-readable format. The ordering of keys is determined by how quickly they vary.
The exclude list allows specific keys to be excluded for readability (e.g. to hide long, absolute filenames).
Formats the elements of an argument set appropriately
Restore the most recently saved state.
See state_push() for more details.
Save this instance’s state.
For Parameterized instances, this includes the state of dynamically generated values.
Subclasses that maintain short-term state should additionally save and restore that state using state_push() and state_pop().
Generally, this method is used by operations that need to test something without permanently altering the objects’ state.
A succinct summary of the argument specifier. Unlike the repr, a summary does not have to be complete but must supply the most relevant information about the object to the user.
Print msg merged with args as a verbose message.
See Python’s logging module for details of message formatting.
Print msg merged with args as a warning, unless module variable warnings_as_exceptions is True, then raise an Exception containing the arguments.
See Python’s logging module for details of message formatting.
Bases: lancet.core.Args
params(log_path=String, tid_key=String, specs=List, fp_precision=Integer, name=String)
Specifier that loads arguments from a log file in task id (tid) order. This wrapper class allows a concise representation of file logs with the option of adding the task id to the loaded specifications.
For full control over the arguments, you can use this class to create a fully specified Args object as follows:
Args(Log.extract_log(<log_file>).values()),
[0m [1;31mParameters changed from their default values are marked in red.[0m [1;36mSoft bound values are marked in cyan.[0m C/V= Constant/Variable, RO/RW = ReadOnly/ReadWrite, AN=Allow None
[1;34mName Value Type Bounds Mode [0m
fp_precision 4 Integer C RW log_path None String C RW AN specs [] List (0, None) C RW tid_key ‘tid’ String C RW AN
[1;32mParameter docstrings: =====================[0m
[1;34mfp_precision: The floating point precision to use for floating point[0m [1;34m values. Unlike other basic Python types, floats need care[0m [1;34m with their representation as you only want to display up to[0m [1;34m the precision actually specified. A floating point precision[0m [1;34m of 0 casts number to integers before representing them.[0m [1;31mlog_path: The relative or absolute path to the log file. If a[0m [1;31m relative path is given, the absolute path is computed[0m [1;31m relative to os.getcwd().[0m [1;34mspecs: The static list of specifications (ie. dictionaries) to be[0m [1;34m returned by the specifier. Float values are rounded[0m [1;34m according to fp_precision.[0m [1;31mtid_key: If not None, the key given to the tid values included[0m [1;31m in the loaded specifications. If None, the tid number[0m [1;31m is ignored.[0m
Convenience method to avoid using the specifier without exhausting it.
Print msg merged with args as a debugging statement.
See Python’s logging module for details of message formatting.
Return {parameter_name:parameter.default} for all non-constant Parameters.
Note that a Parameter for which instantiate==True has its default instantiated.
Parses the log file generated by a launcher and returns dictionary with tid keys and specification values.
Ordering can be maintained by setting dict_type to the appropriate constructor (i.e. OrderedDict). Keys are converted from unicode to strings for kwarg use.
Return a list of name,value pairs for all Parameters of this object.
If onlychanged is True, will only return values that are not equal to the default value.
The lexical sort order is specified by a list of string arguments. Each string is a key name prefixed by ‘+’ or ‘-‘ for ascending and descending sort respectively. If the key is not found in the operand’s set of varying keys, it is ignored.
Print msg merged with args as a message.
See Python’s logging module for details of message formatting.
Return the Parameters of this class as the dictionary {name: parameter_object}
Includes Parameters from this class and its superclasses.
(Experimental) Pretty printed representation that may be evaluated with eval. See pprint() function for more details.
Method to define the positional arguments and keyword order for pretty printing.
Print the default values of all cls’s Parameters.
Print the values of all this object’s Parameters.
Variant of __repr__ designed for generating a runnable script.
Set the default value of param_name.
Equivalent to setting param_name on the class.
Convenience method to inspect the available argument values in human-readable format. The ordering of keys is determined by how quickly they vary.
The exclude list allows specific keys to be excluded for readability (e.g. to hide long, absolute filenames).
Formats the elements of an argument set appropriately
Restore the most recently saved state.
See state_push() for more details.
Save this instance’s state.
For Parameterized instances, this includes the state of dynamically generated values.
Subclasses that maintain short-term state should additionally save and restore that state using state_push() and state_pop().
Generally, this method is used by operations that need to test something without permanently altering the objects’ state.
A succinct summary of the argument specifier. Unlike the repr, a summary does not have to be complete but must supply the most relevant information about the object to the user.
Print msg merged with args as a verbose message.
See Python’s logging module for details of message formatting.
Print msg merged with args as a warning, unless module variable warnings_as_exceptions is True, then raise an Exception containing the arguments.
See Python’s logging module for details of message formatting.
Writes the supplied specifications to the log path. The data may be supplied as either as a an Args or as a list of dictionaries.
By default, specifications will be appropriately appended to an existing log file. This can be disabled by setting allow_append to False.
Bases: object
A mixin class for generating pretty-printed representations.
Bases: lancet.core.Args
params(end_value=Number, key=String, mapfn=Callable, start_value=Number, steps=Integer, specs=List, fp_precision=Integer, name=String)
Range generates an argument from a numerically interpolated range which is linear by default. An optional function can be specified to sample a numeric range with regular intervals.
[0m [1;31mParameters changed from their default values are marked in red.[0m [1;36mSoft bound values are marked in cyan.[0m C/V= Constant/Variable, RO/RW = ReadOnly/ReadWrite, AN=Allow None
[1;34mName Value Type Bounds Mode [0m
end_value None Number C RW AN fp_precision 4 Integer C RW key ‘’ String C RW mapfn <function identityfn at 0x2b06c9b508c... Callable C RW specs [] List (0, None) C RW start_value None Number C RW AN steps 2 Integer (1, None) C RW
[1;32mParameter docstrings: =====================[0m
[1;34mend_value: The ending numeric value of the range (inclusive).[0m [1;31mfp_precision: The floating point precision to use for floating point[0m [1;31m values. Unlike other basic Python types, floats need care[0m [1;31m with their representation as you only want to display up to[0m [1;31m the precision actually specified. A floating point precision[0m [1;31m of 0 casts number to integers before representing them.[0m [1;34mkey: The key assigned to the values computed over the numeric range.[0m [1;31mmapfn: The function to be mapped across the linear range. The[0m [1;31m identity function is used by by default[0m [1;34mspecs: The static list of specifications (ie. dictionaries) to be[0m [1;34m returned by the specifier. Float values are rounded[0m [1;34m according to fp_precision.[0m [1;31mstart_value: The starting numeric value of the range.[0m [1;34msteps: The number of steps to interpolate over. Default is 2[0m [1;34m which returns the start and end values without interpolation.[0m
Convenience method to avoid using the specifier without exhausting it.
Print msg merged with args as a debugging statement.
See Python’s logging module for details of message formatting.
Return {parameter_name:parameter.default} for all non-constant Parameters.
Note that a Parameter for which instantiate==True has its default instantiated.
Return a list of name,value pairs for all Parameters of this object.
If onlychanged is True, will only return values that are not equal to the default value.
The lexical sort order is specified by a list of string arguments. Each string is a key name prefixed by ‘+’ or ‘-‘ for ascending and descending sort respectively. If the key is not found in the operand’s set of varying keys, it is ignored.
Print msg merged with args as a message.
See Python’s logging module for details of message formatting.
Return the Parameters of this class as the dictionary {name: parameter_object}
Includes Parameters from this class and its superclasses.
(Experimental) Pretty printed representation that may be evaluated with eval. See pprint() function for more details.
Method to define the positional arguments and keyword order for pretty printing.
Print the default values of all cls’s Parameters.
Print the values of all this object’s Parameters.
Variant of __repr__ designed for generating a runnable script.
Set the default value of param_name.
Equivalent to setting param_name on the class.
Convenience method to inspect the available argument values in human-readable format. The ordering of keys is determined by how quickly they vary.
The exclude list allows specific keys to be excluded for readability (e.g. to hide long, absolute filenames).
Formats the elements of an argument set appropriately
Restore the most recently saved state.
See state_push() for more details.
Save this instance’s state.
For Parameterized instances, this includes the state of dynamically generated values.
Subclasses that maintain short-term state should additionally save and restore that state using state_push() and state_pop().
Generally, this method is used by operations that need to test something without permanently altering the objects’ state.
A succinct summary of the argument specifier. Unlike the repr, a summary does not have to be complete but must supply the most relevant information about the object to the user.
Print msg merged with args as a verbose message.
See Python’s logging module for details of message formatting.
Print msg merged with args as a warning, unless module variable warnings_as_exceptions is True, then raise an Exception containing the arguments.
See Python’s logging module for details of message formatting.
Bases: lancet.core.Arguments
params(output_extractor=Callable, fp_precision=Integer, name=String)
DynamicArgs are declarative specifications that specify a parameter space via a dynamic algorithmic process instead of using precomputed arguments. Unlike the static Args objects, new arguments can only be generated in response to some feedback from the processes that are executed. This type of dynamic feedback is a common feature for many algorithms such as hill climbing optimization, genetic algorithms, bisection search and other sophisticated optimization and search procedures.
Like the Args objects, a DynamicArgs object is an iterator. On each iteration, one or more argument sets defining a collection of independent jobs are returned (these jobs should be possible to execute concurrently). Between iterations, the output_extractor function is used to extract the necessary information from the standard output streams of the previously executed jobs. This information is used to update the internal state of the DynamicArgs object can then generate more arguments to explore or terminate. All DynamicArgs classes need to declare the expected return format of the output_extractor function.
[0m [1;31mParameters changed from their default values are marked in red.[0m [1;36mSoft bound values are marked in cyan.[0m C/V= Constant/Variable, RO/RW = ReadOnly/ReadWrite, AN=Allow None
[1;34mName Value Type Mode [0m
fp_precision 4 Integer C RW output_extractor <function loads at 0x2b06c9b50848> Callable V RW
[1;32mParameter docstrings: =====================[0m
[1;34mfp_precision: The floating point precision to use for floating point[0m [1;34m values. Unlike other basic Python types, floats need care[0m [1;34m with their representation as you only want to display up to[0m [1;34m the precision actually specified. A floating point precision[0m [1;34m of 0 casts number to integers before representing them.[0m [1;31moutput_extractor: The function that returns the relevant data from the standard[0m [1;31m output stream dumped to file in the streams subdirectory. This[0m [1;31m information must be retyrned in a format suitable for updating[0m [1;31m the specifier.. By default uses json.loads but pickle.loads[0m [1;31m could also be a valid option. The callable must take a string[0m [1;31m and return a Python object suitable for updating the specifier.[0m
Returns the set of constant items as a list of tuples. This allows easy conversion to dictionary format. Note, the items should be supplied in the same key ordering as for constant_keys for consistency.
Returns the list of parameter names whose values are constant as the argument specifier is iterated. Note that the union of constant and varying_keys should partition the entire set of keys in the case where there are no unsortable keys.
Convenience method to avoid using the specifier without exhausting it.
Print msg merged with args as a debugging statement.
See Python’s logging module for details of message formatting.
Return {parameter_name:parameter.default} for all non-constant Parameters.
Note that a Parameter for which instantiate==True has its default instantiated.
Return a list of name,value pairs for all Parameters of this object.
If onlychanged is True, will only return values that are not equal to the default value.
Print msg merged with args as a message.
See Python’s logging module for details of message formatting.
Deserialize s (a str or unicode instance containing a JSON document) to a Python object.
If s is a str instance and is encoded with an ASCII based encoding other than utf-8 (e.g. latin-1) then an appropriate encoding name must be specified. Encodings that are not ASCII based (such as UCS-2) are not allowed and should be decoded to unicode first.
object_hook is an optional function that will be called with the result of any object literal decode (a dict). The return value of object_hook will be used instead of the dict. This feature can be used to implement custom decoders (e.g. JSON-RPC class hinting).
object_pairs_hook is an optional function that will be called with the result of any object literal decoded with an ordered list of pairs. The return value of object_pairs_hook will be used instead of the dict. This feature can be used to implement custom decoders that rely on the order that the key and value pairs are decoded (for example, collections.OrderedDict will remember the order of insertion). If object_hook is also defined, the object_pairs_hook takes priority.
parse_float, if specified, will be called with the string of every JSON float to be decoded. By default this is equivalent to float(num_str). This can be used to use another datatype or parser for JSON floats (e.g. decimal.Decimal).
parse_int, if specified, will be called with the string of every JSON int to be decoded. By default this is equivalent to int(num_str). This can be used to use another datatype or parser for JSON integers (e.g. float).
parse_constant, if specified, will be called with one of the following strings: -Infinity, Infinity, NaN, null, true, false. This can be used to raise an exception if invalid JSON numbers are encountered.
To use a custom JSONDecoder subclass, specify it with the cls kwarg; otherwise JSONDecoder is used.
Return the Parameters of this class as the dictionary {name: parameter_object}
Includes Parameters from this class and its superclasses.
(Experimental) Pretty printed representation that may be evaluated with eval. See pprint() function for more details.
Method to define the positional arguments and keyword order for pretty printing.
Print the default values of all cls’s Parameters.
Print the values of all this object’s Parameters.
Variant of __repr__ designed for generating a runnable script.
Set the default value of param_name.
Equivalent to setting param_name on the class.
Formats the elements of an argument set appropriately
Restore the most recently saved state.
See state_push() for more details.
Save this instance’s state.
For Parameterized instances, this includes the state of dynamically generated values.
Subclasses that maintain short-term state should additionally save and restore that state using state_push() and state_pop().
Generally, this method is used by operations that need to test something without permanently altering the objects’ state.
A succinct summary of the argument specifier. Unlike the repr, a summary does not have to be complete but must supply the most relevant information about the object to the user.
Called to update the state of the iterator. This methods receives the set of task ids from the previous set of tasks together with the launch information to allow the output values to be parsed using the output_extractor. This data is then used to determine the next desired point in the parameter space by calling the _update_state method.
Returns the list of parameters whose values vary as the argument specifier is iterated. Whenever it is possible, keys should be sorted from those slowest to faster varying and sorted alphanumerically within groups that vary at the same rate.
Print msg merged with args as a verbose message.
See Python’s logging module for details of message formatting.
Print msg merged with args as a warning, unless module variable warnings_as_exceptions is True, then raise an Exception containing the arguments.
See Python’s logging module for details of message formatting.
Bases: lancet.dynamic.DynamicArgs
params(output_extractor=Callable, fp_precision=Integer, name=String) [1;32mParameters of ‘DynamicCartesianProduct’ ======================================= [0m [1;31mParameters changed from their default values are marked in red.[0m [1;36mSoft bound values are marked in cyan.[0m C/V= Constant/Variable, RO/RW = ReadOnly/ReadWrite, AN=Allow None
[1;34mName Value Type Mode [0m
fp_precision 4 Integer C RW output_extractor <function loads at 0x2b06c9b50848> Callable V RW
[1;32mParameter docstrings: =====================[0m
[1;34mfp_precision: The floating point precision to use for floating point[0m [1;34m values. Unlike other basic Python types, floats need care[0m [1;34m with their representation as you only want to display up to[0m [1;34m the precision actually specified. A floating point precision[0m [1;34m of 0 casts number to integers before representing them.[0m [1;31moutput_extractor: The function that returns the relevant data from the standard[0m [1;31m output stream dumped to file in the streams subdirectory. This[0m [1;31m information must be retyrned in a format suitable for updating[0m [1;31m the specifier.. By default uses json.loads but pickle.loads[0m [1;31m could also be a valid option. The callable must take a string[0m [1;31m and return a Python object suitable for updating the specifier.[0m
Returns the set of constant items as a list of tuples. This allows easy conversion to dictionary format. Note, the items should be supplied in the same key ordering as for constant_keys for consistency.
Convenience method to avoid using the specifier without exhausting it.
Print msg merged with args as a debugging statement.
See Python’s logging module for details of message formatting.
Return {parameter_name:parameter.default} for all non-constant Parameters.
Note that a Parameter for which instantiate==True has its default instantiated.
Return a list of name,value pairs for all Parameters of this object.
If onlychanged is True, will only return values that are not equal to the default value.
Print msg merged with args as a message.
See Python’s logging module for details of message formatting.
Deserialize s (a str or unicode instance containing a JSON document) to a Python object.
If s is a str instance and is encoded with an ASCII based encoding other than utf-8 (e.g. latin-1) then an appropriate encoding name must be specified. Encodings that are not ASCII based (such as UCS-2) are not allowed and should be decoded to unicode first.
object_hook is an optional function that will be called with the result of any object literal decode (a dict). The return value of object_hook will be used instead of the dict. This feature can be used to implement custom decoders (e.g. JSON-RPC class hinting).
object_pairs_hook is an optional function that will be called with the result of any object literal decoded with an ordered list of pairs. The return value of object_pairs_hook will be used instead of the dict. This feature can be used to implement custom decoders that rely on the order that the key and value pairs are decoded (for example, collections.OrderedDict will remember the order of insertion). If object_hook is also defined, the object_pairs_hook takes priority.
parse_float, if specified, will be called with the string of every JSON float to be decoded. By default this is equivalent to float(num_str). This can be used to use another datatype or parser for JSON floats (e.g. decimal.Decimal).
parse_int, if specified, will be called with the string of every JSON int to be decoded. By default this is equivalent to int(num_str). This can be used to use another datatype or parser for JSON integers (e.g. float).
parse_constant, if specified, will be called with one of the following strings: -Infinity, Infinity, NaN, null, true, false. This can be used to raise an exception if invalid JSON numbers are encountered.
To use a custom JSONDecoder subclass, specify it with the cls kwarg; otherwise JSONDecoder is used.
Return the Parameters of this class as the dictionary {name: parameter_object}
Includes Parameters from this class and its superclasses.
(Experimental) Pretty printed representation that may be evaluated with eval. See pprint() function for more details.
Method to define the positional arguments and keyword order for pretty printing.
Print the default values of all cls’s Parameters.
Print the values of all this object’s Parameters.
Variant of __repr__ designed for generating a runnable script.
Set the default value of param_name.
Equivalent to setting param_name on the class.
When dynamic, not all argument values may be available.
Formats the elements of an argument set appropriately
Restore the most recently saved state.
See state_push() for more details.
Save this instance’s state.
For Parameterized instances, this includes the state of dynamically generated values.
Subclasses that maintain short-term state should additionally save and restore that state using state_push() and state_pop().
Generally, this method is used by operations that need to test something without permanently altering the objects’ state.
A succinct summary of the argument specifier. Unlike the repr, a summary does not have to be complete but must supply the most relevant information about the object to the user.
Print msg merged with args as a verbose message.
See Python’s logging module for details of message formatting.
Print msg merged with args as a warning, unless module variable warnings_as_exceptions is True, then raise an Exception containing the arguments.
See Python’s logging module for details of message formatting.
Bases: lancet.dynamic.DynamicArgs
params(output_extractor=Callable, fp_precision=Integer, name=String) [1;32mParameters of ‘DynamicConcatenate’ ================================== [0m [1;31mParameters changed from their default values are marked in red.[0m [1;36mSoft bound values are marked in cyan.[0m C/V= Constant/Variable, RO/RW = ReadOnly/ReadWrite, AN=Allow None
[1;34mName Value Type Mode [0m
fp_precision 4 Integer C RW output_extractor <function loads at 0x2b06c9b50848> Callable V RW
[1;32mParameter docstrings: =====================[0m
[1;34mfp_precision: The floating point precision to use for floating point[0m [1;34m values. Unlike other basic Python types, floats need care[0m [1;34m with their representation as you only want to display up to[0m [1;34m the precision actually specified. A floating point precision[0m [1;34m of 0 casts number to integers before representing them.[0m [1;31moutput_extractor: The function that returns the relevant data from the standard[0m [1;31m output stream dumped to file in the streams subdirectory. This[0m [1;31m information must be retyrned in a format suitable for updating[0m [1;31m the specifier.. By default uses json.loads but pickle.loads[0m [1;31m could also be a valid option. The callable must take a string[0m [1;31m and return a Python object suitable for updating the specifier.[0m
Returns the set of constant items as a list of tuples. This allows easy conversion to dictionary format. Note, the items should be supplied in the same key ordering as for constant_keys for consistency.
Convenience method to avoid using the specifier without exhausting it.
Print msg merged with args as a debugging statement.
See Python’s logging module for details of message formatting.
Return {parameter_name:parameter.default} for all non-constant Parameters.
Note that a Parameter for which instantiate==True has its default instantiated.
Return a list of name,value pairs for all Parameters of this object.
If onlychanged is True, will only return values that are not equal to the default value.
Print msg merged with args as a message.
See Python’s logging module for details of message formatting.
Deserialize s (a str or unicode instance containing a JSON document) to a Python object.
If s is a str instance and is encoded with an ASCII based encoding other than utf-8 (e.g. latin-1) then an appropriate encoding name must be specified. Encodings that are not ASCII based (such as UCS-2) are not allowed and should be decoded to unicode first.
object_hook is an optional function that will be called with the result of any object literal decode (a dict). The return value of object_hook will be used instead of the dict. This feature can be used to implement custom decoders (e.g. JSON-RPC class hinting).
object_pairs_hook is an optional function that will be called with the result of any object literal decoded with an ordered list of pairs. The return value of object_pairs_hook will be used instead of the dict. This feature can be used to implement custom decoders that rely on the order that the key and value pairs are decoded (for example, collections.OrderedDict will remember the order of insertion). If object_hook is also defined, the object_pairs_hook takes priority.
parse_float, if specified, will be called with the string of every JSON float to be decoded. By default this is equivalent to float(num_str). This can be used to use another datatype or parser for JSON floats (e.g. decimal.Decimal).
parse_int, if specified, will be called with the string of every JSON int to be decoded. By default this is equivalent to int(num_str). This can be used to use another datatype or parser for JSON integers (e.g. float).
parse_constant, if specified, will be called with one of the following strings: -Infinity, Infinity, NaN, null, true, false. This can be used to raise an exception if invalid JSON numbers are encountered.
To use a custom JSONDecoder subclass, specify it with the cls kwarg; otherwise JSONDecoder is used.
Return the Parameters of this class as the dictionary {name: parameter_object}
Includes Parameters from this class and its superclasses.
(Experimental) Pretty printed representation that may be evaluated with eval. See pprint() function for more details.
Method to define the positional arguments and keyword order for pretty printing.
Print the default values of all cls’s Parameters.
Print the values of all this object’s Parameters.
Variant of __repr__ designed for generating a runnable script.
Set the default value of param_name.
Equivalent to setting param_name on the class.
When dynamic, not all argument values may be available.
Formats the elements of an argument set appropriately
Restore the most recently saved state.
See state_push() for more details.
Save this instance’s state.
For Parameterized instances, this includes the state of dynamically generated values.
Subclasses that maintain short-term state should additionally save and restore that state using state_push() and state_pop().
Generally, this method is used by operations that need to test something without permanently altering the objects’ state.
A succinct summary of the argument specifier. Unlike the repr, a summary does not have to be complete but must supply the most relevant information about the object to the user.
Print msg merged with args as a verbose message.
See Python’s logging module for details of message formatting.
Print msg merged with args as a warning, unless module variable warnings_as_exceptions is True, then raise an Exception containing the arguments.
See Python’s logging module for details of message formatting.
Bases: lancet.dynamic.DynamicArgs
params(key=String, max_steps=Integer, start=Number, stepsize=Number, output_extractor=Callable, fp_precision=Integer, name=String)
Very simple gradient descent optimizer designed to illustrate how Dynamic Args may be implemented. This class has been deliberately kept simple to clearly illustrate how Dynamic Args may be implemented. A more practical example would likely probably make use of mature, third party optimization libraries (such as the routines offered in scipy.optimize).
This particular algorithm greedily minimizes an output value via greedy gradient descent. The local parameter space is explored by examining the change in output value when an increment or decrement of ‘stepsize’ is made in the parameter space, centered around the current position. The initial parameter is initialized with the ‘start’ value and the optimization process terminates when either a local minima/maxima has been found or when ‘max_steps’ is reached.
The ‘output_extractor’ function is expected to return a single scalar number to drive the gradient descent algorithm forwards.
[0m [1;31mParameters changed from their default values are marked in red.[0m [1;36mSoft bound values are marked in cyan.[0m C/V= Constant/Variable, RO/RW = ReadOnly/ReadWrite, AN=Allow None
[1;34mName Value Type Mode [0m
fp_precision 4 Integer C RW key ‘’ String C RW max_steps 100 Integer C RW output_extractor <function loads at 0x2b06c9b50848> Callable V RW start 0.0 Number C RW stepsize 1.0 Number C RW
[1;32mParameter docstrings: =====================[0m
[1;34mfp_precision: The floating point precision to use for floating point[0m [1;34m values. Unlike other basic Python types, floats need care[0m [1;34m with their representation as you only want to display up to[0m [1;34m the precision actually specified. A floating point precision[0m [1;34m of 0 casts number to integers before representing them.[0m [1;31mkey: The name of the argument that will be optimized in a greedy fashion.[0m [1;34mmax_steps: Once max_steps is reached, the optimization terminates.[0m [1;31moutput_extractor: The function that returns the relevant data from the standard[0m [1;31m output stream dumped to file in the streams subdirectory. This[0m [1;31m information must be retyrned in a format suitable for updating[0m [1;31m the specifier.. By default uses json.loads but pickle.loads[0m [1;31m could also be a valid option. The callable must take a string[0m [1;31m and return a Python object suitable for updating the specifier.[0m [1;34mstart: The starting argument value for the gradient ascent or descent[0m [1;31mstepsize: The size of the steps taken in parameter space.[0m
Convenience method to avoid using the specifier without exhausting it.
Print msg merged with args as a debugging statement.
See Python’s logging module for details of message formatting.
Return {parameter_name:parameter.default} for all non-constant Parameters.
Note that a Parameter for which instantiate==True has its default instantiated.
Return a list of name,value pairs for all Parameters of this object.
If onlychanged is True, will only return values that are not equal to the default value.
Print msg merged with args as a message.
See Python’s logging module for details of message formatting.
Deserialize s (a str or unicode instance containing a JSON document) to a Python object.
If s is a str instance and is encoded with an ASCII based encoding other than utf-8 (e.g. latin-1) then an appropriate encoding name must be specified. Encodings that are not ASCII based (such as UCS-2) are not allowed and should be decoded to unicode first.
object_hook is an optional function that will be called with the result of any object literal decode (a dict). The return value of object_hook will be used instead of the dict. This feature can be used to implement custom decoders (e.g. JSON-RPC class hinting).
object_pairs_hook is an optional function that will be called with the result of any object literal decoded with an ordered list of pairs. The return value of object_pairs_hook will be used instead of the dict. This feature can be used to implement custom decoders that rely on the order that the key and value pairs are decoded (for example, collections.OrderedDict will remember the order of insertion). If object_hook is also defined, the object_pairs_hook takes priority.
parse_float, if specified, will be called with the string of every JSON float to be decoded. By default this is equivalent to float(num_str). This can be used to use another datatype or parser for JSON floats (e.g. decimal.Decimal).
parse_int, if specified, will be called with the string of every JSON int to be decoded. By default this is equivalent to int(num_str). This can be used to use another datatype or parser for JSON integers (e.g. float).
parse_constant, if specified, will be called with one of the following strings: -Infinity, Infinity, NaN, null, true, false. This can be used to raise an exception if invalid JSON numbers are encountered.
To use a custom JSONDecoder subclass, specify it with the cls kwarg; otherwise JSONDecoder is used.
Return the Parameters of this class as the dictionary {name: parameter_object}
Includes Parameters from this class and its superclasses.
(Experimental) Pretty printed representation that may be evaluated with eval. See pprint() function for more details.
Method to define the positional arguments and keyword order for pretty printing.
Print the default values of all cls’s Parameters.
Print the values of all this object’s Parameters.
Variant of __repr__ designed for generating a runnable script.
Set the default value of param_name.
Equivalent to setting param_name on the class.
When dynamic, not all argument values may be available.
Formats the elements of an argument set appropriately
Restore the most recently saved state.
See state_push() for more details.
Save this instance’s state.
For Parameterized instances, this includes the state of dynamically generated values.
Subclasses that maintain short-term state should additionally save and restore that state using state_push() and state_pop().
Generally, this method is used by operations that need to test something without permanently altering the objects’ state.
Called to update the state of the iterator. This methods receives the set of task ids from the previous set of tasks together with the launch information to allow the output values to be parsed using the output_extractor. This data is then used to determine the next desired point in the parameter space by calling the _update_state method.
Print msg merged with args as a verbose message.
See Python’s logging module for details of message formatting.
Print msg merged with args as a warning, unless module variable warnings_as_exceptions is True, then raise an Exception containing the arguments.
See Python’s logging module for details of message formatting.
Bases: lancet.filetypes.FileType
params(data_fn=Callable, metadata_fn=Callable, data_key=String, directory=String, extensions=List, hash_suffix=Boolean, name=String)
A customizable FileType that takes two functions as input and maps them to the loading interface for all FileTypes.
[0m [1;31mParameters changed from their default values are marked in red.[0m [1;36mSoft bound values are marked in cyan.[0m C/V= Constant/Variable, RO/RW = ReadOnly/ReadWrite, AN=Allow None
[1;34mName Value Type Bounds Mode [0m
data_fn None Callable V RW AN data_key ‘data’ String V RW directory ‘.’ String V RW AN extensions [] List (0, None) C RW hash_suffix True Boolean (0, 1) V RW metadata_fn None Callable V RW AN
[1;32mParameter docstrings: =====================[0m
[1;34mdata_fn: A callable that takes a filename and returns a dictionary of[0m [1;34m data values[0m [1;31mdata_key: The name (key) given to the file contents if the key cannot be[0m [1;31m determined from the file itself.[0m [1;34mdirectory: Directory in which to load or save the file. Note that this[0m [1;34m is a class level parameter only.[0m [1;31mextensions: The set of supported file extensions.[0m [1;34mhash_suffix: Whether to ensure the saved filename is unique by adding a[0m [1;34m short hash suffix. Note that this is a class level parameter[0m [1;34m only.[0m [1;31mmetadata_fn: A callable that takes a filename and returns a dictionary of[0m [1;31m metadata values[0m
Print msg merged with args as a debugging statement.
See Python’s logging module for details of message formatting.
Return {parameter_name:parameter.default} for all non-constant Parameters.
Note that a Parameter for which instantiate==True has its default instantiated.
Returns a boolean indicating whether the filename has an appropriate extension for this class.
Return a list of name,value pairs for all Parameters of this object.
If onlychanged is True, will only return values that are not equal to the default value.
Print msg merged with args as a message.
See Python’s logging module for details of message formatting.
Return the Parameters of this class as the dictionary {name: parameter_object}
Includes Parameters from this class and its superclasses.
(Experimental) Pretty printed representation that may be evaluated with eval. See pprint() function for more details.
Method to define the positional arguments and keyword order for pretty printing.
Print the default values of all cls’s Parameters.
Print the values of all this object’s Parameters.
Variant of __repr__ designed for generating a runnable script.
Set the default value of param_name.
Equivalent to setting param_name on the class.
Restore the most recently saved state.
See state_push() for more details.
Save this instance’s state.
For Parameterized instances, this includes the state of dynamically generated values.
Subclasses that maintain short-term state should additionally save and restore that state using state_push() and state_pop().
Generally, this method is used by operations that need to test something without permanently altering the objects’ state.
Print msg merged with args as a verbose message.
See Python’s logging module for details of message formatting.
Print msg merged with args as a warning, unless module variable warnings_as_exceptions is True, then raise an Exception containing the arguments.
See Python’s logging module for details of message formatting.
Bases: lancet.filetypes.FileType
params(first=ClassSelector, second=ClassSelector, data_key=String, directory=String, extensions=List, hash_suffix=Boolean, name=String)
Allows a FileType out of a pair of FileTypes to handle a given file. For instance, given a mixed list of .png image filenames and .npz Numpy filenames, the ImageFile() | NumpyFile() object an handle either type of filename appropriately.
[0m [1;31mParameters changed from their default values are marked in red.[0m [1;36mSoft bound values are marked in cyan.[0m C/V= Constant/Variable, RO/RW = ReadOnly/ReadWrite, AN=Allow None
[1;34mName Value Type Bounds Mode [0m
data_key ‘data’ String V RW directory ‘.’ String V RW AN extensions [] List (0, None) C RW first None ClassSelector V RW AN hash_suffix True Boolean (0, 1) V RW second None ClassSelector V RW AN
[1;32mParameter docstrings: =====================[0m
[1;34mdata_key: The name (key) given to the file contents if the key cannot be[0m [1;34m determined from the file itself.[0m [1;31mdirectory: Directory in which to load or save the file. Note that this[0m [1;31m is a class level parameter only.[0m [1;34mextensions: The set of supported file extensions.[0m [1;31mfirst: The first potential FileType to handle a given filename.[0m [1;34mhash_suffix: Whether to ensure the saved filename is unique by adding a[0m [1;34m short hash suffix. Note that this is a class level parameter[0m [1;34m only.[0m [1;31msecond: The second potential FileType to handle a given filename.[0m
Print msg merged with args as a debugging statement.
See Python’s logging module for details of message formatting.
Return {parameter_name:parameter.default} for all non-constant Parameters.
Note that a Parameter for which instantiate==True has its default instantiated.
Returns a boolean indicating whether the filename has an appropriate extension for this class.
Return a list of name,value pairs for all Parameters of this object.
If onlychanged is True, will only return values that are not equal to the default value.
Print msg merged with args as a message.
See Python’s logging module for details of message formatting.
Return the Parameters of this class as the dictionary {name: parameter_object}
Includes Parameters from this class and its superclasses.
(Experimental) Pretty printed representation that may be evaluated with eval. See pprint() function for more details.
Method to define the positional arguments and keyword order for pretty printing.
Print the default values of all cls’s Parameters.
Print the values of all this object’s Parameters.
Variant of __repr__ designed for generating a runnable script.
Set the default value of param_name.
Equivalent to setting param_name on the class.
Restore the most recently saved state.
See state_push() for more details.
Save this instance’s state.
For Parameterized instances, this includes the state of dynamically generated values.
Subclasses that maintain short-term state should additionally save and restore that state using state_push() and state_pop().
Generally, this method is used by operations that need to test something without permanently altering the objects’ state.
Print msg merged with args as a verbose message.
See Python’s logging module for details of message formatting.
Print msg merged with args as a warning, unless module variable warnings_as_exceptions is True, then raise an Exception containing the arguments.
See Python’s logging module for details of message formatting.
Bases: lancet.core.PrettyPrinted, param.parameterized.Parameterized
params(data_key=String, directory=String, extensions=List, hash_suffix=Boolean, name=String)
The base class for all supported file types in Lancet. This class is designed to be simple and easily extensible to support new files and has only three essential methods: ‘save’, ‘data’ and ‘metadata’).
[0m [1;31mParameters changed from their default values are marked in red.[0m [1;36mSoft bound values are marked in cyan.[0m C/V= Constant/Variable, RO/RW = ReadOnly/ReadWrite, AN=Allow None
[1;34mName Value Type Bounds Mode [0m
data_key ‘data’ String V RW directory ‘.’ String V RW AN extensions [] List (0, None) C RW hash_suffix True Boolean (0, 1) V RW
[1;32mParameter docstrings: =====================[0m
[1;34mdata_key: The name (key) given to the file contents if the key cannot be[0m [1;34m determined from the file itself.[0m [1;31mdirectory: Directory in which to load or save the file. Note that this[0m [1;31m is a class level parameter only.[0m [1;34mextensions: The set of supported file extensions.[0m [1;31mhash_suffix: Whether to ensure the saved filename is unique by adding a[0m [1;31m short hash suffix. Note that this is a class level parameter[0m [1;31m only.[0m
Print msg merged with args as a debugging statement.
See Python’s logging module for details of message formatting.
Return {parameter_name:parameter.default} for all non-constant Parameters.
Note that a Parameter for which instantiate==True has its default instantiated.
Returns a boolean indicating whether the filename has an appropriate extension for this class.
Return a list of name,value pairs for all Parameters of this object.
If onlychanged is True, will only return values that are not equal to the default value.
Print msg merged with args as a message.
See Python’s logging module for details of message formatting.
Return the Parameters of this class as the dictionary {name: parameter_object}
Includes Parameters from this class and its superclasses.
(Experimental) Pretty printed representation that may be evaluated with eval. See pprint() function for more details.
Method to define the positional arguments and keyword order for pretty printing.
Print the default values of all cls’s Parameters.
Print the values of all this object’s Parameters.
The implementation in the base class simply checks there is no clash between the metadata and data keys.
Variant of __repr__ designed for generating a runnable script.
Set the default value of param_name.
Equivalent to setting param_name on the class.
Restore the most recently saved state.
See state_push() for more details.
Save this instance’s state.
For Parameterized instances, this includes the state of dynamically generated values.
Subclasses that maintain short-term state should additionally save and restore that state using state_push() and state_pop().
Generally, this method is used by operations that need to test something without permanently altering the objects’ state.
Print msg merged with args as a verbose message.
See Python’s logging module for details of message formatting.
Print msg merged with args as a warning, unless module variable warnings_as_exceptions is True, then raise an Exception containing the arguments.
See Python’s logging module for details of message formatting.
Bases: lancet.filetypes.CustomFile
params(data_fn=Callable, metadata_fn=Callable, data_key=String, directory=String, extensions=List, hash_suffix=Boolean, name=String)
FileType supporting the .hvz file format of the the HoloViews library (http://ioam.github.io/holoviews).
Equivalent to the following CustomFile:
- CustomFile(metadata_fn=lambda f: Unpickler.key(f),
- data_fn = lambda f: {e: Unpickler.load(f, [e])
- for e in Unpickler.entries(f)})
[0m [1;31mParameters changed from their default values are marked in red.[0m [1;36mSoft bound values are marked in cyan.[0m C/V= Constant/Variable, RO/RW = ReadOnly/ReadWrite, AN=Allow None
[1;34mName Value Type Bounds Mode [0m
data_fn <function hvz_data_fn at 0x2b06ccb182... Callable V RW data_key ‘data’ String V RW directory ‘.’ String V RW AN extensions [] List (0, None) C RW hash_suffix True Boolean (0, 1) V RW metadata_fn <function hvz_metadata_fn at 0x2b06cc... Callable V RW
[1;32mParameter docstrings: =====================[0m
[1;34mdata_fn: By default loads all the entries in the .hvz file using[0m [1;34m Unpickler.load and returns them as a dictionary.[0m [1;31mdata_key: The name (key) given to the file contents if the key cannot be[0m [1;31m determined from the file itself.[0m [1;34mdirectory: Directory in which to load or save the file. Note that this[0m [1;34m is a class level parameter only.[0m [1;31mextensions: The set of supported file extensions.[0m [1;34mhash_suffix: Whether to ensure the saved filename is unique by adding a[0m [1;34m short hash suffix. Note that this is a class level parameter[0m [1;34m only.[0m [1;31mmetadata_fn: Returns the key stored in the .hvz file as metadata using the[0m [1;31m Unpickler.key method.[0m
Print msg merged with args as a debugging statement.
See Python’s logging module for details of message formatting.
Return {parameter_name:parameter.default} for all non-constant Parameters.
Note that a Parameter for which instantiate==True has its default instantiated.
Returns a boolean indicating whether the filename has an appropriate extension for this class.
Return a list of name,value pairs for all Parameters of this object.
If onlychanged is True, will only return values that are not equal to the default value.
Print msg merged with args as a message.
See Python’s logging module for details of message formatting.
Return the Parameters of this class as the dictionary {name: parameter_object}
Includes Parameters from this class and its superclasses.
(Experimental) Pretty printed representation that may be evaluated with eval. See pprint() function for more details.
Method to define the positional arguments and keyword order for pretty printing.
Print the default values of all cls’s Parameters.
Print the values of all this object’s Parameters.
Variant of __repr__ designed for generating a runnable script.
Set the default value of param_name.
Equivalent to setting param_name on the class.
Restore the most recently saved state.
See state_push() for more details.
Save this instance’s state.
For Parameterized instances, this includes the state of dynamically generated values.
Subclasses that maintain short-term state should additionally save and restore that state using state_push() and state_pop().
Generally, this method is used by operations that need to test something without permanently altering the objects’ state.
Print msg merged with args as a verbose message.
See Python’s logging module for details of message formatting.
Print msg merged with args as a warning, unless module variable warnings_as_exceptions is True, then raise an Exception containing the arguments.
See Python’s logging module for details of message formatting.
Bases: lancet.filetypes.FileType
params(data_mode=ObjectSelector, image_info=Dict, data_key=String, directory=String, extensions=List, hash_suffix=Boolean, name=String)
Image support - requires PIL or Pillow.
[0m [1;31mParameters changed from their default values are marked in red.[0m [1;36mSoft bound values are marked in cyan.[0m C/V= Constant/Variable, RO/RW = ReadOnly/ReadWrite, AN=Allow None
[1;34mName Value Type Bounds Mode [0m
data_key ‘images’ String V RW data_mode ‘RGBA’ ObjectSelector V RW directory ‘.’ String V RW AN extensions [‘.png’, ‘.jpg’] List (0, None) C RW hash_suffix True Boolean (0, 1) V RW image_info {‘format’: ‘format’, ‘mode’: ‘mode’, ... Dict V RW
[1;32mParameter docstrings: =====================[0m
[1;34mdata_key: The name (key) given to the loaded image data.[0m [1;31mdata_mode: Sets the mode of the mode of the Image object. Palette[0m [1;31m mode’P is not supported[0m [1;34mdirectory: Directory in which to load or save the file. Note that this[0m [1;34m is a class level parameter only.[0m [1;31mextensions: The set of supported file extensions.[0m [1;34mhash_suffix: Whether to ensure the saved filename is unique by adding a[0m [1;34m short hash suffix. Note that this is a class level parameter[0m [1;34m only.[0m [1;31mimage_info: Dictionary of the metadata to load. Each key is the[0m [1;31m name given to the metadata item and each value is the PIL[0m [1;31m Image attribute to return.[0m
Print msg merged with args as a debugging statement.
See Python’s logging module for details of message formatting.
Return {parameter_name:parameter.default} for all non-constant Parameters.
Note that a Parameter for which instantiate==True has its default instantiated.
Returns a boolean indicating whether the filename has an appropriate extension for this class.
Return a list of name,value pairs for all Parameters of this object.
If onlychanged is True, will only return values that are not equal to the default value.
Print msg merged with args as a message.
See Python’s logging module for details of message formatting.
Return the Parameters of this class as the dictionary {name: parameter_object}
Includes Parameters from this class and its superclasses.
(Experimental) Pretty printed representation that may be evaluated with eval. See pprint() function for more details.
Method to define the positional arguments and keyword order for pretty printing.
Print the default values of all cls’s Parameters.
Print the values of all this object’s Parameters.
Variant of __repr__ designed for generating a runnable script.
Set the default value of param_name.
Equivalent to setting param_name on the class.
Restore the most recently saved state.
See state_push() for more details.
Save this instance’s state.
For Parameterized instances, this includes the state of dynamically generated values.
Subclasses that maintain short-term state should additionally save and restore that state using state_push() and state_pop().
Generally, this method is used by operations that need to test something without permanently altering the objects’ state.
Print msg merged with args as a verbose message.
See Python’s logging module for details of message formatting.
Print msg merged with args as a warning, unless module variable warnings_as_exceptions is True, then raise an Exception containing the arguments.
See Python’s logging module for details of message formatting.
Bases: lancet.filetypes.FileType
params(data_key=String, directory=String, extensions=List, hash_suffix=Boolean, name=String)
It is assumed you won’t store very large volumes of data as JSON. For this reason, the contents of JSON files are loaded as metadata.
[0m [1;31mParameters changed from their default values are marked in red.[0m [1;36mSoft bound values are marked in cyan.[0m C/V= Constant/Variable, RO/RW = ReadOnly/ReadWrite, AN=Allow None
[1;34mName Value Type Bounds Mode [0m
data_key ‘data’ String V RW directory ‘.’ String V RW AN extensions [‘.json’] List (0, None) C RW hash_suffix True Boolean (0, 1) V RW
[1;32mParameter docstrings: =====================[0m
[1;34mdata_key: The name (key) given to the file contents if the key cannot be[0m [1;34m determined from the file itself.[0m [1;31mdirectory: Directory in which to load or save the file. Note that this[0m [1;31m is a class level parameter only.[0m [1;34mextensions: The set of supported file extensions.[0m [1;31mhash_suffix: Whether to ensure the saved filename is unique by adding a[0m [1;31m short hash suffix. Note that this is a class level parameter[0m [1;31m only.[0m
Print msg merged with args as a debugging statement.
See Python’s logging module for details of message formatting.
Return {parameter_name:parameter.default} for all non-constant Parameters.
Note that a Parameter for which instantiate==True has its default instantiated.
Returns a boolean indicating whether the filename has an appropriate extension for this class.
Return a list of name,value pairs for all Parameters of this object.
If onlychanged is True, will only return values that are not equal to the default value.
Print msg merged with args as a message.
See Python’s logging module for details of message formatting.
Return the Parameters of this class as the dictionary {name: parameter_object}
Includes Parameters from this class and its superclasses.
(Experimental) Pretty printed representation that may be evaluated with eval. See pprint() function for more details.
Method to define the positional arguments and keyword order for pretty printing.
Print the default values of all cls’s Parameters.
Print the values of all this object’s Parameters.
Variant of __repr__ designed for generating a runnable script.
Set the default value of param_name.
Equivalent to setting param_name on the class.
Restore the most recently saved state.
See state_push() for more details.
Save this instance’s state.
For Parameterized instances, this includes the state of dynamically generated values.
Subclasses that maintain short-term state should additionally save and restore that state using state_push() and state_pop().
Generally, this method is used by operations that need to test something without permanently altering the objects’ state.
Print msg merged with args as a verbose message.
See Python’s logging module for details of message formatting.
Print msg merged with args as a warning, unless module variable warnings_as_exceptions is True, then raise an Exception containing the arguments.
See Python’s logging module for details of message formatting.
Bases: lancet.filetypes.FileType
params(data_key=String, directory=String, extensions=List, hash_suffix=Boolean, name=String)
Since version 1.0, Matplotlib figures support pickling. An mpkl file is simply a pickled matplotlib figure.
[0m [1;31mParameters changed from their default values are marked in red.[0m [1;36mSoft bound values are marked in cyan.[0m C/V= Constant/Variable, RO/RW = ReadOnly/ReadWrite, AN=Allow None
[1;34mName Value Type Bounds Mode [0m
data_key ‘data’ String V RW directory ‘.’ String V RW AN extensions [‘.mpkl’] List (0, None) C RW hash_suffix True Boolean (0, 1) V RW
[1;32mParameter docstrings: =====================[0m
[1;34mdata_key: The name (key) given to the file contents if the key cannot be[0m [1;34m determined from the file itself.[0m [1;31mdirectory: Directory in which to load or save the file. Note that this[0m [1;31m is a class level parameter only.[0m [1;34mextensions: The set of supported file extensions.[0m [1;31mhash_suffix: Whether to ensure the saved filename is unique by adding a[0m [1;31m short hash suffix. Note that this is a class level parameter[0m [1;31m only.[0m
Print msg merged with args as a debugging statement.
See Python’s logging module for details of message formatting.
Return {parameter_name:parameter.default} for all non-constant Parameters.
Note that a Parameter for which instantiate==True has its default instantiated.
Returns a boolean indicating whether the filename has an appropriate extension for this class.
Return a list of name,value pairs for all Parameters of this object.
If onlychanged is True, will only return values that are not equal to the default value.
Print msg merged with args as a message.
See Python’s logging module for details of message formatting.
Return the Parameters of this class as the dictionary {name: parameter_object}
Includes Parameters from this class and its superclasses.
(Experimental) Pretty printed representation that may be evaluated with eval. See pprint() function for more details.
Method to define the positional arguments and keyword order for pretty printing.
Print the default values of all cls’s Parameters.
Print the values of all this object’s Parameters.
Variant of __repr__ designed for generating a runnable script.
Set the default value of param_name.
Equivalent to setting param_name on the class.
Restore the most recently saved state.
See state_push() for more details.
Save this instance’s state.
For Parameterized instances, this includes the state of dynamically generated values.
Subclasses that maintain short-term state should additionally save and restore that state using state_push() and state_pop().
Generally, this method is used by operations that need to test something without permanently altering the objects’ state.
Print msg merged with args as a verbose message.
See Python’s logging module for details of message formatting.
Print msg merged with args as a warning, unless module variable warnings_as_exceptions is True, then raise an Exception containing the arguments.
See Python’s logging module for details of message formatting.
Bases: lancet.filetypes.FileType
params(compress=Boolean, data_key=String, directory=String, extensions=List, hash_suffix=Boolean, name=String)
An npz file is the standard way to save Numpy arrays. This is a highly flexible FileType that supports most native Python objects including Numpy arrays.
[0m [1;31mParameters changed from their default values are marked in red.[0m [1;36mSoft bound values are marked in cyan.[0m C/V= Constant/Variable, RO/RW = ReadOnly/ReadWrite, AN=Allow None
[1;34mName Value Type Bounds Mode [0m
compress True Boolean (0, 1) V RW data_key ‘data’ String V RW directory ‘.’ String V RW AN extensions [‘.npz’] List (0, None) C RW hash_suffix True Boolean (0, 1) V RW
[1;32mParameter docstrings: =====================[0m
[1;34mcompress: Whether or not the compressed npz format should be used.[0m [1;31mdata_key: The name (key) given to the file contents if the key cannot be[0m [1;31m determined from the file itself.[0m [1;34mdirectory: Directory in which to load or save the file. Note that this[0m [1;34m is a class level parameter only.[0m [1;31mextensions: The set of supported file extensions.[0m [1;34mhash_suffix: Whether to ensure the saved filename is unique by adding a[0m [1;34m short hash suffix. Note that this is a class level parameter[0m [1;34m only.[0m
Print msg merged with args as a debugging statement.
See Python’s logging module for details of message formatting.
Return {parameter_name:parameter.default} for all non-constant Parameters.
Note that a Parameter for which instantiate==True has its default instantiated.
Returns a boolean indicating whether the filename has an appropriate extension for this class.
Return a list of name,value pairs for all Parameters of this object.
If onlychanged is True, will only return values that are not equal to the default value.
Print msg merged with args as a message.
See Python’s logging module for details of message formatting.
Return the Parameters of this class as the dictionary {name: parameter_object}
Includes Parameters from this class and its superclasses.
(Experimental) Pretty printed representation that may be evaluated with eval. See pprint() function for more details.
Method to define the positional arguments and keyword order for pretty printing.
Print the default values of all cls’s Parameters.
Print the values of all this object’s Parameters.
Variant of __repr__ designed for generating a runnable script.
Set the default value of param_name.
Equivalent to setting param_name on the class.
Restore the most recently saved state.
See state_push() for more details.
Save this instance’s state.
For Parameterized instances, this includes the state of dynamically generated values.
Subclasses that maintain short-term state should additionally save and restore that state using state_push() and state_pop().
Generally, this method is used by operations that need to test something without permanently altering the objects’ state.
Print msg merged with args as a verbose message.
See Python’s logging module for details of message formatting.
Print msg merged with args as a warning, unless module variable warnings_as_exceptions is True, then raise an Exception containing the arguments.
See Python’s logging module for details of message formatting.
Bases: lancet.core.PrettyPrinted, param.parameterized.Parameterized
params(do_format=Boolean, executable=String, name=String)
A command is a way of converting the dictionaries returned by argument specifiers into a particular command. When called with an argument specifier, a command template returns a list of strings corresponding to a subprocess Popen argument list.
__call__(self, spec, tid=None, info={}):
All Commands must be callable. The tid argument is the task id and info is a dictionary of run-time information supplied by the launcher. See the _setup_launch method of Launcher to see details about the launch information supplied.
[0m [1;31mParameters changed from their default values are marked in red.[0m [1;36mSoft bound values are marked in cyan.[0m C/V= Constant/Variable, RO/RW = ReadOnly/ReadWrite, AN=Allow None
[1;34mName Value Type Bounds Mode [0m
do_format True Boolean (0, 1) V RW executable ‘python’ String C RW
[1;32mParameter docstrings: =====================[0m
[1;34mdo_format: Set to True to receive input arguments as formatted strings,[0m [1;34m False for the raw unformatted objects.[0m [1;31mexecutable: The executable that is to be run by this Command. Unless the[0m [1;31m executable is a standard command expected on the system path,[0m [1;31m this should be an absolute path. By default this invokes[0m [1;31m python or the python environment used to invoke the Command[0m [1;31m (Topographica for instance).[0m
Print msg merged with args as a debugging statement.
See Python’s logging module for details of message formatting.
Return {parameter_name:parameter.default} for all non-constant Parameters.
Note that a Parameter for which instantiate==True has its default instantiated.
Optional method that allows a Command to save state before launch. The info argument is supplied by the Launcher.
Return a list of name,value pairs for all Parameters of this object.
If onlychanged is True, will only return values that are not equal to the default value.
Print msg merged with args as a message.
See Python’s logging module for details of message formatting.
Return the Parameters of this class as the dictionary {name: parameter_object}
Includes Parameters from this class and its superclasses.
(Experimental) Pretty printed representation that may be evaluated with eval. See pprint() function for more details.
Method to define the positional arguments and keyword order for pretty printing.
Print the default values of all cls’s Parameters.
Print the values of all this object’s Parameters.
Variant of __repr__ designed for generating a runnable script.
Set the default value of param_name.
Equivalent to setting param_name on the class.
Write to file_handle if supplied, othewise print output
Restore the most recently saved state.
See state_push() for more details.
Save this instance’s state.
For Parameterized instances, this includes the state of dynamically generated values.
Subclasses that maintain short-term state should additionally save and restore that state using state_push() and state_pop().
Generally, this method is used by operations that need to test something without permanently altering the objects’ state.
A succinct summary of the Command configuration. Unlike the repr, a summary does not have to be complete but must supply key information relevant to the user. Must begin by stating the executable.
Print msg merged with args as a verbose message.
See Python’s logging module for details of message formatting.
Optional, final check that ensures valid arguments have been passed before launch. Allows the constant and varying_keys to be be checked and can inspect the specs attribute if an instance of Args. If invalid, raise an Exception with the appropriate error message, otherwise return None.
Print msg merged with args as a warning, unless module variable warnings_as_exceptions is True, then raise an Exception containing the arguments.
See Python’s logging module for details of message formatting.
Bases: lancet.core.PrettyPrinted, param.parameterized.Parameterized
params(args=ClassSelector, batch_name=String, command=ClassSelector, description=String, max_concurrency=Integer, metadata=Dict, output_directory=String, reduction_fn=Callable, subdir=List, tag=String, timestamp=NumericTuple, timestamp_format=String, name=String)
A Launcher is constructed using a name, an argument specifier and a command template. It can then launch the corresponding tasks appropriately when invoked.
This default Launcher uses subprocess to launch tasks. It is intended to illustrate the basic design and should be used as a base class for more complex Launchers. In particular all Launchers should retain the same behaviour of writing stdout/stderr to the streams directory, writing a log file and recording launch information.
[0m [1;31mParameters changed from their default values are marked in red.[0m [1;36mSoft bound values are marked in cyan.[0m C/V= Constant/Variable, RO/RW = ReadOnly/ReadWrite, AN=Allow None
[1;34mName Value Type Bounds Mode [0m
args None ClassSelector C RW AN batch_name None String C RW AN command None ClassSelector C RW AN description ‘’ String V RW max_concurrency 2 Integer V RW AN metadata {} Dict V RW output_directory ‘.’ String V RW reduction_fn None Callable V RW AN subdir [] List (0, None) V RW tag ‘’ String V RW timestamp (0, 0, 0, 0, 0, 0, 0, 0, 0) NumericTuple V RW timestamp_format ‘%Y-%m-%d_%H%M’ String V RW AN
[1;32mParameter docstrings: =====================[0m
[1;34margs: The specifier used to generate the varying parameters for the tasks.[0m [1;31mbatch_name: A unique identifier for the current batch[0m [1;34mcommand: The command template used to generate the commands for the current tasks.[0m [1;31mdescription: A short description of the purpose of the current set of tasks.[0m [1;34mmax_concurrency: Concurrency limit to impose on the launch. As the current class[0m [1;34m uses subprocess locally, multiple processes are possible at[0m [1;34m once. Set to None for no limit (eg. for clusters)[0m [1;31mmetadata: Metadata information to add to the info file.[0m [1;34moutput_directory: The output directory - the directory that will contain all[0m [1;34m the root directories for the individual launches.[0m [1;31mreduction_fn: A callable that will be invoked when the Launcher has completed[0m [1;31m all tasks. For example, this could inform the user of completion[0m [1;31m (eg. send an e-mail) among other possibilities.[0m [1;34msubdir: A list of subdirectory names that allows custom organization[0m [1;34m within the output directory before the root directory.[0m [1;31mtag: A very short, identifiable human-readable string that[0m [1;31m meaningfully describes the batch to be executed. Should not[0m [1;31m include spaces as it may be used in filenames.[0m [1;34mtimestamp: Optional override of timestamp (default timestamp set on launch[0m [1;34m call) in Python struct_time 9-tuple format. Useful when you[0m [1;34m need to have a known root_directory path (see root_directory[0m [1;34m documentation) before launch. For example, you should store[0m [1;34m state related to analysis (eg. pickles) in the same location as[0m [1;34m everything else.[0m [1;31mtimestamp_format: The timestamp format for the root directories in python datetime[0m [1;31m format. If None, the timestamp is omitted from root directory[0m [1;31m name.[0m
Print msg merged with args as a debugging statement.
See Python’s logging module for details of message formatting.
Return {parameter_name:parameter.default} for all non-constant Parameters.
Note that a Parameter for which instantiate==True has its default instantiated.
Return a list of name,value pairs for all Parameters of this object.
If onlychanged is True, will only return values that are not equal to the default value.
A helper method that supplies the root directory name given a timestamp.
Print msg merged with args as a message.
See Python’s logging module for details of message formatting.
Return the Parameters of this class as the dictionary {name: parameter_object}
Includes Parameters from this class and its superclasses.
(Experimental) Pretty printed representation that may be evaluated with eval. See pprint() function for more details.
Method to define the positional arguments and keyword order for pretty printing.
Print the default values of all cls’s Parameters.
Print the values of all this object’s Parameters.
Variant of __repr__ designed for generating a runnable script.
Set the default value of param_name.
Equivalent to setting param_name on the class.
Restore the most recently saved state.
See state_push() for more details.
Save this instance’s state.
For Parameterized instances, this includes the state of dynamically generated values.
Subclasses that maintain short-term state should additionally save and restore that state using state_push() and state_pop().
Generally, this method is used by operations that need to test something without permanently altering the objects’ state.
A succinct summary of the Launcher configuration. Unlike the repr, a summary does not have to be complete but must supply key information relevant to the user.
Print msg merged with args as a verbose message.
See Python’s logging module for details of message formatting.
Print msg merged with args as a warning, unless module variable warnings_as_exceptions is True, then raise an Exception containing the arguments.
See Python’s logging module for details of message formatting.
Bases: param.parameterized.Parameterized
params(expansions=Dict, output_dir=String, name=String) A convenience class to help collect the generated outputs from an
invocation of a Launcher (which is called a “launch”).
Given an output directory, the object reads the log file, info file and provides easy access to the output streams for each of the launches.
The Launch information for each launch is stored in a namedtuple called LaunchInfo which has the following fields:
'timestamp', 'path', 'tids', 'specs', 'stdout', 'stderr', 'log', 'info'If there are any expansions specified (see the ShellCommand’s expansions parameter), those are also added to the named tuple.
Here is an example of using the class:
>> output = Output('output') >> len(output) 2 >> output[-1]._fields # the fields of the namedtuple. ('timestamp', 'path', 'tids', 'specs', 'stdout', 'stderr', 'log', 'info') >> output[-1].path # the path of the last run. u'/tmp/output/2015-06-21_0325-prime_quintuplet' >> len(output[-1].specs) # spec the arguments for each case. 16 >> output[-1].specs[-1] {'integer': 115} >> len(output[1].stdout) # the path to the stdout for each case. 16 >> open(output[1].stdout[-1]).read() '109: 109
‘
One can iterate over the LaunchInfo for the launches like so:
>> for li in output: .. print(li.path) .. /tmp/output/2015-06-21_0315-prime_quintuplet /tmp/output/2015-06-21_0325-prime_quintuplet
[0m [1;31mParameters changed from their default values are marked in red.[0m [1;36mSoft bound values are marked in cyan.[0m C/V= Constant/Variable, RO/RW = ReadOnly/ReadWrite, AN=Allow None
[1;34mName Value Type Mode [0m
expansions {} Dict C RW output_dir ‘.’ String V RW
[1;32mParameter docstrings: =====================[0m
[1;34mexpansions: Perform expansions (analogous to a ShellCommand) given a callable.[0m [1;34m Allows extension of the specification that supports callables that[0m [1;34m expand to valid argument values. The callable must have the signature[0m [1;34m (spec, info, tid). A typical usage for a function value is to build a[0m [1;34m valid output filename given the context.[0m [1;34m [0m [1;34m See the ShellCommand.RootDirectory, ShellCommand.LongFilename and[0m [1;34m ShellCommand.Expand.[0m [1;31moutput_dir: The output directory - the directory that will contain all[0m [1;31m the root directories for the individual launches.[0m
Print msg merged with args as a debugging statement.
See Python’s logging module for details of message formatting.
Return {parameter_name:parameter.default} for all non-constant Parameters.
Note that a Parameter for which instantiate==True has its default instantiated.
Return a list of name,value pairs for all Parameters of this object.
If onlychanged is True, will only return values that are not equal to the default value.
Print msg merged with args as a message.
See Python’s logging module for details of message formatting.
Return the Parameters of this class as the dictionary {name: parameter_object}
Includes Parameters from this class and its superclasses.
(Experimental) Pretty printed representation that may be evaluated with eval. See pprint() function for more details.
Print the default values of all cls’s Parameters.
Print the values of all this object’s Parameters.
Variant of __repr__ designed for generating a runnable script.
Set the default value of param_name.
Equivalent to setting param_name on the class.
Restore the most recently saved state.
See state_push() for more details.
Save this instance’s state.
For Parameterized instances, this includes the state of dynamically generated values.
Subclasses that maintain short-term state should additionally save and restore that state using state_push() and state_pop().
Generally, this method is used by operations that need to test something without permanently altering the objects’ state.
Print msg merged with args as a verbose message.
See Python’s logging module for details of message formatting.
Print msg merged with args as a warning, unless module variable warnings_as_exceptions is True, then raise an Exception containing the arguments.
See Python’s logging module for details of message formatting.
Bases: lancet.launch.Launcher
params(qsub_flag_options=Dict, qsub_switches=List, args=ClassSelector, batch_name=String, command=ClassSelector, description=String, max_concurrency=Integer, metadata=Dict, output_directory=String, reduction_fn=Callable, subdir=List, tag=String, timestamp=NumericTuple, timestamp_format=String, name=String)
Launcher that operates with Grid Engine using default arguments chosen to be suitable for a typical cluster (tested on the Edinburgh University Eddie cluster).
One of the main features of this class is that it is non-blocking - it alway exits shortly after invoking qsub. This means that the script is not left running or waiting for long periods of time.
By convention the standard output and error streams go to the corresponding folders in the ‘streams’ subfolder of the root directory - any -o or -e qsub options will be overridden. The job name (the -N flag) is specified automatically and any user value will be ignored.
[0m [1;31mParameters changed from their default values are marked in red.[0m [1;36mSoft bound values are marked in cyan.[0m C/V= Constant/Variable, RO/RW = ReadOnly/ReadWrite, AN=Allow None
[1;34mName Value Type Bounds Mode [0m
args None ClassSelector C RW AN batch_name None String C RW AN command None ClassSelector C RW AN description ‘’ String V RW max_concurrency 2 Integer V RW AN metadata {} Dict V RW output_directory ‘.’ String V RW qsub_flag_options {‘-b’: ‘y’} Dict V RW qsub_switches [‘-V’, ‘-cwd’] List (0, None) V RW reduction_fn None Callable V RW AN subdir [] List (0, None) V RW tag ‘’ String V RW timestamp (0, 0, 0, 0, 0, 0, 0, 0, 0) NumericTuple V RW timestamp_format ‘%Y-%m-%d_%H%M’ String V RW AN
[1;32mParameter docstrings: =====================[0m
[1;34margs: The specifier used to generate the varying parameters for the tasks.[0m [1;31mbatch_name: A unique identifier for the current batch[0m [1;34mcommand: The command template used to generate the commands for the current tasks.[0m [1;31mdescription: A short description of the purpose of the current set of tasks.[0m [1;34mmax_concurrency: Concurrency limit to impose on the launch. As the current class[0m [1;34m uses subprocess locally, multiple processes are possible at[0m [1;34m once. Set to None for no limit (eg. for clusters)[0m [1;31mmetadata: Metadata information to add to the info file.[0m [1;34moutput_directory: The output directory - the directory that will contain all[0m [1;34m the root directories for the individual launches.[0m [1;31mqsub_flag_options: Specifies qsub flags and their corresponding options as a[0m [1;31m dictionary. Valid values may be strings or lists of string. If[0m [1;31m a plain Python dictionary is used, the keys arealphanumerically[0m [1;31m sorted, otherwise the dictionary is assumed to be an[0m [1;31m OrderedDict (Python 2.7+ or param.external.OrderedDict) and the[0m [1;31m key ordering will be preserved.[0m [1;31m [0m [1;31m By default the -b (binary) flag is set to ‘y’ to allow binaries[0m [1;31m to be directly invoked. Note that the ‘-‘ is added to the key[0m [1;31m if missing (to make into a valid flag) so you can specify using[0m [1;31m keywords in the dict constructor: ie. using[0m [1;31m qsub_flag_options=dict(key1=value1, key2=value2, ....)[0m [1;34mqsub_switches: Specifies the qsub switches (flags without arguments) as a list[0m [1;34m of strings. By default the -V switch is used to exports all[0m [1;34m environment variables in the host environment to the batch job.[0m [1;31mreduction_fn: A callable that will be invoked when the Launcher has completed[0m [1;31m all tasks. For example, this could inform the user of completion[0m [1;31m (eg. send an e-mail) among other possibilities.[0m [1;34msubdir: A list of subdirectory names that allows custom organization[0m [1;34m within the output directory before the root directory.[0m [1;31mtag: A very short, identifiable human-readable string that[0m [1;31m meaningfully describes the batch to be executed. Should not[0m [1;31m include spaces as it may be used in filenames.[0m [1;34mtimestamp: Optional override of timestamp (default timestamp set on launch[0m [1;34m call) in Python struct_time 9-tuple format. Useful when you[0m [1;34m need to have a known root_directory path (see root_directory[0m [1;34m documentation) before launch. For example, you should store[0m [1;34m state related to analysis (eg. pickles) in the same location as[0m [1;34m everything else.[0m [1;31mtimestamp_format: The timestamp format for the root directories in python datetime[0m [1;31m format. If None, the timestamp is omitted from root directory[0m [1;31m name.[0m
Method that collates the previous jobs and launches the next block of concurrent jobs when using DynamicArgs. This method is invoked on initial launch and then subsequently via a commandline call (to Python via qsub) to collate the previously run jobs and launch the next block of jobs.
Print msg merged with args as a debugging statement.
See Python’s logging module for details of message formatting.
Return {parameter_name:parameter.default} for all non-constant Parameters.
Note that a Parameter for which instantiate==True has its default instantiated.
Return a list of name,value pairs for all Parameters of this object.
If onlychanged is True, will only return values that are not equal to the default value.
A helper method that supplies the root directory name given a timestamp.
Print msg merged with args as a message.
See Python’s logging module for details of message formatting.
Return the Parameters of this class as the dictionary {name: parameter_object}
Includes Parameters from this class and its superclasses.
(Experimental) Pretty printed representation that may be evaluated with eval. See pprint() function for more details.
Method to define the positional arguments and keyword order for pretty printing.
Print the default values of all cls’s Parameters.
Print the values of all this object’s Parameters.
Runs qdel command to remove all remaining queued jobs using the <batch_name>* pattern . Necessary when StopIteration is raised with scheduled jobs left on the queue. Returns exit-code of qdel.
Variant of __repr__ designed for generating a runnable script.
Set the default value of param_name.
Equivalent to setting param_name on the class.
Restore the most recently saved state.
See state_push() for more details.
Save this instance’s state.
For Parameterized instances, this includes the state of dynamically generated values.
Subclasses that maintain short-term state should additionally save and restore that state using state_push() and state_pop().
Generally, this method is used by operations that need to test something without permanently altering the objects’ state.
A succinct summary of the Launcher configuration. Unlike the repr, a summary does not have to be complete but must supply key information relevant to the user.
Print msg merged with args as a verbose message.
See Python’s logging module for details of message formatting.
Print msg merged with args as a warning, unless module variable warnings_as_exceptions is True, then raise an Exception containing the arguments.
See Python’s logging module for details of message formatting.
Bases: lancet.launch.Launcher
params(json_name=String, script_path=String, args=ClassSelector, batch_name=String, command=ClassSelector, description=String, max_concurrency=Integer, metadata=Dict, output_directory=String, reduction_fn=Callable, subdir=List, tag=String, timestamp=NumericTuple, timestamp_format=String, name=String)
Script-based launcher. Calls a script with a path to a JSON file containing process group job options. This easily supports more environment-specific job-submission schemes without having to create a new Launcher every time.
[0m [1;31mParameters changed from their default values are marked in red.[0m [1;36mSoft bound values are marked in cyan.[0m C/V= Constant/Variable, RO/RW = ReadOnly/ReadWrite, AN=Allow None
[1;34mName Value Type Bounds Mode [0m
args None ClassSelector C RW AN batch_name None String C RW AN command None ClassSelector C RW AN description ‘’ String V RW json_name ‘processes_%s.json’ String V RW max_concurrency 2 Integer V RW AN metadata {} Dict V RW output_directory ‘.’ String V RW reduction_fn None Callable V RW AN script_path ‘/var/lib/buildbot/slaves/lancet_docs... String V RW subdir [] List (0, None) V RW tag ‘’ String V RW timestamp (0, 0, 0, 0, 0, 0, 0, 0, 0) NumericTuple V RW timestamp_format ‘%Y-%m-%d_%H%M’ String V RW AN
[1;32mParameter docstrings: =====================[0m
[1;34margs: The specifier used to generate the varying parameters for the tasks.[0m [1;31mbatch_name: A unique identifier for the current batch[0m [1;34mcommand: The command template used to generate the commands for the current tasks.[0m [1;31mdescription: A short description of the purpose of the current set of tasks.[0m [1;34mjson_name: Name of the JSON file output per process group.[0m [1;31mmax_concurrency: Concurrency limit to impose on the launch. As the current class[0m [1;31m uses subprocess locally, multiple processes are possible at[0m [1;31m once. Set to None for no limit (eg. for clusters)[0m [1;34mmetadata: Metadata information to add to the info file.[0m [1;31moutput_directory: The output directory - the directory that will contain all[0m [1;31m the root directories for the individual launches.[0m [1;34mreduction_fn: A callable that will be invoked when the Launcher has completed[0m [1;34m all tasks. For example, this could inform the user of completion[0m [1;34m (eg. send an e-mail) among other possibilities.[0m [1;31mscript_path: Path to script which is called for every group, with JSON file,[0m [1;31m batch_name, number of commands for this group and max_concurrency as[0m [1;31m arguments.[0m [1;34msubdir: A list of subdirectory names that allows custom organization[0m [1;34m within the output directory before the root directory.[0m [1;31mtag: A very short, identifiable human-readable string that[0m [1;31m meaningfully describes the batch to be executed. Should not[0m [1;31m include spaces as it may be used in filenames.[0m [1;34mtimestamp: Optional override of timestamp (default timestamp set on launch[0m [1;34m call) in Python struct_time 9-tuple format. Useful when you[0m [1;34m need to have a known root_directory path (see root_directory[0m [1;34m documentation) before launch. For example, you should store[0m [1;34m state related to analysis (eg. pickles) in the same location as[0m [1;34m everything else.[0m [1;31mtimestamp_format: The timestamp format for the root directories in python datetime[0m [1;31m format. If None, the timestamp is omitted from root directory[0m [1;31m name.[0m
Print msg merged with args as a debugging statement.
See Python’s logging module for details of message formatting.
Return {parameter_name:parameter.default} for all non-constant Parameters.
Note that a Parameter for which instantiate==True has its default instantiated.
Return a list of name,value pairs for all Parameters of this object.
If onlychanged is True, will only return values that are not equal to the default value.
A helper method that supplies the root directory name given a timestamp.
Print msg merged with args as a message.
See Python’s logging module for details of message formatting.
Return the Parameters of this class as the dictionary {name: parameter_object}
Includes Parameters from this class and its superclasses.
(Experimental) Pretty printed representation that may be evaluated with eval. See pprint() function for more details.
Method to define the positional arguments and keyword order for pretty printing.
Print the default values of all cls’s Parameters.
Print the values of all this object’s Parameters.
Variant of __repr__ designed for generating a runnable script.
Set the default value of param_name.
Equivalent to setting param_name on the class.
Restore the most recently saved state.
See state_push() for more details.
Save this instance’s state.
For Parameterized instances, this includes the state of dynamically generated values.
Subclasses that maintain short-term state should additionally save and restore that state using state_push() and state_pop().
Generally, this method is used by operations that need to test something without permanently altering the objects’ state.
A succinct summary of the Launcher configuration. Unlike the repr, a summary does not have to be complete but must supply key information relevant to the user.
Print msg merged with args as a verbose message.
See Python’s logging module for details of message formatting.
Print msg merged with args as a warning, unless module variable warnings_as_exceptions is True, then raise an Exception containing the arguments.
See Python’s logging module for details of message formatting.
Bases: lancet.launch.Command
params(expansions=Dict, long_prefix=String, posargs=List, short_prefix=String, do_format=Boolean, executable=String, name=String)
A generic Command that can be used to invoke shell commands on most operating systems where Python can be run. By default, follows the GNU coding convention for commandline arguments.
[0m [1;31mParameters changed from their default values are marked in red.[0m [1;36mSoft bound values are marked in cyan.[0m C/V= Constant/Variable, RO/RW = ReadOnly/ReadWrite, AN=Allow None
[1;34mName Value Type Bounds Mode [0m
do_format True Boolean (0, 1) V RW executable ‘python’ String C RW expansions {} Dict C RW long_prefix ‘–’ String C RW posargs [] List (0, None) C RW short_prefix ‘-‘ String C RW
[1;32mParameter docstrings: =====================[0m
[1;34mdo_format: Set to True to receive input arguments as formatted strings,[0m [1;34m False for the raw unformatted objects.[0m [1;31mexecutable: The executable that is to be run by this Command. Unless the[0m [1;31m executable is a standard command expected on the system path,[0m [1;31m this should be an absolute path. By default this invokes[0m [1;31m python or the python environment used to invoke the Command[0m [1;31m (Topographica for instance).[0m [1;34mexpansions: Allows extension of the specification that supports functions[0m [1;34m that expand to valid argument values. If a function is used,[0m [1;34m it must have the signature (spec, info, tid). A typical usage[0m [1;34m for a function value is to build a valid output filename given[0m [1;34m the context.[0m [1;34m [0m [1;34m Three such subclasses are provided:[0m [1;34m ‘RootDirectory’, ‘LongFilename’ and ‘Expand’.[0m [1;31mlong_prefix: Although the double dash is a GNU coding convention, some[0m [1;31m applications use single dashes for long options.[0m [1;34mposargs: The list of positional argument keys. Positional arguments are[0m [1;34m always supplied at the end of a command in the order given.[0m [1;31mshort_prefix: Although the single dash is a GNU coding convention, the[0m [1;31m argument prefix may depend on the applications and/or platform.[0m
Bases: object
Takes a new-style format string template and expands it out using the keys in the spec, info and tid.
Bases: object
Generates a long filename based on the input arguments in the root directory with the given extension. Ignores constant items.
Print msg merged with args as a debugging statement.
See Python’s logging module for details of message formatting.
Return {parameter_name:parameter.default} for all non-constant Parameters.
Note that a Parameter for which instantiate==True has its default instantiated.
Optional method that allows a Command to save state before launch. The info argument is supplied by the Launcher.
Return a list of name,value pairs for all Parameters of this object.
If onlychanged is True, will only return values that are not equal to the default value.
Print msg merged with args as a message.
See Python’s logging module for details of message formatting.
Return the Parameters of this class as the dictionary {name: parameter_object}
Includes Parameters from this class and its superclasses.
(Experimental) Pretty printed representation that may be evaluated with eval. See pprint() function for more details.
Method to define the positional arguments and keyword order for pretty printing.
Print the default values of all cls’s Parameters.
Print the values of all this object’s Parameters.
Variant of __repr__ designed for generating a runnable script.
Set the default value of param_name.
Equivalent to setting param_name on the class.
Write to file_handle if supplied, othewise print output
Restore the most recently saved state.
See state_push() for more details.
Save this instance’s state.
For Parameterized instances, this includes the state of dynamically generated values.
Subclasses that maintain short-term state should additionally save and restore that state using state_push() and state_pop().
Generally, this method is used by operations that need to test something without permanently altering the objects’ state.
Print msg merged with args as a verbose message.
See Python’s logging module for details of message formatting.
Optional, final check that ensures valid arguments have been passed before launch. Allows the constant and varying_keys to be be checked and can inspect the specs attribute if an instance of Args. If invalid, raise an Exception with the appropriate error message, otherwise return None.
Print msg merged with args as a warning, unless module variable warnings_as_exceptions is True, then raise an Exception containing the arguments.
See Python’s logging module for details of message formatting.
Bases: lancet.core.PrettyPrinted, param.parameterized.Parameterized
params(launch_args=ClassSelector, launch_fn=Callable, output_directory=String, review=Boolean, name=String)
A helper decorator that always checks for consistency and can prompt the user for a full review of the launch configuration.
[0m [1;31mParameters changed from their default values are marked in red.[0m [1;36mSoft bound values are marked in cyan.[0m C/V= Constant/Variable, RO/RW = ReadOnly/ReadWrite, AN=Allow None
[1;34mName Value Type Bounds Mode [0m
launch_args None ClassSelector V RW AN launch_fn None Callable V RW AN output_directory ‘.’ String V RW review True Boolean (0, 1) V RW
[1;32mParameter docstrings: =====================[0m
[1;34mlaunch_args: An optional argument specifier to[0m [1;34m parameterise lancet, allowing multi-launch scripts. For[0m [1;34m instance, this may be useful for collecting statistics over[0m [1;34m runs that are not deterministic or are affected by a random[0m [1;34m input seed.[0m [1;31mlaunch_fn: The function that is to be decorated.[0m [1;34moutput_directory: The output directory - the directory that will contain all[0m [1;34m the root directories for the individual launches.[0m [1;31mreview: Whether or not to perform a detailed review of the launch.[0m
Print msg merged with args as a debugging statement.
See Python’s logging module for details of message formatting.
Return {parameter_name:parameter.default} for all non-constant Parameters.
Note that a Parameter for which instantiate==True has its default instantiated.
Return a list of name,value pairs for all Parameters of this object.
If onlychanged is True, will only return values that are not equal to the default value.
Helper to prompt the user for input on the commandline.
Print msg merged with args as a message.
See Python’s logging module for details of message formatting.
Return the Parameters of this class as the dictionary {name: parameter_object}
Includes Parameters from this class and its superclasses.
(Experimental) Pretty printed representation that may be evaluated with eval. See pprint() function for more details.
Method to define the positional arguments and keyword order for pretty printing.
Print the default values of all cls’s Parameters.
Print the values of all this object’s Parameters.
Reviews the given argument specification. Can review the meta-arguments (launch_args) or the arguments themselves.
Variant of __repr__ designed for generating a runnable script.
Set the default value of param_name.
Equivalent to setting param_name on the class.
Restore the most recently saved state.
See state_push() for more details.
Save this instance’s state.
For Parameterized instances, this includes the state of dynamically generated values.
Subclasses that maintain short-term state should additionally save and restore that state using state_push() and state_pop().
Generally, this method is used by operations that need to test something without permanently altering the objects’ state.
Print msg merged with args as a verbose message.
See Python’s logging module for details of message formatting.
Print msg merged with args as a warning, unless module variable warnings_as_exceptions is True, then raise an Exception containing the arguments.
See Python’s logging module for details of message formatting.