Utilities for using AWS (
Write logs for all jobs with given the status to files.
get_batch_command(command_list, project=None, purpose=None)¶
Get the command appropriate for running something on batch.
get_job_log(job_info, log_group_name='/aws/batch/job', write_file=True, verbose=False)¶
Gets the Cloudwatch log associated with the given job.
- job_info (dict) – dict containing entries for ‘jobName’ and ‘jobId’, e.g., as returned by get_jobs()
- log_group_name (string) – Name of the log group; defaults to ‘/aws/batch/job’
- write_file (boolean) – If True, writes the downloaded log to a text file with the filename ‘%s_%s.log’ % (job_name, job_id)
The event messages in the log, with the earliest events listed first.
list of strings
Returns a list of dicts with jobName and jobId for each job with the given status.
get_log_by_name(log_group_name, log_stream_name, out_file=None, verbose=True)¶
Download a log given the log’s group and stream name.
- log_group_name (str) – The name of the log group, e.g. /aws/batch/job.
- log_stream_name (str) – The name of the log stream, e.g. run_reach_jobdef/default/<UUID>
lines – The lines of the log as a list.
get_s3_file_tree(s3, bucket, prefix)¶
Overcome s3 response limit and return NestedDict tree of paths.
The NestedDict object also allows the user to search by the ends of a path.
The tree mimics a file directory structure, with the leave nodes being the full unbroken key. For example, ‘path/to/file.txt’ would be retrieved byret[‘path’][‘to’][‘file.txt’][‘key’]
The NestedDict object returned also has the capability to get paths that lead to a certain value. So if you wanted all paths that lead to something called ‘file.txt’, you could useret.get_paths(‘file.txt’)
For more details, see the NestedDict docs.
kill_all(job_queue, reason='None given', states=None)¶
Terminates/cancels all RUNNING, RUNNABLE, and STARTING jobs.
Tag a single ec2 instance.
Function run when indra is used in an EC2 instance to apply tags.
A utility to get the INDRA version (
This tool provides a uniform method for createing a robust indra version string, both from within python and from commandline. If possible, the version will include the git commit hash. Otherwise, the version will be marked with ‘UNHASHED’.
Get a dict with useful git info.
Get an indra version string, including a git hash.
A simple utility to get graphs from kappa (
Return pygraphviz Agraph from Kappy’s contact map JSON.
Parameters: im_json (dict) – A JSON dict which contains a contact map generated by Kappy. Returns: graph – A graph representing the contact map. Return type: pygraphviz.Agraph
Return networkx graph from Kappy’s influence map JSON.
Parameters: im_json (dict) – A JSON dict which contains an influence map generated by Kappy. Returns: graph – A graph representing the influence map. Return type: networkx.MultiDiGraph
Define NestedDict (
A dict-like object that recursively populates elements of a dict.
More specifically, this acts like a recursive defaultdict, allowing, for example:
>> nd = NestedDict() >> nd[‘a’][‘b’][‘c’] = ‘foo’
In addition, useful methods have been defined that allow the user to search the data structure. Note that the are not particularly optimized methods at this time. However, for convenience, you can for example simply call get_path to get the path to a particular key:
>> nd.get_path(‘c’) ((‘a’, ‘b’, ‘c’), ‘foo’)
and the value at that key. Similarly:
>> nd.get_path(‘b’) ((‘a’, ‘b’), NestedDict(‘c’: ‘foo’
get, gets, and get_paths operate on similar principles, and are documented below.
Convert this into an ordinary dict (of dicts).
Find the first value within the tree which has the key.
Get the deepest entries as a flat set.
Like get, but also return the path taken to the value.
Like gets, but include the paths, like get_path for all matches.
Like get, but return all matches, not just the first.
Some shorthands for plot formatting (
format_axis(ax, label_padding=2, tick_padding=0, yticks_position='left')¶
Set standardized axis formatting for figure.
Set standardized font properties for figure.