repo
stringlengths
7
55
path
stringlengths
4
223
func_name
stringlengths
1
134
original_string
stringlengths
75
104k
language
stringclasses
1 value
code
stringlengths
75
104k
code_tokens
listlengths
19
28.4k
docstring
stringlengths
1
46.9k
docstring_tokens
listlengths
1
1.97k
sha
stringlengths
40
40
url
stringlengths
87
315
partition
stringclasses
3 values
summary
stringlengths
4
350
melizalab/arf
arf.py
append_data
def append_data(dset, data): """Append data to dset along axis 0. Data must be a single element or a 1D array of the same type as the dataset (including compound datatypes).""" N = data.shape[0] if hasattr(data, 'shape') else 1 if N == 0: return oldlen = dset.shape[0] newlen = oldlen + N...
python
def append_data(dset, data): """Append data to dset along axis 0. Data must be a single element or a 1D array of the same type as the dataset (including compound datatypes).""" N = data.shape[0] if hasattr(data, 'shape') else 1 if N == 0: return oldlen = dset.shape[0] newlen = oldlen + N...
[ "def", "append_data", "(", "dset", ",", "data", ")", ":", "N", "=", "data", ".", "shape", "[", "0", "]", "if", "hasattr", "(", "data", ",", "'shape'", ")", "else", "1", "if", "N", "==", "0", ":", "return", "oldlen", "=", "dset", ".", "shape", "...
Append data to dset along axis 0. Data must be a single element or a 1D array of the same type as the dataset (including compound datatypes).
[ "Append", "data", "to", "dset", "along", "axis", "0", ".", "Data", "must", "be", "a", "single", "element", "or", "a", "1D", "array", "of", "the", "same", "type", "as", "the", "dataset", "(", "including", "compound", "datatypes", ")", "." ]
71746d9edbe7993a783d4acaf84b9631f3230283
https://github.com/melizalab/arf/blob/71746d9edbe7993a783d4acaf84b9631f3230283/arf.py#L192-L201
train
Append data to dset along axis 0.
melizalab/arf
arf.py
check_file_version
def check_file_version(file): """Check the ARF version attribute of file for compatibility. Raises DeprecationWarning for backwards-incompatible files, FutureWarning for (potentially) forwards-incompatible files, and UserWarning for files that may not have been created by an ARF library. Returns t...
python
def check_file_version(file): """Check the ARF version attribute of file for compatibility. Raises DeprecationWarning for backwards-incompatible files, FutureWarning for (potentially) forwards-incompatible files, and UserWarning for files that may not have been created by an ARF library. Returns t...
[ "def", "check_file_version", "(", "file", ")", ":", "from", "distutils", ".", "version", "import", "StrictVersion", "as", "Version", "try", ":", "ver", "=", "file", ".", "attrs", ".", "get", "(", "'arf_version'", ",", "None", ")", "if", "ver", "is", "Non...
Check the ARF version attribute of file for compatibility. Raises DeprecationWarning for backwards-incompatible files, FutureWarning for (potentially) forwards-incompatible files, and UserWarning for files that may not have been created by an ARF library. Returns the version for the file
[ "Check", "the", "ARF", "version", "attribute", "of", "file", "for", "compatibility", "." ]
71746d9edbe7993a783d4acaf84b9631f3230283
https://github.com/melizalab/arf/blob/71746d9edbe7993a783d4acaf84b9631f3230283/arf.py#L204-L238
train
Checks the ARF version attribute of file for compatibility.
melizalab/arf
arf.py
set_attributes
def set_attributes(node, overwrite=True, **attributes): """Set multiple attributes on node. If overwrite is False, and the attribute already exists, does nothing. If the value for a key is None, the attribute is deleted. """ aset = node.attrs for k, v in attributes.items(): if not over...
python
def set_attributes(node, overwrite=True, **attributes): """Set multiple attributes on node. If overwrite is False, and the attribute already exists, does nothing. If the value for a key is None, the attribute is deleted. """ aset = node.attrs for k, v in attributes.items(): if not over...
[ "def", "set_attributes", "(", "node", ",", "overwrite", "=", "True", ",", "*", "*", "attributes", ")", ":", "aset", "=", "node", ".", "attrs", "for", "k", ",", "v", "in", "attributes", ".", "items", "(", ")", ":", "if", "not", "overwrite", "and", "...
Set multiple attributes on node. If overwrite is False, and the attribute already exists, does nothing. If the value for a key is None, the attribute is deleted.
[ "Set", "multiple", "attributes", "on", "node", "." ]
71746d9edbe7993a783d4acaf84b9631f3230283
https://github.com/melizalab/arf/blob/71746d9edbe7993a783d4acaf84b9631f3230283/arf.py#L241-L256
train
Set multiple attributes on a node.
melizalab/arf
arf.py
keys_by_creation
def keys_by_creation(group): """Returns a sequence of links in group in order of creation. Raises an error if the group was not set to track creation order. """ from h5py import h5 out = [] try: group._id.links.iterate( out.append, idx_type=h5.INDEX_CRT_ORDER, order=h5.ITER...
python
def keys_by_creation(group): """Returns a sequence of links in group in order of creation. Raises an error if the group was not set to track creation order. """ from h5py import h5 out = [] try: group._id.links.iterate( out.append, idx_type=h5.INDEX_CRT_ORDER, order=h5.ITER...
[ "def", "keys_by_creation", "(", "group", ")", ":", "from", "h5py", "import", "h5", "out", "=", "[", "]", "try", ":", "group", ".", "_id", ".", "links", ".", "iterate", "(", "out", ".", "append", ",", "idx_type", "=", "h5", ".", "INDEX_CRT_ORDER", ","...
Returns a sequence of links in group in order of creation. Raises an error if the group was not set to track creation order.
[ "Returns", "a", "sequence", "of", "links", "in", "group", "in", "order", "of", "creation", "." ]
71746d9edbe7993a783d4acaf84b9631f3230283
https://github.com/melizalab/arf/blob/71746d9edbe7993a783d4acaf84b9631f3230283/arf.py#L259-L277
train
Returns a sequence of links in group in order of creation.
melizalab/arf
arf.py
convert_timestamp
def convert_timestamp(obj): """Make an ARF timestamp from an object. Argument can be a datetime.datetime object, a time.struct_time, an integer, a float, or a tuple of integers. The returned value is a numpy array with the integer number of seconds since the Epoch and any additional microseconds. ...
python
def convert_timestamp(obj): """Make an ARF timestamp from an object. Argument can be a datetime.datetime object, a time.struct_time, an integer, a float, or a tuple of integers. The returned value is a numpy array with the integer number of seconds since the Epoch and any additional microseconds. ...
[ "def", "convert_timestamp", "(", "obj", ")", ":", "import", "numbers", "from", "datetime", "import", "datetime", "from", "time", "import", "mktime", ",", "struct_time", "from", "numpy", "import", "zeros", "out", "=", "zeros", "(", "2", ",", "dtype", "=", "...
Make an ARF timestamp from an object. Argument can be a datetime.datetime object, a time.struct_time, an integer, a float, or a tuple of integers. The returned value is a numpy array with the integer number of seconds since the Epoch and any additional microseconds. Note that because floating poin...
[ "Make", "an", "ARF", "timestamp", "from", "an", "object", "." ]
71746d9edbe7993a783d4acaf84b9631f3230283
https://github.com/melizalab/arf/blob/71746d9edbe7993a783d4acaf84b9631f3230283/arf.py#L280-L313
train
Convert an ARF timestamp from an object to an ARF timestamp.
melizalab/arf
arf.py
timestamp_to_datetime
def timestamp_to_datetime(timestamp): """Convert an ARF timestamp to a datetime.datetime object (naive local time)""" from datetime import datetime, timedelta obj = datetime.fromtimestamp(timestamp[0]) return obj + timedelta(microseconds=int(timestamp[1]))
python
def timestamp_to_datetime(timestamp): """Convert an ARF timestamp to a datetime.datetime object (naive local time)""" from datetime import datetime, timedelta obj = datetime.fromtimestamp(timestamp[0]) return obj + timedelta(microseconds=int(timestamp[1]))
[ "def", "timestamp_to_datetime", "(", "timestamp", ")", ":", "from", "datetime", "import", "datetime", ",", "timedelta", "obj", "=", "datetime", ".", "fromtimestamp", "(", "timestamp", "[", "0", "]", ")", "return", "obj", "+", "timedelta", "(", "microseconds", ...
Convert an ARF timestamp to a datetime.datetime object (naive local time)
[ "Convert", "an", "ARF", "timestamp", "to", "a", "datetime", ".", "datetime", "object", "(", "naive", "local", "time", ")" ]
71746d9edbe7993a783d4acaf84b9631f3230283
https://github.com/melizalab/arf/blob/71746d9edbe7993a783d4acaf84b9631f3230283/arf.py#L316-L320
train
Convert an ARF timestamp to a datetime. datetime object
melizalab/arf
arf.py
set_uuid
def set_uuid(obj, uuid=None): """Set the uuid attribute of an HDF5 object. Use this method to ensure correct dtype """ from uuid import uuid4, UUID if uuid is None: uuid = uuid4() elif isinstance(uuid, bytes): if len(uuid) == 16: uuid = UUID(bytes=uuid) else: ...
python
def set_uuid(obj, uuid=None): """Set the uuid attribute of an HDF5 object. Use this method to ensure correct dtype """ from uuid import uuid4, UUID if uuid is None: uuid = uuid4() elif isinstance(uuid, bytes): if len(uuid) == 16: uuid = UUID(bytes=uuid) else: ...
[ "def", "set_uuid", "(", "obj", ",", "uuid", "=", "None", ")", ":", "from", "uuid", "import", "uuid4", ",", "UUID", "if", "uuid", "is", "None", ":", "uuid", "=", "uuid4", "(", ")", "elif", "isinstance", "(", "uuid", ",", "bytes", ")", ":", "if", "...
Set the uuid attribute of an HDF5 object. Use this method to ensure correct dtype
[ "Set", "the", "uuid", "attribute", "of", "an", "HDF5", "object", ".", "Use", "this", "method", "to", "ensure", "correct", "dtype" ]
71746d9edbe7993a783d4acaf84b9631f3230283
https://github.com/melizalab/arf/blob/71746d9edbe7993a783d4acaf84b9631f3230283/arf.py#L328-L341
train
Set the uuid attribute of an HDF5 object.
melizalab/arf
arf.py
get_uuid
def get_uuid(obj): """Return the uuid for obj, or null uuid if none is set""" # TODO: deprecate null uuid ret val from uuid import UUID try: uuid = obj.attrs['uuid'] except KeyError: return UUID(int=0) # convert to unicode for python 3 try: uuid = uuid.decode('ascii')...
python
def get_uuid(obj): """Return the uuid for obj, or null uuid if none is set""" # TODO: deprecate null uuid ret val from uuid import UUID try: uuid = obj.attrs['uuid'] except KeyError: return UUID(int=0) # convert to unicode for python 3 try: uuid = uuid.decode('ascii')...
[ "def", "get_uuid", "(", "obj", ")", ":", "# TODO: deprecate null uuid ret val", "from", "uuid", "import", "UUID", "try", ":", "uuid", "=", "obj", ".", "attrs", "[", "'uuid'", "]", "except", "KeyError", ":", "return", "UUID", "(", "int", "=", "0", ")", "#...
Return the uuid for obj, or null uuid if none is set
[ "Return", "the", "uuid", "for", "obj", "or", "null", "uuid", "if", "none", "is", "set" ]
71746d9edbe7993a783d4acaf84b9631f3230283
https://github.com/melizalab/arf/blob/71746d9edbe7993a783d4acaf84b9631f3230283/arf.py#L344-L357
train
Return the uuid for obj or null uuid if none is set
melizalab/arf
arf.py
count_children
def count_children(obj, type=None): """Return the number of children of obj, optionally restricting by class""" if type is None: return len(obj) else: # there doesn't appear to be any hdf5 function for getting this # information without inspecting each child, which makes this somewha...
python
def count_children(obj, type=None): """Return the number of children of obj, optionally restricting by class""" if type is None: return len(obj) else: # there doesn't appear to be any hdf5 function for getting this # information without inspecting each child, which makes this somewha...
[ "def", "count_children", "(", "obj", ",", "type", "=", "None", ")", ":", "if", "type", "is", "None", ":", "return", "len", "(", "obj", ")", "else", ":", "# there doesn't appear to be any hdf5 function for getting this", "# information without inspecting each child, whic...
Return the number of children of obj, optionally restricting by class
[ "Return", "the", "number", "of", "children", "of", "obj", "optionally", "restricting", "by", "class" ]
71746d9edbe7993a783d4acaf84b9631f3230283
https://github.com/melizalab/arf/blob/71746d9edbe7993a783d4acaf84b9631f3230283/arf.py#L360-L368
train
Return the number of children of obj optionally restricting by class
melizalab/arf
arf.py
DataTypes._todict
def _todict(cls): """ generate a dict keyed by value """ return dict((getattr(cls, attr), attr) for attr in dir(cls) if not attr.startswith('_'))
python
def _todict(cls): """ generate a dict keyed by value """ return dict((getattr(cls, attr), attr) for attr in dir(cls) if not attr.startswith('_'))
[ "def", "_todict", "(", "cls", ")", ":", "return", "dict", "(", "(", "getattr", "(", "cls", ",", "attr", ")", ",", "attr", ")", "for", "attr", "in", "dir", "(", "cls", ")", "if", "not", "attr", ".", "startswith", "(", "'_'", ")", ")" ]
generate a dict keyed by value
[ "generate", "a", "dict", "keyed", "by", "value" ]
71746d9edbe7993a783d4acaf84b9631f3230283
https://github.com/melizalab/arf/blob/71746d9edbe7993a783d4acaf84b9631f3230283/arf.py#L32-L34
train
generate a dict keyed by value
singularityhub/singularity-python
singularity/views/utils.py
get_template
def get_template(template_name,fields=None): '''get_template will return a template in the template folder, with some substitutions (eg, {'{{ graph | safe }}':"fill this in!"} ''' template = None if not template_name.endswith('.html'): template_name = "%s.html" %(template_name) here = "%...
python
def get_template(template_name,fields=None): '''get_template will return a template in the template folder, with some substitutions (eg, {'{{ graph | safe }}':"fill this in!"} ''' template = None if not template_name.endswith('.html'): template_name = "%s.html" %(template_name) here = "%...
[ "def", "get_template", "(", "template_name", ",", "fields", "=", "None", ")", ":", "template", "=", "None", "if", "not", "template_name", ".", "endswith", "(", "'.html'", ")", ":", "template_name", "=", "\"%s.html\"", "%", "(", "template_name", ")", "here", ...
get_template will return a template in the template folder, with some substitutions (eg, {'{{ graph | safe }}':"fill this in!"}
[ "get_template", "will", "return", "a", "template", "in", "the", "template", "folder", "with", "some", "substitutions", "(", "eg", "{", "{{", "graph", "|", "safe", "}}", ":", "fill", "this", "in!", "}" ]
498c3433724b332f7493fec632d8daf479f47b82
https://github.com/singularityhub/singularity-python/blob/498c3433724b332f7493fec632d8daf479f47b82/singularity/views/utils.py#L32-L46
train
get_template will return a template in the template folder with some substitutions
singularityhub/singularity-python
singularity/analysis/compare.py
container_similarity_vector
def container_similarity_vector(container1=None,packages_set=None,by=None): '''container similarity_vector is similar to compare_packages, but intended to compare a container object (singularity image or singularity hub container) to a list of packages. If packages_set is not provided, the default used is ...
python
def container_similarity_vector(container1=None,packages_set=None,by=None): '''container similarity_vector is similar to compare_packages, but intended to compare a container object (singularity image or singularity hub container) to a list of packages. If packages_set is not provided, the default used is ...
[ "def", "container_similarity_vector", "(", "container1", "=", "None", ",", "packages_set", "=", "None", ",", "by", "=", "None", ")", ":", "if", "by", "==", "None", ":", "by", "=", "[", "'files.txt'", "]", "if", "not", "isinstance", "(", "by", ",", "lis...
container similarity_vector is similar to compare_packages, but intended to compare a container object (singularity image or singularity hub container) to a list of packages. If packages_set is not provided, the default used is 'docker-os'. This can be changed to 'docker-library', or if the user wants a cu...
[ "container", "similarity_vector", "is", "similar", "to", "compare_packages", "but", "intended", "to", "compare", "a", "container", "object", "(", "singularity", "image", "or", "singularity", "hub", "container", ")", "to", "a", "list", "of", "packages", ".", "If"...
498c3433724b332f7493fec632d8daf479f47b82
https://github.com/singularityhub/singularity-python/blob/498c3433724b332f7493fec632d8daf479f47b82/singularity/analysis/compare.py#L41-L75
train
container similarity_vector is similar to compare_packages but intended to compare a container object.
singularityhub/singularity-python
singularity/analysis/compare.py
compare_singularity_images
def compare_singularity_images(image_paths1, image_paths2=None): '''compare_singularity_images is a wrapper for compare_containers to compare singularity containers. If image_paths2 is not defined, pairwise comparison is done with image_paths1 ''' repeat = False if image_paths2 is None: ...
python
def compare_singularity_images(image_paths1, image_paths2=None): '''compare_singularity_images is a wrapper for compare_containers to compare singularity containers. If image_paths2 is not defined, pairwise comparison is done with image_paths1 ''' repeat = False if image_paths2 is None: ...
[ "def", "compare_singularity_images", "(", "image_paths1", ",", "image_paths2", "=", "None", ")", ":", "repeat", "=", "False", "if", "image_paths2", "is", "None", ":", "image_paths2", "=", "image_paths1", "repeat", "=", "True", "if", "not", "isinstance", "(", "...
compare_singularity_images is a wrapper for compare_containers to compare singularity containers. If image_paths2 is not defined, pairwise comparison is done with image_paths1
[ "compare_singularity_images", "is", "a", "wrapper", "for", "compare_containers", "to", "compare", "singularity", "containers", ".", "If", "image_paths2", "is", "not", "defined", "pairwise", "comparison", "is", "done", "with", "image_paths1" ]
498c3433724b332f7493fec632d8daf479f47b82
https://github.com/singularityhub/singularity-python/blob/498c3433724b332f7493fec632d8daf479f47b82/singularity/analysis/compare.py#L78-L120
train
compare_singularity_images is a wrapper for compare_containers to compare singularity containers.
singularityhub/singularity-python
singularity/analysis/compare.py
compare_containers
def compare_containers(container1=None, container2=None): '''compare_containers will generate a data structure with common and unique files to two images. If environmental variable SINGULARITY_HUB is set, will use container database objects. :param container1: first container for comparison :param ...
python
def compare_containers(container1=None, container2=None): '''compare_containers will generate a data structure with common and unique files to two images. If environmental variable SINGULARITY_HUB is set, will use container database objects. :param container1: first container for comparison :param ...
[ "def", "compare_containers", "(", "container1", "=", "None", ",", "container2", "=", "None", ")", ":", "# Get files and folders for each", "container1_guts", "=", "get_container_contents", "(", "split_delim", "=", "\"\\n\"", ",", "container", "=", "container1", ")", ...
compare_containers will generate a data structure with common and unique files to two images. If environmental variable SINGULARITY_HUB is set, will use container database objects. :param container1: first container for comparison :param container2: second container for comparison if either not defined ...
[ "compare_containers", "will", "generate", "a", "data", "structure", "with", "common", "and", "unique", "files", "to", "two", "images", ".", "If", "environmental", "variable", "SINGULARITY_HUB", "is", "set", "will", "use", "container", "database", "objects", ".", ...
498c3433724b332f7493fec632d8daf479f47b82
https://github.com/singularityhub/singularity-python/blob/498c3433724b332f7493fec632d8daf479f47b82/singularity/analysis/compare.py#L123-L140
train
This function will generate a data structure with common and unique files to two images.
singularityhub/singularity-python
singularity/analysis/compare.py
compare_lists
def compare_lists(list1,list2): '''compare lists is the lowest level that drives compare_containers and compare_packages. It returns a comparison object (dict) with the unique, total, and intersecting things between two lists :param list1: the list for container1 :param list2: the list for container...
python
def compare_lists(list1,list2): '''compare lists is the lowest level that drives compare_containers and compare_packages. It returns a comparison object (dict) with the unique, total, and intersecting things between two lists :param list1: the list for container1 :param list2: the list for container...
[ "def", "compare_lists", "(", "list1", ",", "list2", ")", ":", "intersect", "=", "list", "(", "set", "(", "list1", ")", ".", "intersection", "(", "list2", ")", ")", "unique1", "=", "list", "(", "set", "(", "list1", ")", ".", "difference", "(", "list2"...
compare lists is the lowest level that drives compare_containers and compare_packages. It returns a comparison object (dict) with the unique, total, and intersecting things between two lists :param list1: the list for container1 :param list2: the list for container2
[ "compare", "lists", "is", "the", "lowest", "level", "that", "drives", "compare_containers", "and", "compare_packages", ".", "It", "returns", "a", "comparison", "object", "(", "dict", ")", "with", "the", "unique", "total", "and", "intersecting", "things", "betwee...
498c3433724b332f7493fec632d8daf479f47b82
https://github.com/singularityhub/singularity-python/blob/498c3433724b332f7493fec632d8daf479f47b82/singularity/analysis/compare.py#L143-L160
train
compare lists is the lowest level that drives compare_containers and compare_packages. It returns a dict with the unique total and intersecting things between two lists
singularityhub/singularity-python
singularity/analysis/compare.py
calculate_similarity
def calculate_similarity(container1=None, container2=None, comparison=None, metric=None): '''calculate_similarity will calculate similarity of two containers by files content, default will calculate 2.0*len(intersect) / to...
python
def calculate_similarity(container1=None, container2=None, comparison=None, metric=None): '''calculate_similarity will calculate similarity of two containers by files content, default will calculate 2.0*len(intersect) / to...
[ "def", "calculate_similarity", "(", "container1", "=", "None", ",", "container2", "=", "None", ",", "comparison", "=", "None", ",", "metric", "=", "None", ")", ":", "if", "metric", "is", "None", ":", "metric", "=", "information_coefficient", "if", "compariso...
calculate_similarity will calculate similarity of two containers by files content, default will calculate 2.0*len(intersect) / total package1 + total package2 Parameters ========== container1: container 1 container2: container 2 must be defined or metric a function to take a total...
[ "calculate_similarity", "will", "calculate", "similarity", "of", "two", "containers", "by", "files", "content", "default", "will", "calculate", "2", ".", "0", "*", "len", "(", "intersect", ")", "/", "total", "package1", "+", "total", "package2" ]
498c3433724b332f7493fec632d8daf479f47b82
https://github.com/singularityhub/singularity-python/blob/498c3433724b332f7493fec632d8daf479f47b82/singularity/analysis/compare.py#L163-L193
train
calculate_similarity will calculate similarity of two containers by files content
singularityhub/singularity-python
singularity/package/clone.py
package_node
def package_node(root=None, name=None): '''package node aims to package a (present working node) for a user into a container. This assumes that the node is a single partition. :param root: the root of the node to package, default is / :param name: the name for the image. If not specified, will use ma...
python
def package_node(root=None, name=None): '''package node aims to package a (present working node) for a user into a container. This assumes that the node is a single partition. :param root: the root of the node to package, default is / :param name: the name for the image. If not specified, will use ma...
[ "def", "package_node", "(", "root", "=", "None", ",", "name", "=", "None", ")", ":", "if", "name", "is", "None", ":", "name", "=", "platform", ".", "node", "(", ")", "if", "root", "is", "None", ":", "root", "=", "\"/\"", "tmpdir", "=", "tempfile", ...
package node aims to package a (present working node) for a user into a container. This assumes that the node is a single partition. :param root: the root of the node to package, default is / :param name: the name for the image. If not specified, will use machine's psutil.disk_partitions()
[ "package", "node", "aims", "to", "package", "a", "(", "present", "working", "node", ")", "for", "a", "user", "into", "a", "container", ".", "This", "assumes", "that", "the", "node", "is", "a", "single", "partition", ".", ":", "param", "root", ":", "the...
498c3433724b332f7493fec632d8daf479f47b82
https://github.com/singularityhub/singularity-python/blob/498c3433724b332f7493fec632d8daf479f47b82/singularity/package/clone.py#L30-L53
train
package a node into a container
singularityhub/singularity-python
singularity/package/clone.py
unpack_node
def unpack_node(image_path,name=None,output_folder=None,size=None): '''unpackage node is intended to unpackage a node that was packaged with package_node. The image should be a .tgz file. The general steps are to: 1. Package the node using the package_node function 2. Transfer the package somewhere that...
python
def unpack_node(image_path,name=None,output_folder=None,size=None): '''unpackage node is intended to unpackage a node that was packaged with package_node. The image should be a .tgz file. The general steps are to: 1. Package the node using the package_node function 2. Transfer the package somewhere that...
[ "def", "unpack_node", "(", "image_path", ",", "name", "=", "None", ",", "output_folder", "=", "None", ",", "size", "=", "None", ")", ":", "if", "not", "image_path", ".", "endswith", "(", "\".tgz\"", ")", ":", "bot", ".", "error", "(", "\"The image_path s...
unpackage node is intended to unpackage a node that was packaged with package_node. The image should be a .tgz file. The general steps are to: 1. Package the node using the package_node function 2. Transfer the package somewhere that Singularity is installed
[ "unpackage", "node", "is", "intended", "to", "unpackage", "a", "node", "that", "was", "packaged", "with", "package_node", ".", "The", "image", "should", "be", "a", ".", "tgz", "file", ".", "The", "general", "steps", "are", "to", ":", "1", ".", "Package",...
498c3433724b332f7493fec632d8daf479f47b82
https://github.com/singularityhub/singularity-python/blob/498c3433724b332f7493fec632d8daf479f47b82/singularity/package/clone.py#L56-L87
train
unpackage node is intended to unpackage a node that was packaged with package_node function.
singularityhub/singularity-python
singularity/build/utils.py
get_build_template
def get_build_template(template_name,params=None,to_file=None): '''get_build template returns a string or file for a particular build template, which is intended to build a version of a Singularity image on a cloud resource. :param template_name: the name of the template to retrieve in build/scripts :pa...
python
def get_build_template(template_name,params=None,to_file=None): '''get_build template returns a string or file for a particular build template, which is intended to build a version of a Singularity image on a cloud resource. :param template_name: the name of the template to retrieve in build/scripts :pa...
[ "def", "get_build_template", "(", "template_name", ",", "params", "=", "None", ",", "to_file", "=", "None", ")", ":", "base", "=", "get_installdir", "(", ")", "template_folder", "=", "\"%s/build/scripts\"", "%", "(", "base", ")", "template_file", "=", "\"%s/%s...
get_build template returns a string or file for a particular build template, which is intended to build a version of a Singularity image on a cloud resource. :param template_name: the name of the template to retrieve in build/scripts :param params: (if needed) a dictionary of parameters to substitute in the...
[ "get_build", "template", "returns", "a", "string", "or", "file", "for", "a", "particular", "build", "template", "which", "is", "intended", "to", "build", "a", "version", "of", "a", "Singularity", "image", "on", "a", "cloud", "resource", ".", ":", "param", ...
498c3433724b332f7493fec632d8daf479f47b82
https://github.com/singularityhub/singularity-python/blob/498c3433724b332f7493fec632d8daf479f47b82/singularity/build/utils.py#L72-L100
train
get_build template returns a string or file for a particular build template
singularityhub/singularity-python
singularity/build/utils.py
sniff_extension
def sniff_extension(file_path,verbose=True): '''sniff_extension will attempt to determine the file type based on the extension, and return the proper mimetype :param file_path: the full path to the file to sniff :param verbose: print stuff out ''' mime_types = { "xls": 'application/vnd.ms-exc...
python
def sniff_extension(file_path,verbose=True): '''sniff_extension will attempt to determine the file type based on the extension, and return the proper mimetype :param file_path: the full path to the file to sniff :param verbose: print stuff out ''' mime_types = { "xls": 'application/vnd.ms-exc...
[ "def", "sniff_extension", "(", "file_path", ",", "verbose", "=", "True", ")", ":", "mime_types", "=", "{", "\"xls\"", ":", "'application/vnd.ms-excel'", ",", "\"xlsx\"", ":", "'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet'", ",", "\"xml\"", ":", "'t...
sniff_extension will attempt to determine the file type based on the extension, and return the proper mimetype :param file_path: the full path to the file to sniff :param verbose: print stuff out
[ "sniff_extension", "will", "attempt", "to", "determine", "the", "file", "type", "based", "on", "the", "extension", "and", "return", "the", "proper", "mimetype", ":", "param", "file_path", ":", "the", "full", "path", "to", "the", "file", "to", "sniff", ":", ...
498c3433724b332f7493fec632d8daf479f47b82
https://github.com/singularityhub/singularity-python/blob/498c3433724b332f7493fec632d8daf479f47b82/singularity/build/utils.py#L140-L185
train
sniff_extension will attempt to determine the file type based on the extension and return the proper mimetype
singularityhub/singularity-python
singularity/build/utils.py
get_script
def get_script(script_name): '''get_script will return a build script_name, if it is included in singularity/build/scripts, otherwise will alert the user and return None :param script_name: the name of the script to look for ''' install_dir = get_installdir() script_path = "%s/build/scripts/%s"...
python
def get_script(script_name): '''get_script will return a build script_name, if it is included in singularity/build/scripts, otherwise will alert the user and return None :param script_name: the name of the script to look for ''' install_dir = get_installdir() script_path = "%s/build/scripts/%s"...
[ "def", "get_script", "(", "script_name", ")", ":", "install_dir", "=", "get_installdir", "(", ")", "script_path", "=", "\"%s/build/scripts/%s\"", "%", "(", "install_dir", ",", "script_name", ")", "if", "os", ".", "path", ".", "exists", "(", "script_path", ")",...
get_script will return a build script_name, if it is included in singularity/build/scripts, otherwise will alert the user and return None :param script_name: the name of the script to look for
[ "get_script", "will", "return", "a", "build", "script_name", "if", "it", "is", "included", "in", "singularity", "/", "build", "/", "scripts", "otherwise", "will", "alert", "the", "user", "and", "return", "None", ":", "param", "script_name", ":", "the", "name...
498c3433724b332f7493fec632d8daf479f47b82
https://github.com/singularityhub/singularity-python/blob/498c3433724b332f7493fec632d8daf479f47b82/singularity/build/utils.py#L188-L199
train
get_script will return a build script_name if it is included in singularity - python otherwise will alert the user and return None
singularityhub/singularity-python
singularity/package/utils.py
zip_up
def zip_up(file_list,zip_name,output_folder=None): '''zip_up will zip up some list of files into a package (.zip) :param file_list: a list of files to include in the zip. :param output_folder: the output folder to create the zip in. If not :param zip_name: the name of the zipfile to return. specifi...
python
def zip_up(file_list,zip_name,output_folder=None): '''zip_up will zip up some list of files into a package (.zip) :param file_list: a list of files to include in the zip. :param output_folder: the output folder to create the zip in. If not :param zip_name: the name of the zipfile to return. specifi...
[ "def", "zip_up", "(", "file_list", ",", "zip_name", ",", "output_folder", "=", "None", ")", ":", "tmpdir", "=", "tempfile", ".", "mkdtemp", "(", ")", "# Make a new archive ", "output_zip", "=", "\"%s/%s\"", "%", "(", "tmpdir", ",", "zip_name", ")", "zf", ...
zip_up will zip up some list of files into a package (.zip) :param file_list: a list of files to include in the zip. :param output_folder: the output folder to create the zip in. If not :param zip_name: the name of the zipfile to return. specified, a temporary folder will be given.
[ "zip_up", "will", "zip", "up", "some", "list", "of", "files", "into", "a", "package", "(", ".", "zip", ")", ":", "param", "file_list", ":", "a", "list", "of", "files", "to", "include", "in", "the", "zip", ".", ":", "param", "output_folder", ":", "the...
498c3433724b332f7493fec632d8daf479f47b82
https://github.com/singularityhub/singularity-python/blob/498c3433724b332f7493fec632d8daf479f47b82/singularity/package/utils.py#L52-L110
train
This function will zip up some list of files into a single file in a folder.
singularityhub/singularity-python
singularity/package/utils.py
get_container_contents
def get_container_contents(container, split_delim=None): '''get_container_contents will return a list of folders and or files for a container. The environmental variable SINGULARITY_HUB being set means that container objects are referenced instead of packages :param container: the container to get conte...
python
def get_container_contents(container, split_delim=None): '''get_container_contents will return a list of folders and or files for a container. The environmental variable SINGULARITY_HUB being set means that container objects are referenced instead of packages :param container: the container to get conte...
[ "def", "get_container_contents", "(", "container", ",", "split_delim", "=", "None", ")", ":", "# We will look for everything in guts, then return it", "guts", "=", "dict", "(", ")", "SINGULARITY_HUB", "=", "os", ".", "environ", ".", "get", "(", "'SINGULARITY_HUB'", ...
get_container_contents will return a list of folders and or files for a container. The environmental variable SINGULARITY_HUB being set means that container objects are referenced instead of packages :param container: the container to get content for :param gets: a list of file names to return, without ...
[ "get_container_contents", "will", "return", "a", "list", "of", "folders", "and", "or", "files", "for", "a", "container", ".", "The", "environmental", "variable", "SINGULARITY_HUB", "being", "set", "means", "that", "container", "objects", "are", "referenced", "inst...
498c3433724b332f7493fec632d8daf479f47b82
https://github.com/singularityhub/singularity-python/blob/498c3433724b332f7493fec632d8daf479f47b82/singularity/package/utils.py#L119-L156
train
get_container_contents will return a list of folders or files for a container
singularityhub/singularity-python
singularity/analysis/reproduce/hash.py
get_image_hashes
def get_image_hashes(image_path, version=None, levels=None): '''get_image_hashes returns the hash for an image across all levels. This is the quickest, easiest way to define a container's reproducibility on each level. ''' if levels is None: levels = get_levels(version=version) hashes = dict...
python
def get_image_hashes(image_path, version=None, levels=None): '''get_image_hashes returns the hash for an image across all levels. This is the quickest, easiest way to define a container's reproducibility on each level. ''' if levels is None: levels = get_levels(version=version) hashes = dict...
[ "def", "get_image_hashes", "(", "image_path", ",", "version", "=", "None", ",", "levels", "=", "None", ")", ":", "if", "levels", "is", "None", ":", "levels", "=", "get_levels", "(", "version", "=", "version", ")", "hashes", "=", "dict", "(", ")", "for"...
get_image_hashes returns the hash for an image across all levels. This is the quickest, easiest way to define a container's reproducibility on each level.
[ "get_image_hashes", "returns", "the", "hash", "for", "an", "image", "across", "all", "levels", ".", "This", "is", "the", "quickest", "easiest", "way", "to", "define", "a", "container", "s", "reproducibility", "on", "each", "level", "." ]
498c3433724b332f7493fec632d8daf479f47b82
https://github.com/singularityhub/singularity-python/blob/498c3433724b332f7493fec632d8daf479f47b82/singularity/analysis/reproduce/hash.py#L42-L52
train
get_image_hashes returns the hash for an image across all levels
singularityhub/singularity-python
singularity/analysis/reproduce/hash.py
get_image_hash
def get_image_hash(image_path, level=None,level_filter=None, include_files=None, skip_files=None, version=None): '''get_image_hash will generate a sha1 hash of an image, depending on a level of reproducibility specified by the user. (s...
python
def get_image_hash(image_path, level=None,level_filter=None, include_files=None, skip_files=None, version=None): '''get_image_hash will generate a sha1 hash of an image, depending on a level of reproducibility specified by the user. (s...
[ "def", "get_image_hash", "(", "image_path", ",", "level", "=", "None", ",", "level_filter", "=", "None", ",", "include_files", "=", "None", ",", "skip_files", "=", "None", ",", "version", "=", "None", ")", ":", "# First get a level dictionary, with description and...
get_image_hash will generate a sha1 hash of an image, depending on a level of reproducibility specified by the user. (see function get_levels for descriptions) the user can also provide a level_filter manually with level_filter (for custom levels) :param level: the level of reproducibility to use, which map...
[ "get_image_hash", "will", "generate", "a", "sha1", "hash", "of", "an", "image", "depending", "on", "a", "level", "of", "reproducibility", "specified", "by", "the", "user", ".", "(", "see", "function", "get_levels", "for", "descriptions", ")", "the", "user", ...
498c3433724b332f7493fec632d8daf479f47b82
https://github.com/singularityhub/singularity-python/blob/498c3433724b332f7493fec632d8daf479f47b82/singularity/analysis/reproduce/hash.py#L56-L121
train
This function will generate a sha1 hash of an image.
singularityhub/singularity-python
singularity/analysis/reproduce/hash.py
get_content_hashes
def get_content_hashes(image_path, level=None, regexp=None, include_files=None, tag_root=True, level_filter=None, skip_files=None, version=None, ...
python
def get_content_hashes(image_path, level=None, regexp=None, include_files=None, tag_root=True, level_filter=None, skip_files=None, version=None, ...
[ "def", "get_content_hashes", "(", "image_path", ",", "level", "=", "None", ",", "regexp", "=", "None", ",", "include_files", "=", "None", ",", "tag_root", "=", "True", ",", "level_filter", "=", "None", ",", "skip_files", "=", "None", ",", "version", "=", ...
get_content_hashes is like get_image_hash, but it returns a complete dictionary of file names (keys) and their respective hashes (values). This function is intended for more research purposes and was used to generate the levels in the first place. If include_sizes is True, we include a second data structur...
[ "get_content_hashes", "is", "like", "get_image_hash", "but", "it", "returns", "a", "complete", "dictionary", "of", "file", "names", "(", "keys", ")", "and", "their", "respective", "hashes", "(", "values", ")", ".", "This", "function", "is", "intended", "for", ...
498c3433724b332f7493fec632d8daf479f47b82
https://github.com/singularityhub/singularity-python/blob/498c3433724b332f7493fec632d8daf479f47b82/singularity/analysis/reproduce/hash.py#L124-L162
train
This function returns a dictionary of file names and their hashes. It returns a dictionary of file names and their corresponding hashes.
singularityhub/singularity-python
singularity/analysis/reproduce/hash.py
get_image_file_hash
def get_image_file_hash(image_path): '''get_image_hash will return an md5 hash of the file based on a criteria level. :param level: one of LOW, MEDIUM, HIGH :param image_path: full path to the singularity image ''' hasher = hashlib.md5() with open(image_path, "rb") as f: for chunk in ite...
python
def get_image_file_hash(image_path): '''get_image_hash will return an md5 hash of the file based on a criteria level. :param level: one of LOW, MEDIUM, HIGH :param image_path: full path to the singularity image ''' hasher = hashlib.md5() with open(image_path, "rb") as f: for chunk in ite...
[ "def", "get_image_file_hash", "(", "image_path", ")", ":", "hasher", "=", "hashlib", ".", "md5", "(", ")", "with", "open", "(", "image_path", ",", "\"rb\"", ")", "as", "f", ":", "for", "chunk", "in", "iter", "(", "lambda", ":", "f", ".", "read", "(",...
get_image_hash will return an md5 hash of the file based on a criteria level. :param level: one of LOW, MEDIUM, HIGH :param image_path: full path to the singularity image
[ "get_image_hash", "will", "return", "an", "md5", "hash", "of", "the", "file", "based", "on", "a", "criteria", "level", ".", ":", "param", "level", ":", "one", "of", "LOW", "MEDIUM", "HIGH", ":", "param", "image_path", ":", "full", "path", "to", "the", ...
498c3433724b332f7493fec632d8daf479f47b82
https://github.com/singularityhub/singularity-python/blob/498c3433724b332f7493fec632d8daf479f47b82/singularity/analysis/reproduce/hash.py#L166-L175
train
get_image_hash will return an md5 hash of the file based on a criteria level
singularityhub/singularity-python
singularity/views/trees.py
container_difference
def container_difference(container=None,container_subtract=None,image_package=None, image_package_subtract=None,comparison=None): '''container_difference will return a data structure to render an html tree (graph) of the differences between two images or packages. The second contai...
python
def container_difference(container=None,container_subtract=None,image_package=None, image_package_subtract=None,comparison=None): '''container_difference will return a data structure to render an html tree (graph) of the differences between two images or packages. The second contai...
[ "def", "container_difference", "(", "container", "=", "None", ",", "container_subtract", "=", "None", ",", "image_package", "=", "None", ",", "image_package_subtract", "=", "None", ",", "comparison", "=", "None", ")", ":", "if", "comparison", "==", "None", ":"...
container_difference will return a data structure to render an html tree (graph) of the differences between two images or packages. The second container is subtracted from the first :param container: the primary container object (to subtract from) :param container_subtract: the second container object ...
[ "container_difference", "will", "return", "a", "data", "structure", "to", "render", "an", "html", "tree", "(", "graph", ")", "of", "the", "differences", "between", "two", "images", "or", "packages", ".", "The", "second", "container", "is", "subtracted", "from"...
498c3433724b332f7493fec632d8daf479f47b82
https://github.com/singularityhub/singularity-python/blob/498c3433724b332f7493fec632d8daf479f47b82/singularity/views/trees.py#L55-L78
train
container_difference will return a data structure to render an html tree
singularityhub/singularity-python
singularity/views/trees.py
container_similarity
def container_similarity(container1=None,container2=None,image_package1=None, image_package2=None,comparison=None): '''container_sim will return a data structure to render an html tree (graph) of the intersection (commonalities) between two images or packages :param container1: the...
python
def container_similarity(container1=None,container2=None,image_package1=None, image_package2=None,comparison=None): '''container_sim will return a data structure to render an html tree (graph) of the intersection (commonalities) between two images or packages :param container1: the...
[ "def", "container_similarity", "(", "container1", "=", "None", ",", "container2", "=", "None", ",", "image_package1", "=", "None", ",", "image_package2", "=", "None", ",", "comparison", "=", "None", ")", ":", "if", "comparison", "==", "None", ":", "compariso...
container_sim will return a data structure to render an html tree (graph) of the intersection (commonalities) between two images or packages :param container1: the first container object :param container2: the second container object if either not defined, need :param image_package1: a packaged contain...
[ "container_sim", "will", "return", "a", "data", "structure", "to", "render", "an", "html", "tree", "(", "graph", ")", "of", "the", "intersection", "(", "commonalities", ")", "between", "two", "images", "or", "packages", ":", "param", "container1", ":", "the"...
498c3433724b332f7493fec632d8daf479f47b82
https://github.com/singularityhub/singularity-python/blob/498c3433724b332f7493fec632d8daf479f47b82/singularity/views/trees.py#L82-L103
train
container_sim will return a data structure to render an html tree
singularityhub/singularity-python
singularity/views/trees.py
container_tree
def container_tree(container=None,image_package=None): '''tree will render an html tree (graph) of a container ''' guts = get_container_contents(container=container, image_package=image_package, split_delim="\n") # Make the tree and r...
python
def container_tree(container=None,image_package=None): '''tree will render an html tree (graph) of a container ''' guts = get_container_contents(container=container, image_package=image_package, split_delim="\n") # Make the tree and r...
[ "def", "container_tree", "(", "container", "=", "None", ",", "image_package", "=", "None", ")", ":", "guts", "=", "get_container_contents", "(", "container", "=", "container", ",", "image_package", "=", "image_package", ",", "split_delim", "=", "\"\\n\"", ")", ...
tree will render an html tree (graph) of a container
[ "tree", "will", "render", "an", "html", "tree", "(", "graph", ")", "of", "a", "container" ]
498c3433724b332f7493fec632d8daf479f47b82
https://github.com/singularityhub/singularity-python/blob/498c3433724b332f7493fec632d8daf479f47b82/singularity/views/trees.py#L106-L117
train
will render an html tree of a container
singularityhub/singularity-python
singularity/views/trees.py
make_container_tree
def make_container_tree(folders,files,path_delim="/",parse_files=True): '''make_container_tree will convert a list of folders and files into a json structure that represents a graph. :param folders: a list of folders in the image :param files: a list of files in the folder :param parse_files: return 'fi...
python
def make_container_tree(folders,files,path_delim="/",parse_files=True): '''make_container_tree will convert a list of folders and files into a json structure that represents a graph. :param folders: a list of folders in the image :param files: a list of files in the folder :param parse_files: return 'fi...
[ "def", "make_container_tree", "(", "folders", ",", "files", ",", "path_delim", "=", "\"/\"", ",", "parse_files", "=", "True", ")", ":", "nodes", "=", "{", "}", "# first we will make a list of nodes", "lookup", "=", "{", "}", "count", "=", "1", "# count will ho...
make_container_tree will convert a list of folders and files into a json structure that represents a graph. :param folders: a list of folders in the image :param files: a list of files in the folder :param parse_files: return 'files' lookup in result, to associate ID of node with files (default True) :p...
[ "make_container_tree", "will", "convert", "a", "list", "of", "folders", "and", "files", "into", "a", "json", "structure", "that", "represents", "a", "graph", ".", ":", "param", "folders", ":", "a", "list", "of", "folders", "in", "the", "image", ":", "param...
498c3433724b332f7493fec632d8daf479f47b82
https://github.com/singularityhub/singularity-python/blob/498c3433724b332f7493fec632d8daf479f47b82/singularity/views/trees.py#L120-L197
train
This function will convert a list of folders and files into a json structure that represents a graph.
singularityhub/singularity-python
singularity/views/trees.py
make_package_tree
def make_package_tree(matrix=None,labels=None,width=25,height=10,title=None,font_size=None): '''make package tree will make a dendrogram comparing a matrix of packages :param matrix: a pandas df of packages, with names in index and columns :param labels: a list of labels corresponding to row names, will be ...
python
def make_package_tree(matrix=None,labels=None,width=25,height=10,title=None,font_size=None): '''make package tree will make a dendrogram comparing a matrix of packages :param matrix: a pandas df of packages, with names in index and columns :param labels: a list of labels corresponding to row names, will be ...
[ "def", "make_package_tree", "(", "matrix", "=", "None", ",", "labels", "=", "None", ",", "width", "=", "25", ",", "height", "=", "10", ",", "title", "=", "None", ",", "font_size", "=", "None", ")", ":", "from", "matplotlib", "import", "pyplot", "as", ...
make package tree will make a dendrogram comparing a matrix of packages :param matrix: a pandas df of packages, with names in index and columns :param labels: a list of labels corresponding to row names, will be pulled from rows if not defined :param title: a title for the plot, if not defined, will be ...
[ "make", "package", "tree", "will", "make", "a", "dendrogram", "comparing", "a", "matrix", "of", "packages", ":", "param", "matrix", ":", "a", "pandas", "df", "of", "packages", "with", "names", "in", "index", "and", "columns", ":", "param", "labels", ":", ...
498c3433724b332f7493fec632d8daf479f47b82
https://github.com/singularityhub/singularity-python/blob/498c3433724b332f7493fec632d8daf479f47b82/singularity/views/trees.py#L205-L247
train
make a package tree
singularityhub/singularity-python
singularity/views/trees.py
make_interactive_tree
def make_interactive_tree(matrix=None,labels=None): '''make interactive tree will return complete html for an interactive tree :param title: a title for the plot, if not defined, will be left out. ''' from scipy.cluster.hierarchy import ( dendrogram, linkage, to_tree ) ...
python
def make_interactive_tree(matrix=None,labels=None): '''make interactive tree will return complete html for an interactive tree :param title: a title for the plot, if not defined, will be left out. ''' from scipy.cluster.hierarchy import ( dendrogram, linkage, to_tree ) ...
[ "def", "make_interactive_tree", "(", "matrix", "=", "None", ",", "labels", "=", "None", ")", ":", "from", "scipy", ".", "cluster", ".", "hierarchy", "import", "(", "dendrogram", ",", "linkage", ",", "to_tree", ")", "d3", "=", "None", "from", "scipy", "."...
make interactive tree will return complete html for an interactive tree :param title: a title for the plot, if not defined, will be left out.
[ "make", "interactive", "tree", "will", "return", "complete", "html", "for", "an", "interactive", "tree", ":", "param", "title", ":", "a", "title", "for", "the", "plot", "if", "not", "defined", "will", "be", "left", "out", "." ]
498c3433724b332f7493fec632d8daf479f47b82
https://github.com/singularityhub/singularity-python/blob/498c3433724b332f7493fec632d8daf479f47b82/singularity/views/trees.py#L250-L284
train
make an interactive tree
singularityhub/singularity-python
singularity/views/trees.py
add_node
def add_node(node, parent): '''add_node will add a node to it's parent ''' newNode = dict(node_id=node.id, children=[]) parent["children"].append(newNode) if node.left: add_node(node.left, newNode) if node.right: add_node(node.right, newNode)
python
def add_node(node, parent): '''add_node will add a node to it's parent ''' newNode = dict(node_id=node.id, children=[]) parent["children"].append(newNode) if node.left: add_node(node.left, newNode) if node.right: add_node(node.right, newNode)
[ "def", "add_node", "(", "node", ",", "parent", ")", ":", "newNode", "=", "dict", "(", "node_id", "=", "node", ".", "id", ",", "children", "=", "[", "]", ")", "parent", "[", "\"children\"", "]", ".", "append", "(", "newNode", ")", "if", "node", ".",...
add_node will add a node to it's parent
[ "add_node", "will", "add", "a", "node", "to", "it", "s", "parent" ]
498c3433724b332f7493fec632d8daf479f47b82
https://github.com/singularityhub/singularity-python/blob/498c3433724b332f7493fec632d8daf479f47b82/singularity/views/trees.py#L287-L293
train
add_node will add a node to it s parent
singularityhub/singularity-python
singularity/views/trees.py
label_tree
def label_tree(n,lookup): '''label tree will again recursively label the tree :param n: the root node, usually d3['children'][0] :param lookup: the node/id lookup ''' if len(n["children"]) == 0: leaves = [lookup[n["node_id"]]] else: leaves = reduce(lambda ls, c: ls + label_tree(c...
python
def label_tree(n,lookup): '''label tree will again recursively label the tree :param n: the root node, usually d3['children'][0] :param lookup: the node/id lookup ''' if len(n["children"]) == 0: leaves = [lookup[n["node_id"]]] else: leaves = reduce(lambda ls, c: ls + label_tree(c...
[ "def", "label_tree", "(", "n", ",", "lookup", ")", ":", "if", "len", "(", "n", "[", "\"children\"", "]", ")", "==", "0", ":", "leaves", "=", "[", "lookup", "[", "n", "[", "\"node_id\"", "]", "]", "]", "else", ":", "leaves", "=", "reduce", "(", ...
label tree will again recursively label the tree :param n: the root node, usually d3['children'][0] :param lookup: the node/id lookup
[ "label", "tree", "will", "again", "recursively", "label", "the", "tree", ":", "param", "n", ":", "the", "root", "node", "usually", "d3", "[", "children", "]", "[", "0", "]", ":", "param", "lookup", ":", "the", "node", "/", "id", "lookup" ]
498c3433724b332f7493fec632d8daf479f47b82
https://github.com/singularityhub/singularity-python/blob/498c3433724b332f7493fec632d8daf479f47b82/singularity/views/trees.py#L296-L307
train
label tree will recursively label the tree
singularityhub/singularity-python
singularity/analysis/apps.py
extract_apps
def extract_apps(image, app_names): ''' extract app will extract metadata for one or more apps Parameters ========== image: the absolute path to the image app_name: the name of the app under /scif/apps ''' apps = dict() if isinstance(app_names, tuple): app_names...
python
def extract_apps(image, app_names): ''' extract app will extract metadata for one or more apps Parameters ========== image: the absolute path to the image app_name: the name of the app under /scif/apps ''' apps = dict() if isinstance(app_names, tuple): app_names...
[ "def", "extract_apps", "(", "image", ",", "app_names", ")", ":", "apps", "=", "dict", "(", ")", "if", "isinstance", "(", "app_names", ",", "tuple", ")", ":", "app_names", "=", "list", "(", "app_names", ")", "if", "not", "isinstance", "(", "app_names", ...
extract app will extract metadata for one or more apps Parameters ========== image: the absolute path to the image app_name: the name of the app under /scif/apps
[ "extract", "app", "will", "extract", "metadata", "for", "one", "or", "more", "apps", "Parameters", "==========", "image", ":", "the", "absolute", "path", "to", "the", "image", "app_name", ":", "the", "name", "of", "the", "app", "under", "/", "scif", "/", ...
498c3433724b332f7493fec632d8daf479f47b82
https://github.com/singularityhub/singularity-python/blob/498c3433724b332f7493fec632d8daf479f47b82/singularity/analysis/apps.py#L31-L61
train
extract app will extract metadata for one or more apps
singularityhub/singularity-python
singularity/utils.py
run_command
def run_command(cmd, sudo=False): '''run_command uses subprocess to send a command to the terminal. :param cmd: the command to send, should be a list for subprocess :param error_message: the error message to give to user if fails, if none specified, will alert that command failed. :param sudopw: if ...
python
def run_command(cmd, sudo=False): '''run_command uses subprocess to send a command to the terminal. :param cmd: the command to send, should be a list for subprocess :param error_message: the error message to give to user if fails, if none specified, will alert that command failed. :param sudopw: if ...
[ "def", "run_command", "(", "cmd", ",", "sudo", "=", "False", ")", ":", "if", "sudo", "is", "True", ":", "cmd", "=", "[", "'sudo'", "]", "+", "cmd", "output", "=", "Popen", "(", "cmd", ",", "stderr", "=", "STDOUT", ",", "stdout", "=", "PIPE", ")",...
run_command uses subprocess to send a command to the terminal. :param cmd: the command to send, should be a list for subprocess :param error_message: the error message to give to user if fails, if none specified, will alert that command failed. :param sudopw: if specified (not None) command will be run ...
[ "run_command", "uses", "subprocess", "to", "send", "a", "command", "to", "the", "terminal", ".", ":", "param", "cmd", ":", "the", "command", "to", "send", "should", "be", "a", "list", "for", "subprocess", ":", "param", "error_message", ":", "the", "error",...
498c3433724b332f7493fec632d8daf479f47b82
https://github.com/singularityhub/singularity-python/blob/498c3433724b332f7493fec632d8daf479f47b82/singularity/utils.py#L70-L85
train
run_command uses subprocess to send a command to the terminal
singularityhub/singularity-python
singularity/utils.py
download_repo
def download_repo(repo_url, destination, commit=None): '''download_repo :param repo_url: the url of the repo to clone from :param destination: the full path to the destination for the repo ''' command = "git clone %s %s" % (repo_url, destination) os.system(command) return destination
python
def download_repo(repo_url, destination, commit=None): '''download_repo :param repo_url: the url of the repo to clone from :param destination: the full path to the destination for the repo ''' command = "git clone %s %s" % (repo_url, destination) os.system(command) return destination
[ "def", "download_repo", "(", "repo_url", ",", "destination", ",", "commit", "=", "None", ")", ":", "command", "=", "\"git clone %s %s\"", "%", "(", "repo_url", ",", "destination", ")", "os", ".", "system", "(", "command", ")", "return", "destination" ]
download_repo :param repo_url: the url of the repo to clone from :param destination: the full path to the destination for the repo
[ "download_repo", ":", "param", "repo_url", ":", "the", "url", "of", "the", "repo", "to", "clone", "from", ":", "param", "destination", ":", "the", "full", "path", "to", "the", "destination", "for", "the", "repo" ]
498c3433724b332f7493fec632d8daf479f47b82
https://github.com/singularityhub/singularity-python/blob/498c3433724b332f7493fec632d8daf479f47b82/singularity/utils.py#L190-L197
train
downloads the repo from the specified url to the specified destination
singularityhub/singularity-python
singularity/analysis/classify.py
get_tags
def get_tags(container=None, search_folders=None, file_list=None, return_unique=True): '''get tags will return a list of tags that describe the software in an image, meaning inside of a paricular folder. If search_folder is not defined, uses lib :param container: if p...
python
def get_tags(container=None, search_folders=None, file_list=None, return_unique=True): '''get tags will return a list of tags that describe the software in an image, meaning inside of a paricular folder. If search_folder is not defined, uses lib :param container: if p...
[ "def", "get_tags", "(", "container", "=", "None", ",", "search_folders", "=", "None", ",", "file_list", "=", "None", ",", "return_unique", "=", "True", ")", ":", "if", "file_list", "is", "None", ":", "file_list", "=", "get_container_contents", "(", "containe...
get tags will return a list of tags that describe the software in an image, meaning inside of a paricular folder. If search_folder is not defined, uses lib :param container: if provided, will use container as image. Can also provide :param image_package: if provided, can be used instead of container :pa...
[ "get", "tags", "will", "return", "a", "list", "of", "tags", "that", "describe", "the", "software", "in", "an", "image", "meaning", "inside", "of", "a", "paricular", "folder", ".", "If", "search_folder", "is", "not", "defined", "uses", "lib", ":", "param", ...
498c3433724b332f7493fec632d8daf479f47b82
https://github.com/singularityhub/singularity-python/blob/498c3433724b332f7493fec632d8daf479f47b82/singularity/analysis/classify.py#L51-L91
train
get tags will return a list of tags that describe the software in an image
singularityhub/singularity-python
singularity/analysis/classify.py
file_counts
def file_counts(container=None, patterns=None, image_package=None, file_list=None): '''file counts will return a list of files that match one or more regular expressions. if no patterns is defined, a default of readme is used. All patterns and files are made ...
python
def file_counts(container=None, patterns=None, image_package=None, file_list=None): '''file counts will return a list of files that match one or more regular expressions. if no patterns is defined, a default of readme is used. All patterns and files are made ...
[ "def", "file_counts", "(", "container", "=", "None", ",", "patterns", "=", "None", ",", "image_package", "=", "None", ",", "file_list", "=", "None", ")", ":", "if", "file_list", "is", "None", ":", "file_list", "=", "get_container_contents", "(", "container",...
file counts will return a list of files that match one or more regular expressions. if no patterns is defined, a default of readme is used. All patterns and files are made case insensitive. Parameters ========== :param container: if provided, will use container as image. Can also provide :param...
[ "file", "counts", "will", "return", "a", "list", "of", "files", "that", "match", "one", "or", "more", "regular", "expressions", ".", "if", "no", "patterns", "is", "defined", "a", "default", "of", "readme", "is", "used", ".", "All", "patterns", "and", "fi...
498c3433724b332f7493fec632d8daf479f47b82
https://github.com/singularityhub/singularity-python/blob/498c3433724b332f7493fec632d8daf479f47b82/singularity/analysis/classify.py#L99-L130
train
file counts will return a list of files that match one or more regular expressions.
singularityhub/singularity-python
singularity/analysis/classify.py
extension_counts
def extension_counts(container=None, file_list=None, return_counts=True): '''extension counts will return a dictionary with counts of file extensions for an image. :param container: if provided, will use container as image. Can also provide :param image_package: if provided, can be used instead of conta...
python
def extension_counts(container=None, file_list=None, return_counts=True): '''extension counts will return a dictionary with counts of file extensions for an image. :param container: if provided, will use container as image. Can also provide :param image_package: if provided, can be used instead of conta...
[ "def", "extension_counts", "(", "container", "=", "None", ",", "file_list", "=", "None", ",", "return_counts", "=", "True", ")", ":", "if", "file_list", "is", "None", ":", "file_list", "=", "get_container_contents", "(", "container", ",", "split_delim", "=", ...
extension counts will return a dictionary with counts of file extensions for an image. :param container: if provided, will use container as image. Can also provide :param image_package: if provided, can be used instead of container :param file_list: the complete list of files :param return_counts: r...
[ "extension", "counts", "will", "return", "a", "dictionary", "with", "counts", "of", "file", "extensions", "for", "an", "image", ".", ":", "param", "container", ":", "if", "provided", "will", "use", "container", "as", "image", ".", "Can", "also", "provide", ...
498c3433724b332f7493fec632d8daf479f47b82
https://github.com/singularityhub/singularity-python/blob/498c3433724b332f7493fec632d8daf479f47b82/singularity/analysis/classify.py#L133-L158
train
returns a dictionary with counts of file extensions for a container and an image.
singularityhub/singularity-python
singularity/analysis/reproduce/metrics.py
assess_differences
def assess_differences(image_file1, image_file2, levels=None, version=None, size_heuristic=False, guts1=None, guts2=None): '''assess_differences will compare two images on each ...
python
def assess_differences(image_file1, image_file2, levels=None, version=None, size_heuristic=False, guts1=None, guts2=None): '''assess_differences will compare two images on each ...
[ "def", "assess_differences", "(", "image_file1", ",", "image_file2", ",", "levels", "=", "None", ",", "version", "=", "None", ",", "size_heuristic", "=", "False", ",", "guts1", "=", "None", ",", "guts2", "=", "None", ")", ":", "if", "levels", "is", "None...
assess_differences will compare two images on each level of reproducibility, returning for each level a dictionary with files that are the same, different, and an overall score. :param size_heuristic: if True, assess root owned files based on size :param guts1,guts2: the result (dict with sizes,roots,e...
[ "assess_differences", "will", "compare", "two", "images", "on", "each", "level", "of", "reproducibility", "returning", "for", "each", "level", "a", "dictionary", "with", "files", "that", "are", "the", "same", "different", "and", "an", "overall", "score", ".", ...
498c3433724b332f7493fec632d8daf479f47b82
https://github.com/singularityhub/singularity-python/blob/498c3433724b332f7493fec632d8daf479f47b82/singularity/analysis/reproduce/metrics.py#L30-L134
train
assess the differences between two images on each level of returns a dictionary with files that are the same different and an overall score.
singularityhub/singularity-python
singularity/analysis/reproduce/criteria.py
include_file
def include_file(member,file_filter): '''include_file will look at a path and determine if it matches a regular expression from a level ''' member_path = member.name.replace('.','',1) if len(member_path) == 0: return False # Does the filter skip it explicitly? if "skip_files" in fi...
python
def include_file(member,file_filter): '''include_file will look at a path and determine if it matches a regular expression from a level ''' member_path = member.name.replace('.','',1) if len(member_path) == 0: return False # Does the filter skip it explicitly? if "skip_files" in fi...
[ "def", "include_file", "(", "member", ",", "file_filter", ")", ":", "member_path", "=", "member", ".", "name", ".", "replace", "(", "'.'", ",", "''", ",", "1", ")", "if", "len", "(", "member_path", ")", "==", "0", ":", "return", "False", "# Does the fi...
include_file will look at a path and determine if it matches a regular expression from a level
[ "include_file", "will", "look", "at", "a", "path", "and", "determine", "if", "it", "matches", "a", "regular", "expression", "from", "a", "level" ]
498c3433724b332f7493fec632d8daf479f47b82
https://github.com/singularityhub/singularity-python/blob/498c3433724b332f7493fec632d8daf479f47b82/singularity/analysis/reproduce/criteria.py#L27-L50
train
Returns True if the member matches a regular expression from a level .
singularityhub/singularity-python
singularity/analysis/reproduce/criteria.py
is_root_owned
def is_root_owned(member): '''assess if a file is root owned, meaning "root" or user/group id of 0''' if member.uid == 0 or member.gid == 0: return True elif member.uname == 'root' or member.gname == 'root': return True return False
python
def is_root_owned(member): '''assess if a file is root owned, meaning "root" or user/group id of 0''' if member.uid == 0 or member.gid == 0: return True elif member.uname == 'root' or member.gname == 'root': return True return False
[ "def", "is_root_owned", "(", "member", ")", ":", "if", "member", ".", "uid", "==", "0", "or", "member", ".", "gid", "==", "0", ":", "return", "True", "elif", "member", ".", "uname", "==", "'root'", "or", "member", ".", "gname", "==", "'root'", ":", ...
assess if a file is root owned, meaning "root" or user/group id of 0
[ "assess", "if", "a", "file", "is", "root", "owned", "meaning", "root", "or", "user", "/", "group", "id", "of", "0" ]
498c3433724b332f7493fec632d8daf479f47b82
https://github.com/singularityhub/singularity-python/blob/498c3433724b332f7493fec632d8daf479f47b82/singularity/analysis/reproduce/criteria.py#L53-L60
train
assess if a file is root owned meaning root or user / group id of 0
singularityhub/singularity-python
singularity/analysis/reproduce/criteria.py
assess_content
def assess_content(member,file_filter): '''Determine if the filter wants the file to be read for content. In the case of yes, we would then want to add the content to the hash and not the file object. ''' member_path = member.name.replace('.','',1) if len(member_path) == 0: return False...
python
def assess_content(member,file_filter): '''Determine if the filter wants the file to be read for content. In the case of yes, we would then want to add the content to the hash and not the file object. ''' member_path = member.name.replace('.','',1) if len(member_path) == 0: return False...
[ "def", "assess_content", "(", "member", ",", "file_filter", ")", ":", "member_path", "=", "member", ".", "name", ".", "replace", "(", "'.'", ",", "''", ",", "1", ")", "if", "len", "(", "member_path", ")", "==", "0", ":", "return", "False", "# Does the ...
Determine if the filter wants the file to be read for content. In the case of yes, we would then want to add the content to the hash and not the file object.
[ "Determine", "if", "the", "filter", "wants", "the", "file", "to", "be", "read", "for", "content", ".", "In", "the", "case", "of", "yes", "we", "would", "then", "want", "to", "add", "the", "content", "to", "the", "hash", "and", "not", "the", "file", "...
498c3433724b332f7493fec632d8daf479f47b82
https://github.com/singularityhub/singularity-python/blob/498c3433724b332f7493fec632d8daf479f47b82/singularity/analysis/reproduce/criteria.py#L63-L81
train
Determine if the filter wants the file to be read for content.
singularityhub/singularity-python
singularity/analysis/reproduce/levels.py
get_custom_level
def get_custom_level(regexp=None,description=None,skip_files=None,include_files=None): '''get_custom_level will generate a custom level for the user, based on a regular expression. If used outside the context of tarsum, the user can generate their own named and described filters. :param regexp: must be...
python
def get_custom_level(regexp=None,description=None,skip_files=None,include_files=None): '''get_custom_level will generate a custom level for the user, based on a regular expression. If used outside the context of tarsum, the user can generate their own named and described filters. :param regexp: must be...
[ "def", "get_custom_level", "(", "regexp", "=", "None", ",", "description", "=", "None", ",", "skip_files", "=", "None", ",", "include_files", "=", "None", ")", ":", "if", "regexp", "==", "None", ":", "regexp", "=", "\".\"", "if", "description", "is", "No...
get_custom_level will generate a custom level for the user, based on a regular expression. If used outside the context of tarsum, the user can generate their own named and described filters. :param regexp: must be defined, the file filter regular expression :param description: optional description
[ "get_custom_level", "will", "generate", "a", "custom", "level", "for", "the", "user", "based", "on", "a", "regular", "expression", ".", "If", "used", "outside", "the", "context", "of", "tarsum", "the", "user", "can", "generate", "their", "own", "named", "and...
498c3433724b332f7493fec632d8daf479f47b82
https://github.com/singularityhub/singularity-python/blob/498c3433724b332f7493fec632d8daf479f47b82/singularity/analysis/reproduce/levels.py#L34-L61
train
This function returns a custom level for a user based on a regular expression.
singularityhub/singularity-python
singularity/analysis/reproduce/levels.py
get_level
def get_level(level,version=None,include_files=None,skip_files=None): '''get_level returns a single level, with option to customize files added and skipped. ''' levels = get_levels(version=version) level_names = list(levels.keys()) if level.upper() in level_names: level = levels[level]...
python
def get_level(level,version=None,include_files=None,skip_files=None): '''get_level returns a single level, with option to customize files added and skipped. ''' levels = get_levels(version=version) level_names = list(levels.keys()) if level.upper() in level_names: level = levels[level]...
[ "def", "get_level", "(", "level", ",", "version", "=", "None", ",", "include_files", "=", "None", ",", "skip_files", "=", "None", ")", ":", "levels", "=", "get_levels", "(", "version", "=", "version", ")", "level_names", "=", "list", "(", "levels", ".", ...
get_level returns a single level, with option to customize files added and skipped.
[ "get_level", "returns", "a", "single", "level", "with", "option", "to", "customize", "files", "added", "and", "skipped", "." ]
498c3433724b332f7493fec632d8daf479f47b82
https://github.com/singularityhub/singularity-python/blob/498c3433724b332f7493fec632d8daf479f47b82/singularity/analysis/reproduce/levels.py#L64-L86
train
get_level returns a single level with option to customize files added and skipped.
singularityhub/singularity-python
singularity/analysis/reproduce/levels.py
modify_level
def modify_level(level,field,values,append=True): '''modify level is intended to add / modify a content type. Default content type is list, meaning the entry is appended. If you set append to False, the content will be overwritten For any other content type, the entry is overwritten. ''' field =...
python
def modify_level(level,field,values,append=True): '''modify level is intended to add / modify a content type. Default content type is list, meaning the entry is appended. If you set append to False, the content will be overwritten For any other content type, the entry is overwritten. ''' field =...
[ "def", "modify_level", "(", "level", ",", "field", ",", "values", ",", "append", "=", "True", ")", ":", "field", "=", "field", ".", "lower", "(", ")", "valid_fields", "=", "[", "'regexp'", ",", "'skip_files'", ",", "'include_files'", "]", "if", "field", ...
modify level is intended to add / modify a content type. Default content type is list, meaning the entry is appended. If you set append to False, the content will be overwritten For any other content type, the entry is overwritten.
[ "modify", "level", "is", "intended", "to", "add", "/", "modify", "a", "content", "type", ".", "Default", "content", "type", "is", "list", "meaning", "the", "entry", "is", "appended", ".", "If", "you", "set", "append", "to", "False", "the", "content", "wi...
498c3433724b332f7493fec632d8daf479f47b82
https://github.com/singularityhub/singularity-python/blob/498c3433724b332f7493fec632d8daf479f47b82/singularity/analysis/reproduce/levels.py#L89-L112
train
modify level is intended to add or modify a content type.
singularityhub/singularity-python
singularity/analysis/reproduce/levels.py
get_levels
def get_levels(version=None): '''get_levels returns a dictionary of levels (key) and values (dictionaries with descriptions and regular expressions for files) for the user. :param version: the version of singularity to use (default is 2.2) :param include_files: files to add to the level, only relvant i...
python
def get_levels(version=None): '''get_levels returns a dictionary of levels (key) and values (dictionaries with descriptions and regular expressions for files) for the user. :param version: the version of singularity to use (default is 2.2) :param include_files: files to add to the level, only relvant i...
[ "def", "get_levels", "(", "version", "=", "None", ")", ":", "valid_versions", "=", "[", "'2.3'", ",", "'2.2'", "]", "if", "version", "is", "None", ":", "version", "=", "\"2.3\"", "version", "=", "str", "(", "version", ")", "if", "version", "not", "in",...
get_levels returns a dictionary of levels (key) and values (dictionaries with descriptions and regular expressions for files) for the user. :param version: the version of singularity to use (default is 2.2) :param include_files: files to add to the level, only relvant if
[ "get_levels", "returns", "a", "dictionary", "of", "levels", "(", "key", ")", "and", "values", "(", "dictionaries", "with", "descriptions", "and", "regular", "expressions", "for", "files", ")", "for", "the", "user", ".", ":", "param", "version", ":", "the", ...
498c3433724b332f7493fec632d8daf479f47b82
https://github.com/singularityhub/singularity-python/blob/498c3433724b332f7493fec632d8daf479f47b82/singularity/analysis/reproduce/levels.py#L115-L143
train
get_levels returns a dictionary of levels descriptions and regular expressions for files for the user.
singularityhub/singularity-python
singularity/analysis/reproduce/levels.py
make_levels_set
def make_levels_set(levels): '''make set efficient will convert all lists of items in levels to a set to speed up operations''' for level_key,level_filters in levels.items(): levels[level_key] = make_level_set(level_filters) return levels
python
def make_levels_set(levels): '''make set efficient will convert all lists of items in levels to a set to speed up operations''' for level_key,level_filters in levels.items(): levels[level_key] = make_level_set(level_filters) return levels
[ "def", "make_levels_set", "(", "levels", ")", ":", "for", "level_key", ",", "level_filters", "in", "levels", ".", "items", "(", ")", ":", "levels", "[", "level_key", "]", "=", "make_level_set", "(", "level_filters", ")", "return", "levels" ]
make set efficient will convert all lists of items in levels to a set to speed up operations
[ "make", "set", "efficient", "will", "convert", "all", "lists", "of", "items", "in", "levels", "to", "a", "set", "to", "speed", "up", "operations" ]
498c3433724b332f7493fec632d8daf479f47b82
https://github.com/singularityhub/singularity-python/blob/498c3433724b332f7493fec632d8daf479f47b82/singularity/analysis/reproduce/levels.py#L146-L151
train
make set efficient will convert all lists of items in levels to a set
singularityhub/singularity-python
singularity/analysis/reproduce/levels.py
make_level_set
def make_level_set(level): '''make level set will convert one level into a set''' new_level = dict() for key,value in level.items(): if isinstance(value,list): new_level[key] = set(value) else: new_level[key] = value return new_level
python
def make_level_set(level): '''make level set will convert one level into a set''' new_level = dict() for key,value in level.items(): if isinstance(value,list): new_level[key] = set(value) else: new_level[key] = value return new_level
[ "def", "make_level_set", "(", "level", ")", ":", "new_level", "=", "dict", "(", ")", "for", "key", ",", "value", "in", "level", ".", "items", "(", ")", ":", "if", "isinstance", "(", "value", ",", "list", ")", ":", "new_level", "[", "key", "]", "=",...
make level set will convert one level into a set
[ "make", "level", "set", "will", "convert", "one", "level", "into", "a", "set" ]
498c3433724b332f7493fec632d8daf479f47b82
https://github.com/singularityhub/singularity-python/blob/498c3433724b332f7493fec632d8daf479f47b82/singularity/analysis/reproduce/levels.py#L155-L164
train
make level set will convert one level into a set
singularityhub/singularity-python
singularity/analysis/reproduce/utils.py
extract_guts
def extract_guts(image_path, tar, file_filter=None, tag_root=True, include_sizes=True): '''extract the file guts from an in memory tarfile. The file is not closed. This should not be done for large images. ''' if file_filter is None...
python
def extract_guts(image_path, tar, file_filter=None, tag_root=True, include_sizes=True): '''extract the file guts from an in memory tarfile. The file is not closed. This should not be done for large images. ''' if file_filter is None...
[ "def", "extract_guts", "(", "image_path", ",", "tar", ",", "file_filter", "=", "None", ",", "tag_root", "=", "True", ",", "include_sizes", "=", "True", ")", ":", "if", "file_filter", "is", "None", ":", "file_filter", "=", "get_level", "(", "'IDENTICAL'", "...
extract the file guts from an in memory tarfile. The file is not closed. This should not be done for large images.
[ "extract", "the", "file", "guts", "from", "an", "in", "memory", "tarfile", ".", "The", "file", "is", "not", "closed", ".", "This", "should", "not", "be", "done", "for", "large", "images", "." ]
498c3433724b332f7493fec632d8daf479f47b82
https://github.com/singularityhub/singularity-python/blob/498c3433724b332f7493fec632d8daf479f47b82/singularity/analysis/reproduce/utils.py#L39-L88
train
extract the file guts from an in memory tarfile.
singularityhub/singularity-python
singularity/analysis/reproduce/utils.py
get_memory_tar
def get_memory_tar(image_path): '''get an in memory tar of an image. Use carefully, not as reliable as get_image_tar ''' byte_array = Client.image.export(image_path) file_object = io.BytesIO(byte_array) tar = tarfile.open(mode="r|*", fileobj=file_object) return (file_object,tar)
python
def get_memory_tar(image_path): '''get an in memory tar of an image. Use carefully, not as reliable as get_image_tar ''' byte_array = Client.image.export(image_path) file_object = io.BytesIO(byte_array) tar = tarfile.open(mode="r|*", fileobj=file_object) return (file_object,tar)
[ "def", "get_memory_tar", "(", "image_path", ")", ":", "byte_array", "=", "Client", ".", "image", ".", "export", "(", "image_path", ")", "file_object", "=", "io", ".", "BytesIO", "(", "byte_array", ")", "tar", "=", "tarfile", ".", "open", "(", "mode", "="...
get an in memory tar of an image. Use carefully, not as reliable as get_image_tar
[ "get", "an", "in", "memory", "tar", "of", "an", "image", ".", "Use", "carefully", "not", "as", "reliable", "as", "get_image_tar" ]
498c3433724b332f7493fec632d8daf479f47b82
https://github.com/singularityhub/singularity-python/blob/498c3433724b332f7493fec632d8daf479f47b82/singularity/analysis/reproduce/utils.py#L92-L99
train
get an in memory tar of an image
singularityhub/singularity-python
singularity/analysis/reproduce/utils.py
get_image_tar
def get_image_tar(image_path): '''get an image tar, either written in memory or to the file system. file_obj will either be the file object, or the file itself. ''' bot.debug('Generate file system tar...') file_obj = Client.image.export(image_path=image_path) if file_obj is None: ...
python
def get_image_tar(image_path): '''get an image tar, either written in memory or to the file system. file_obj will either be the file object, or the file itself. ''' bot.debug('Generate file system tar...') file_obj = Client.image.export(image_path=image_path) if file_obj is None: ...
[ "def", "get_image_tar", "(", "image_path", ")", ":", "bot", ".", "debug", "(", "'Generate file system tar...'", ")", "file_obj", "=", "Client", ".", "image", ".", "export", "(", "image_path", "=", "image_path", ")", "if", "file_obj", "is", "None", ":", "bot"...
get an image tar, either written in memory or to the file system. file_obj will either be the file object, or the file itself.
[ "get", "an", "image", "tar", "either", "written", "in", "memory", "or", "to", "the", "file", "system", ".", "file_obj", "will", "either", "be", "the", "file", "object", "or", "the", "file", "itself", "." ]
498c3433724b332f7493fec632d8daf479f47b82
https://github.com/singularityhub/singularity-python/blob/498c3433724b332f7493fec632d8daf479f47b82/singularity/analysis/reproduce/utils.py#L102-L113
train
get an image tar either written in memory or to the file system.
singularityhub/singularity-python
singularity/analysis/reproduce/utils.py
delete_image_tar
def delete_image_tar(file_obj, tar): '''delete image tar will close a file object (if extracted into memory) or delete from the file system (if saved to disk)''' try: file_obj.close() except: tar.close() if os.path.exists(file_obj): os.remove(file_obj) deleted = True ...
python
def delete_image_tar(file_obj, tar): '''delete image tar will close a file object (if extracted into memory) or delete from the file system (if saved to disk)''' try: file_obj.close() except: tar.close() if os.path.exists(file_obj): os.remove(file_obj) deleted = True ...
[ "def", "delete_image_tar", "(", "file_obj", ",", "tar", ")", ":", "try", ":", "file_obj", ".", "close", "(", ")", "except", ":", "tar", ".", "close", "(", ")", "if", "os", ".", "path", ".", "exists", "(", "file_obj", ")", ":", "os", ".", "remove", ...
delete image tar will close a file object (if extracted into memory) or delete from the file system (if saved to disk)
[ "delete", "image", "tar", "will", "close", "a", "file", "object", "(", "if", "extracted", "into", "memory", ")", "or", "delete", "from", "the", "file", "system", "(", "if", "saved", "to", "disk", ")" ]
498c3433724b332f7493fec632d8daf479f47b82
https://github.com/singularityhub/singularity-python/blob/498c3433724b332f7493fec632d8daf479f47b82/singularity/analysis/reproduce/utils.py#L116-L127
train
delete image tar will close a file object or delete from the file system
singularityhub/singularity-python
singularity/analysis/reproduce/utils.py
extract_content
def extract_content(image_path, member_name, return_hash=False): '''extract_content will extract content from an image using cat. If hash=True, a hash sum is returned instead ''' if member_name.startswith('./'): member_name = member_name.replace('.','',1) if return_hash: hashy = hash...
python
def extract_content(image_path, member_name, return_hash=False): '''extract_content will extract content from an image using cat. If hash=True, a hash sum is returned instead ''' if member_name.startswith('./'): member_name = member_name.replace('.','',1) if return_hash: hashy = hash...
[ "def", "extract_content", "(", "image_path", ",", "member_name", ",", "return_hash", "=", "False", ")", ":", "if", "member_name", ".", "startswith", "(", "'./'", ")", ":", "member_name", "=", "member_name", ".", "replace", "(", "'.'", ",", "''", ",", "1", ...
extract_content will extract content from an image using cat. If hash=True, a hash sum is returned instead
[ "extract_content", "will", "extract", "content", "from", "an", "image", "using", "cat", ".", "If", "hash", "=", "True", "a", "hash", "sum", "is", "returned", "instead" ]
498c3433724b332f7493fec632d8daf479f47b82
https://github.com/singularityhub/singularity-python/blob/498c3433724b332f7493fec632d8daf479f47b82/singularity/analysis/reproduce/utils.py#L130-L154
train
extract_content will extract content from an image using cat.
singularityhub/singularity-python
singularity/build/main.py
run_build
def run_build(build_dir, params, verbose=True): '''run_build takes a build directory and params dictionary, and does the following: - downloads repo to a temporary directory - changes branch or commit, if needed - creates and bootstraps singularity image from Singularity file - returns a dic...
python
def run_build(build_dir, params, verbose=True): '''run_build takes a build directory and params dictionary, and does the following: - downloads repo to a temporary directory - changes branch or commit, if needed - creates and bootstraps singularity image from Singularity file - returns a dic...
[ "def", "run_build", "(", "build_dir", ",", "params", ",", "verbose", "=", "True", ")", ":", "# Download the repository", "download_repo", "(", "repo_url", "=", "params", "[", "'repo_url'", "]", ",", "destination", "=", "build_dir", ")", "os", ".", "chdir", "...
run_build takes a build directory and params dictionary, and does the following: - downloads repo to a temporary directory - changes branch or commit, if needed - creates and bootstraps singularity image from Singularity file - returns a dictionary with: image (path), metadata (dict) ...
[ "run_build", "takes", "a", "build", "directory", "and", "params", "dictionary", "and", "does", "the", "following", ":", "-", "downloads", "repo", "to", "a", "temporary", "directory", "-", "changes", "branch", "or", "commit", "if", "needed", "-", "creates", "...
498c3433724b332f7493fec632d8daf479f47b82
https://github.com/singularityhub/singularity-python/blob/498c3433724b332f7493fec632d8daf479f47b82/singularity/build/main.py#L53-L166
train
This function downloads the repository and builds the singularity image from Singularity and creates the singularity image from Singularity.
singularityhub/singularity-python
singularity/build/main.py
send_build_data
def send_build_data(build_dir, data, secret, response_url=None,clean_up=True): '''finish build sends the build and data (response) to a response url :param build_dir: the directory of the build :response_url: where to send the response. If None, won't send :param data: the data obje...
python
def send_build_data(build_dir, data, secret, response_url=None,clean_up=True): '''finish build sends the build and data (response) to a response url :param build_dir: the directory of the build :response_url: where to send the response. If None, won't send :param data: the data obje...
[ "def", "send_build_data", "(", "build_dir", ",", "data", ",", "secret", ",", "response_url", "=", "None", ",", "clean_up", "=", "True", ")", ":", "# Send with Authentication header", "body", "=", "'%s|%s|%s|%s|%s'", "%", "(", "data", "[", "'container_id'", "]", ...
finish build sends the build and data (response) to a response url :param build_dir: the directory of the build :response_url: where to send the response. If None, won't send :param data: the data object to send as a post :param clean_up: If true (default) removes build directory
[ "finish", "build", "sends", "the", "build", "and", "data", "(", "response", ")", "to", "a", "response", "url", ":", "param", "build_dir", ":", "the", "directory", "of", "the", "build", ":", "response_url", ":", "where", "to", "send", "the", "response", "...
498c3433724b332f7493fec632d8daf479f47b82
https://github.com/singularityhub/singularity-python/blob/498c3433724b332f7493fec632d8daf479f47b82/singularity/build/main.py#L170-L203
train
finish build sends the build and data to a response url
singularityhub/singularity-python
singularity/build/main.py
send_build_close
def send_build_close(params,response_url): '''send build close sends a final response (post) to the server to bring down the instance. The following must be included in params: repo_url, logfile, repo_id, secret, log_file, token ''' # Finally, package everything to send back to shub response = ...
python
def send_build_close(params,response_url): '''send build close sends a final response (post) to the server to bring down the instance. The following must be included in params: repo_url, logfile, repo_id, secret, log_file, token ''' # Finally, package everything to send back to shub response = ...
[ "def", "send_build_close", "(", "params", ",", "response_url", ")", ":", "# Finally, package everything to send back to shub", "response", "=", "{", "\"log\"", ":", "json", ".", "dumps", "(", "params", "[", "'log_file'", "]", ")", ",", "\"repo_url\"", ":", "params...
send build close sends a final response (post) to the server to bring down the instance. The following must be included in params: repo_url, logfile, repo_id, secret, log_file, token
[ "send", "build", "close", "sends", "a", "final", "response", "(", "post", ")", "to", "the", "server", "to", "bring", "down", "the", "instance", ".", "The", "following", "must", "be", "included", "in", "params", ":" ]
498c3433724b332f7493fec632d8daf479f47b82
https://github.com/singularityhub/singularity-python/blob/498c3433724b332f7493fec632d8daf479f47b82/singularity/build/main.py#L208-L237
train
send build close to the server
singularityhub/singularity-python
singularity/analysis/utils.py
remove_unicode_dict
def remove_unicode_dict(input_dict): '''remove unicode keys and values from dict, encoding in utf8 ''' if isinstance(input_dict, collections.Mapping): return dict(map(remove_unicode_dict, input_dict.iteritems())) elif isinstance(input_dict, collections.Iterable): return type(input_dict)(...
python
def remove_unicode_dict(input_dict): '''remove unicode keys and values from dict, encoding in utf8 ''' if isinstance(input_dict, collections.Mapping): return dict(map(remove_unicode_dict, input_dict.iteritems())) elif isinstance(input_dict, collections.Iterable): return type(input_dict)(...
[ "def", "remove_unicode_dict", "(", "input_dict", ")", ":", "if", "isinstance", "(", "input_dict", ",", "collections", ".", "Mapping", ")", ":", "return", "dict", "(", "map", "(", "remove_unicode_dict", ",", "input_dict", ".", "iteritems", "(", ")", ")", ")",...
remove unicode keys and values from dict, encoding in utf8
[ "remove", "unicode", "keys", "and", "values", "from", "dict", "encoding", "in", "utf8" ]
498c3433724b332f7493fec632d8daf479f47b82
https://github.com/singularityhub/singularity-python/blob/498c3433724b332f7493fec632d8daf479f47b82/singularity/analysis/utils.py#L39-L47
train
remove unicode keys and values from dict encoding in utf8
singularityhub/singularity-python
singularity/analysis/utils.py
update_dict
def update_dict(input_dict,key,value): '''update_dict will update lists in a dictionary. If the key is not included, if will add as new list. If it is, it will append. :param input_dict: the dict to update :param value: the value to update with ''' if key in input_dict: input_dict[key].a...
python
def update_dict(input_dict,key,value): '''update_dict will update lists in a dictionary. If the key is not included, if will add as new list. If it is, it will append. :param input_dict: the dict to update :param value: the value to update with ''' if key in input_dict: input_dict[key].a...
[ "def", "update_dict", "(", "input_dict", ",", "key", ",", "value", ")", ":", "if", "key", "in", "input_dict", ":", "input_dict", "[", "key", "]", ".", "append", "(", "value", ")", "else", ":", "input_dict", "[", "key", "]", "=", "[", "value", "]", ...
update_dict will update lists in a dictionary. If the key is not included, if will add as new list. If it is, it will append. :param input_dict: the dict to update :param value: the value to update with
[ "update_dict", "will", "update", "lists", "in", "a", "dictionary", ".", "If", "the", "key", "is", "not", "included", "if", "will", "add", "as", "new", "list", ".", "If", "it", "is", "it", "will", "append", ".", ":", "param", "input_dict", ":", "the", ...
498c3433724b332f7493fec632d8daf479f47b82
https://github.com/singularityhub/singularity-python/blob/498c3433724b332f7493fec632d8daf479f47b82/singularity/analysis/utils.py#L50-L60
train
update_dict will update lists in a dictionary.
singularityhub/singularity-python
singularity/analysis/utils.py
update_dict_sum
def update_dict_sum(input_dict,key,increment=None,initial_value=None): '''update_dict sum will increment a dictionary key by an increment, and add a value of 0 if it doesn't exist :param input_dict: the dict to update :param increment: the value to increment by. Default is 1 :param initial_value: v...
python
def update_dict_sum(input_dict,key,increment=None,initial_value=None): '''update_dict sum will increment a dictionary key by an increment, and add a value of 0 if it doesn't exist :param input_dict: the dict to update :param increment: the value to increment by. Default is 1 :param initial_value: v...
[ "def", "update_dict_sum", "(", "input_dict", ",", "key", ",", "increment", "=", "None", ",", "initial_value", "=", "None", ")", ":", "if", "increment", "==", "None", ":", "increment", "=", "1", "if", "initial_value", "==", "None", ":", "initial_value", "="...
update_dict sum will increment a dictionary key by an increment, and add a value of 0 if it doesn't exist :param input_dict: the dict to update :param increment: the value to increment by. Default is 1 :param initial_value: value to start with. Default is 0
[ "update_dict", "sum", "will", "increment", "a", "dictionary", "key", "by", "an", "increment", "and", "add", "a", "value", "of", "0", "if", "it", "doesn", "t", "exist", ":", "param", "input_dict", ":", "the", "dict", "to", "update", ":", "param", "increme...
498c3433724b332f7493fec632d8daf479f47b82
https://github.com/singularityhub/singularity-python/blob/498c3433724b332f7493fec632d8daf479f47b82/singularity/analysis/utils.py#L63-L80
train
update_dict will increment a dictionary key by an increment and add a value of 0
singularityhub/singularity-python
singularity/analysis/metrics.py
information_coefficient
def information_coefficient(total1,total2,intersect): '''a simple jacaard (information coefficient) to compare two lists of overlaps/diffs ''' total = total1 + total2 return 2.0*len(intersect) / total
python
def information_coefficient(total1,total2,intersect): '''a simple jacaard (information coefficient) to compare two lists of overlaps/diffs ''' total = total1 + total2 return 2.0*len(intersect) / total
[ "def", "information_coefficient", "(", "total1", ",", "total2", ",", "intersect", ")", ":", "total", "=", "total1", "+", "total2", "return", "2.0", "*", "len", "(", "intersect", ")", "/", "total" ]
a simple jacaard (information coefficient) to compare two lists of overlaps/diffs
[ "a", "simple", "jacaard", "(", "information", "coefficient", ")", "to", "compare", "two", "lists", "of", "overlaps", "/", "diffs" ]
498c3433724b332f7493fec632d8daf479f47b82
https://github.com/singularityhub/singularity-python/blob/498c3433724b332f7493fec632d8daf479f47b82/singularity/analysis/metrics.py#L34-L38
train
a simple jacaard ( information coefficient to compare two lists of overlaps and differfs
singularityhub/singularity-python
singularity/analysis/metrics.py
RSA
def RSA(m1,m2): '''RSA analysis will compare the similarity of two matrices ''' from scipy.stats import pearsonr import scipy.linalg import numpy # This will take the diagonal of each matrix (and the other half is changed to nan) and flatten to vector vectorm1 = m1.mask(numpy.triu(numpy.one...
python
def RSA(m1,m2): '''RSA analysis will compare the similarity of two matrices ''' from scipy.stats import pearsonr import scipy.linalg import numpy # This will take the diagonal of each matrix (and the other half is changed to nan) and flatten to vector vectorm1 = m1.mask(numpy.triu(numpy.one...
[ "def", "RSA", "(", "m1", ",", "m2", ")", ":", "from", "scipy", ".", "stats", "import", "pearsonr", "import", "scipy", ".", "linalg", "import", "numpy", "# This will take the diagonal of each matrix (and the other half is changed to nan) and flatten to vector", "vectorm1", ...
RSA analysis will compare the similarity of two matrices
[ "RSA", "analysis", "will", "compare", "the", "similarity", "of", "two", "matrices" ]
498c3433724b332f7493fec632d8daf479f47b82
https://github.com/singularityhub/singularity-python/blob/498c3433724b332f7493fec632d8daf479f47b82/singularity/analysis/metrics.py#L42-L56
train
RSA analysis will compare the similarity of two matrices
singularityhub/singularity-python
singularity/build/google.py
get_google_service
def get_google_service(service_type=None,version=None): ''' get_url will use the requests library to get a url :param service_type: the service to get (default is storage) :param version: version to use (default is v1) ''' if service_type == None: service_type = "storage" if version ...
python
def get_google_service(service_type=None,version=None): ''' get_url will use the requests library to get a url :param service_type: the service to get (default is storage) :param version: version to use (default is v1) ''' if service_type == None: service_type = "storage" if version ...
[ "def", "get_google_service", "(", "service_type", "=", "None", ",", "version", "=", "None", ")", ":", "if", "service_type", "==", "None", ":", "service_type", "=", "\"storage\"", "if", "version", "==", "None", ":", "version", "=", "\"v1\"", "credentials", "=...
get_url will use the requests library to get a url :param service_type: the service to get (default is storage) :param version: version to use (default is v1)
[ "get_url", "will", "use", "the", "requests", "library", "to", "get", "a", "url", ":", "param", "service_type", ":", "the", "service", "to", "get", "(", "default", "is", "storage", ")", ":", "param", "version", ":", "version", "to", "use", "(", "default",...
498c3433724b332f7493fec632d8daf479f47b82
https://github.com/singularityhub/singularity-python/blob/498c3433724b332f7493fec632d8daf479f47b82/singularity/build/google.py#L63-L75
train
get_url will use the requests library to get a url
singularityhub/singularity-python
singularity/build/google.py
upload_file
def upload_file(storage_service,bucket,bucket_path,file_name,verbose=True): '''get_folder will return the folder with folder_name, and if create=True, will create it if not found. If folder is found or created, the metadata is returned, otherwise None is returned :param storage_service: the drive_servic...
python
def upload_file(storage_service,bucket,bucket_path,file_name,verbose=True): '''get_folder will return the folder with folder_name, and if create=True, will create it if not found. If folder is found or created, the metadata is returned, otherwise None is returned :param storage_service: the drive_servic...
[ "def", "upload_file", "(", "storage_service", ",", "bucket", ",", "bucket_path", ",", "file_name", ",", "verbose", "=", "True", ")", ":", "# Set up path on bucket", "upload_path", "=", "\"%s/%s\"", "%", "(", "bucket", "[", "'id'", "]", ",", "bucket_path", ")",...
get_folder will return the folder with folder_name, and if create=True, will create it if not found. If folder is found or created, the metadata is returned, otherwise None is returned :param storage_service: the drive_service created from get_storage_service :param bucket: the bucket object from get_bu...
[ "get_folder", "will", "return", "the", "folder", "with", "folder_name", "and", "if", "create", "=", "True", "will", "create", "it", "if", "not", "found", ".", "If", "folder", "is", "found", "or", "created", "the", "metadata", "is", "returned", "otherwise", ...
498c3433724b332f7493fec632d8daf479f47b82
https://github.com/singularityhub/singularity-python/blob/498c3433724b332f7493fec632d8daf479f47b82/singularity/build/google.py#L105-L132
train
upload a file to the specified bucket
singularityhub/singularity-python
singularity/build/google.py
get_image_path
def get_image_path(repo_url, trailing_path): '''get_image_path will determine an image path based on a repo url, removing any token, and taking into account urls that end with .git. :param repo_url: the repo url to parse: :param trailing_path: the trailing path (commit then hash is common) ''' r...
python
def get_image_path(repo_url, trailing_path): '''get_image_path will determine an image path based on a repo url, removing any token, and taking into account urls that end with .git. :param repo_url: the repo url to parse: :param trailing_path: the trailing path (commit then hash is common) ''' r...
[ "def", "get_image_path", "(", "repo_url", ",", "trailing_path", ")", ":", "repo_url", "=", "repo_url", ".", "split", "(", "'@'", ")", "[", "-", "1", "]", ".", "strip", "(", ")", "if", "repo_url", ".", "endswith", "(", "'.git'", ")", ":", "repo_url", ...
get_image_path will determine an image path based on a repo url, removing any token, and taking into account urls that end with .git. :param repo_url: the repo url to parse: :param trailing_path: the trailing path (commit then hash is common)
[ "get_image_path", "will", "determine", "an", "image", "path", "based", "on", "a", "repo", "url", "removing", "any", "token", "and", "taking", "into", "account", "urls", "that", "end", "with", ".", "git", ".", ":", "param", "repo_url", ":", "the", "repo", ...
498c3433724b332f7493fec632d8daf479f47b82
https://github.com/singularityhub/singularity-python/blob/498c3433724b332f7493fec632d8daf479f47b82/singularity/build/google.py#L147-L156
train
This function will determine the path to the image file based on a repo url and the trailing path.
singularityhub/singularity-python
singularity/build/google.py
run_build
def run_build(logfile='/tmp/.shub-log'): '''run_build will generate the Singularity build from a spec_file from a repo_url. If no arguments are required, the metadata api is queried for the values. :param build_dir: directory to do the build in. If not specified, will use temporary. :param spec_fi...
python
def run_build(logfile='/tmp/.shub-log'): '''run_build will generate the Singularity build from a spec_file from a repo_url. If no arguments are required, the metadata api is queried for the values. :param build_dir: directory to do the build in. If not specified, will use temporary. :param spec_fi...
[ "def", "run_build", "(", "logfile", "=", "'/tmp/.shub-log'", ")", ":", "# If we are building the image, this will not be set", "go", "=", "get_build_metadata", "(", "key", "=", "'dobuild'", ")", "if", "go", "==", "None", ":", "sys", ".", "exit", "(", "0", ")", ...
run_build will generate the Singularity build from a spec_file from a repo_url. If no arguments are required, the metadata api is queried for the values. :param build_dir: directory to do the build in. If not specified, will use temporary. :param spec_file: the spec_file name to use, assumed to be in g...
[ "run_build", "will", "generate", "the", "Singularity", "build", "from", "a", "spec_file", "from", "a", "repo_url", "." ]
498c3433724b332f7493fec632d8daf479f47b82
https://github.com/singularityhub/singularity-python/blob/498c3433724b332f7493fec632d8daf479f47b82/singularity/build/google.py#L160-L291
train
This function will generate the Singularity build from a spec_file from a repo_url and then run it.
singularityhub/singularity-python
singularity/build/google.py
finish_build
def finish_build(verbose=True): '''finish_build will finish the build by way of sending the log to the same bucket. the params are loaded from the previous function that built the image, expected in $HOME/params.pkl :: note: this function is currently configured to work with Google Compute Engine me...
python
def finish_build(verbose=True): '''finish_build will finish the build by way of sending the log to the same bucket. the params are loaded from the previous function that built the image, expected in $HOME/params.pkl :: note: this function is currently configured to work with Google Compute Engine me...
[ "def", "finish_build", "(", "verbose", "=", "True", ")", ":", "# If we are building the image, this will not be set", "go", "=", "get_build_metadata", "(", "key", "=", "'dobuild'", ")", "if", "go", "==", "None", ":", "sys", ".", "exit", "(", "0", ")", "# Load ...
finish_build will finish the build by way of sending the log to the same bucket. the params are loaded from the previous function that built the image, expected in $HOME/params.pkl :: note: this function is currently configured to work with Google Compute Engine metadata api, and should (will) be custom...
[ "finish_build", "will", "finish", "the", "build", "by", "way", "of", "sending", "the", "log", "to", "the", "same", "bucket", ".", "the", "params", "are", "loaded", "from", "the", "previous", "function", "that", "built", "the", "image", "expected", "in", "$...
498c3433724b332f7493fec632d8daf479f47b82
https://github.com/singularityhub/singularity-python/blob/498c3433724b332f7493fec632d8daf479f47b82/singularity/build/google.py#L295-L330
train
finish_build will finish the build by way of sending the log to the same bucket
singularityhub/singularity-python
singularity/build/google.py
get_build_metadata
def get_build_metadata(key): '''get_build_metadata will return metadata about an instance from within it. :param key: the key to look up ''' headers = {"Metadata-Flavor":"Google"} url = "http://metadata.google.internal/computeMetadata/v1/instance/attributes/%s" %(key) response = requests...
python
def get_build_metadata(key): '''get_build_metadata will return metadata about an instance from within it. :param key: the key to look up ''' headers = {"Metadata-Flavor":"Google"} url = "http://metadata.google.internal/computeMetadata/v1/instance/attributes/%s" %(key) response = requests...
[ "def", "get_build_metadata", "(", "key", ")", ":", "headers", "=", "{", "\"Metadata-Flavor\"", ":", "\"Google\"", "}", "url", "=", "\"http://metadata.google.internal/computeMetadata/v1/instance/attributes/%s\"", "%", "(", "key", ")", "response", "=", "requests", ".", ...
get_build_metadata will return metadata about an instance from within it. :param key: the key to look up
[ "get_build_metadata", "will", "return", "metadata", "about", "an", "instance", "from", "within", "it", ".", ":", "param", "key", ":", "the", "key", "to", "look", "up" ]
498c3433724b332f7493fec632d8daf479f47b82
https://github.com/singularityhub/singularity-python/blob/498c3433724b332f7493fec632d8daf479f47b82/singularity/build/google.py#L338-L347
train
get_build_metadata will return metadata about an instance from within it
singularityhub/singularity-python
singularity/build/google.py
get_build_params
def get_build_params(metadata): '''get_build_params uses get_build_metadata to retrieve corresponding meta data values for a build :param metadata: a list, each item a dictionary of metadata, in format: metadata = [{'key': 'repo_url', 'value': repo_url }, {'key': 'repo_id', 'value': repo_id ...
python
def get_build_params(metadata): '''get_build_params uses get_build_metadata to retrieve corresponding meta data values for a build :param metadata: a list, each item a dictionary of metadata, in format: metadata = [{'key': 'repo_url', 'value': repo_url }, {'key': 'repo_id', 'value': repo_id ...
[ "def", "get_build_params", "(", "metadata", ")", ":", "params", "=", "dict", "(", ")", "for", "item", "in", "metadata", ":", "if", "item", "[", "'value'", "]", "==", "None", ":", "response", "=", "get_build_metadata", "(", "key", "=", "item", "[", "'ke...
get_build_params uses get_build_metadata to retrieve corresponding meta data values for a build :param metadata: a list, each item a dictionary of metadata, in format: metadata = [{'key': 'repo_url', 'value': repo_url }, {'key': 'repo_id', 'value': repo_id }, {'key': 'credential'...
[ "get_build_params", "uses", "get_build_metadata", "to", "retrieve", "corresponding", "meta", "data", "values", "for", "a", "build", ":", "param", "metadata", ":", "a", "list", "each", "item", "a", "dictionary", "of", "metadata", "in", "format", ":", "metadata", ...
498c3433724b332f7493fec632d8daf479f47b82
https://github.com/singularityhub/singularity-python/blob/498c3433724b332f7493fec632d8daf479f47b82/singularity/build/google.py#L350-L369
train
uses get_build_metadata to retrieve corresponding meta data values for a build
ployground/bsdploy
bsdploy/fabutils.py
rsync
def rsync(*args, **kwargs): """ wrapper around the rsync command. the ssh connection arguments are set automatically. any args are just passed directly to rsync. you can use {host_string} in place of the server. the kwargs are passed on the 'local' fabric command. if not s...
python
def rsync(*args, **kwargs): """ wrapper around the rsync command. the ssh connection arguments are set automatically. any args are just passed directly to rsync. you can use {host_string} in place of the server. the kwargs are passed on the 'local' fabric command. if not s...
[ "def", "rsync", "(", "*", "args", ",", "*", "*", "kwargs", ")", ":", "kwargs", ".", "setdefault", "(", "'capture'", ",", "False", ")", "replacements", "=", "dict", "(", "host_string", "=", "\"{user}@{host}\"", ".", "format", "(", "user", "=", "env", "....
wrapper around the rsync command. the ssh connection arguments are set automatically. any args are just passed directly to rsync. you can use {host_string} in place of the server. the kwargs are passed on the 'local' fabric command. if not set, 'capture' is set to False. ...
[ "wrapper", "around", "the", "rsync", "command", "." ]
096d63b316264931627bed1f8ca8abf7eb517352
https://github.com/ployground/bsdploy/blob/096d63b316264931627bed1f8ca8abf7eb517352/bsdploy/fabutils.py#L23-L53
train
wrapper around the rsync command.
ployground/bsdploy
bsdploy/fabfile_daemonology.py
bootstrap
def bootstrap(**kwargs): """ Bootstrap an EC2 instance that has been booted into an AMI from http://www.daemonology.net/freebsd-on-ec2/ Note: deprecated, current AMI images are basically pre-bootstrapped, they just need to be configured. """ # the user for the image is `ec2-user`, there is no sudo, but ...
python
def bootstrap(**kwargs): """ Bootstrap an EC2 instance that has been booted into an AMI from http://www.daemonology.net/freebsd-on-ec2/ Note: deprecated, current AMI images are basically pre-bootstrapped, they just need to be configured. """ # the user for the image is `ec2-user`, there is no sudo, but ...
[ "def", "bootstrap", "(", "*", "*", "kwargs", ")", ":", "# the user for the image is `ec2-user`, there is no sudo, but we can su to root w/o password", "original_host", "=", "env", ".", "host_string", "env", ".", "host_string", "=", "'ec2-user@%s'", "%", "env", ".", "insta...
Bootstrap an EC2 instance that has been booted into an AMI from http://www.daemonology.net/freebsd-on-ec2/ Note: deprecated, current AMI images are basically pre-bootstrapped, they just need to be configured.
[ "Bootstrap", "an", "EC2", "instance", "that", "has", "been", "booted", "into", "an", "AMI", "from", "http", ":", "//", "www", ".", "daemonology", ".", "net", "/", "freebsd", "-", "on", "-", "ec2", "/", "Note", ":", "deprecated", "current", "AMI", "imag...
096d63b316264931627bed1f8ca8abf7eb517352
https://github.com/ployground/bsdploy/blob/096d63b316264931627bed1f8ca8abf7eb517352/bsdploy/fabfile_daemonology.py#L14-L44
train
Bootstrap an EC2 instance that has been booted into an AMI from http://www. daemonology. net
ployground/bsdploy
bsdploy/fabfile_digitalocean.py
bootstrap
def bootstrap(**kwargs): """Digital Oceans FreeBSD droplets are pretty much already pre-bootstrapped, including having python2.7 and sudo etc. pre-installed. the only thing we need to change is to allow root to login (without a password) enable pf and ensure it is running """ bu = BootstrapUtil...
python
def bootstrap(**kwargs): """Digital Oceans FreeBSD droplets are pretty much already pre-bootstrapped, including having python2.7 and sudo etc. pre-installed. the only thing we need to change is to allow root to login (without a password) enable pf and ensure it is running """ bu = BootstrapUtil...
[ "def", "bootstrap", "(", "*", "*", "kwargs", ")", ":", "bu", "=", "BootstrapUtils", "(", ")", "# (temporarily) set the user to `freebsd`", "original_host", "=", "env", ".", "host_string", "env", ".", "host_string", "=", "'freebsd@%s'", "%", "env", ".", "instance...
Digital Oceans FreeBSD droplets are pretty much already pre-bootstrapped, including having python2.7 and sudo etc. pre-installed. the only thing we need to change is to allow root to login (without a password) enable pf and ensure it is running
[ "Digital", "Oceans", "FreeBSD", "droplets", "are", "pretty", "much", "already", "pre", "-", "bootstrapped", "including", "having", "python2", ".", "7", "and", "sudo", "etc", ".", "pre", "-", "installed", ".", "the", "only", "thing", "we", "need", "to", "ch...
096d63b316264931627bed1f8ca8abf7eb517352
https://github.com/ployground/bsdploy/blob/096d63b316264931627bed1f8ca8abf7eb517352/bsdploy/fabfile_digitalocean.py#L14-L65
train
Bootstrap the FreeBSD droplet into a new root.
ployground/bsdploy
bsdploy/bootstrap_utils.py
BootstrapUtils.bootstrap_files
def bootstrap_files(self): """ we need some files to bootstrap the FreeBSD installation. Some... - need to be provided by the user (i.e. authorized_keys) - others have some (sensible) defaults (i.e. rc.conf) - some can be downloaded via URL (i.e.) http://pkg.freebsd.o...
python
def bootstrap_files(self): """ we need some files to bootstrap the FreeBSD installation. Some... - need to be provided by the user (i.e. authorized_keys) - others have some (sensible) defaults (i.e. rc.conf) - some can be downloaded via URL (i.e.) http://pkg.freebsd.o...
[ "def", "bootstrap_files", "(", "self", ")", ":", "bootstrap_file_yamls", "=", "[", "abspath", "(", "join", "(", "self", ".", "default_template_path", ",", "self", ".", "bootstrap_files_yaml", ")", ")", ",", "abspath", "(", "join", "(", "self", ".", "custom_t...
we need some files to bootstrap the FreeBSD installation. Some... - need to be provided by the user (i.e. authorized_keys) - others have some (sensible) defaults (i.e. rc.conf) - some can be downloaded via URL (i.e.) http://pkg.freebsd.org/freebsd:10:x86:64/latest/Latest/pkg....
[ "we", "need", "some", "files", "to", "bootstrap", "the", "FreeBSD", "installation", ".", "Some", "...", "-", "need", "to", "be", "provided", "by", "the", "user", "(", "i", ".", "e", ".", "authorized_keys", ")", "-", "others", "have", "some", "(", "sens...
096d63b316264931627bed1f8ca8abf7eb517352
https://github.com/ployground/bsdploy/blob/096d63b316264931627bed1f8ca8abf7eb517352/bsdploy/bootstrap_utils.py#L158-L266
train
This method will create a bootstrap file for the FreeBSD installation.
ployground/bsdploy
bsdploy/bootstrap_utils.py
BootstrapUtils.devices
def devices(self): """ computes the name of the disk devices that are suitable installation targets by subtracting CDROM- and USB devices from the list of total mounts. """ install_devices = self.install_devices if 'bootstrap-system-devices' in env.instance.config: ...
python
def devices(self): """ computes the name of the disk devices that are suitable installation targets by subtracting CDROM- and USB devices from the list of total mounts. """ install_devices = self.install_devices if 'bootstrap-system-devices' in env.instance.config: ...
[ "def", "devices", "(", "self", ")", ":", "install_devices", "=", "self", ".", "install_devices", "if", "'bootstrap-system-devices'", "in", "env", ".", "instance", ".", "config", ":", "devices", "=", "set", "(", "env", ".", "instance", ".", "config", "[", "...
computes the name of the disk devices that are suitable installation targets by subtracting CDROM- and USB devices from the list of total mounts.
[ "computes", "the", "name", "of", "the", "disk", "devices", "that", "are", "suitable", "installation", "targets", "by", "subtracting", "CDROM", "-", "and", "USB", "devices", "from", "the", "list", "of", "total", "mounts", "." ]
096d63b316264931627bed1f8ca8abf7eb517352
https://github.com/ployground/bsdploy/blob/096d63b316264931627bed1f8ca8abf7eb517352/bsdploy/bootstrap_utils.py#L372-L386
train
returns the name of the disk devices that are suitable installation targets by subtracting CDROM - and USB devices from the list of total mounts.
ployground/bsdploy
bsdploy/bootstrap_utils.py
BootstrapUtils.fetch_assets
def fetch_assets(self): """ download bootstrap assets to control host. If present on the control host they will be uploaded to the target host during bootstrapping. """ # allow overwrites from the commandline packages = set( env.instance.config.get('bootstrap-packages...
python
def fetch_assets(self): """ download bootstrap assets to control host. If present on the control host they will be uploaded to the target host during bootstrapping. """ # allow overwrites from the commandline packages = set( env.instance.config.get('bootstrap-packages...
[ "def", "fetch_assets", "(", "self", ")", ":", "# allow overwrites from the commandline", "packages", "=", "set", "(", "env", ".", "instance", ".", "config", ".", "get", "(", "'bootstrap-packages'", ",", "''", ")", ".", "split", "(", ")", ")", "packages", "."...
download bootstrap assets to control host. If present on the control host they will be uploaded to the target host during bootstrapping.
[ "download", "bootstrap", "assets", "to", "control", "host", ".", "If", "present", "on", "the", "control", "host", "they", "will", "be", "uploaded", "to", "the", "target", "host", "during", "bootstrapping", "." ]
096d63b316264931627bed1f8ca8abf7eb517352
https://github.com/ployground/bsdploy/blob/096d63b316264931627bed1f8ca8abf7eb517352/bsdploy/bootstrap_utils.py#L457-L474
train
Download bootstrap assets to control host.
david-caro/python-foreman
foreman/client.py
res_to_str
def res_to_str(res): """ :param res: :class:`requests.Response` object Parse the given request and generate an informative string from it """ if 'Authorization' in res.request.headers: res.request.headers['Authorization'] = "*****" return """ #################################### url = %...
python
def res_to_str(res): """ :param res: :class:`requests.Response` object Parse the given request and generate an informative string from it """ if 'Authorization' in res.request.headers: res.request.headers['Authorization'] = "*****" return """ #################################### url = %...
[ "def", "res_to_str", "(", "res", ")", ":", "if", "'Authorization'", "in", "res", ".", "request", ".", "headers", ":", "res", ".", "request", ".", "headers", "[", "'Authorization'", "]", "=", "\"*****\"", "return", "\"\"\"\n####################################\nurl...
:param res: :class:`requests.Response` object Parse the given request and generate an informative string from it
[ ":", "param", "res", ":", ":", "class", ":", "requests", ".", "Response", "object" ]
a81e4c99fe6a9ad56e9758dbe96dd55bca67d3b8
https://github.com/david-caro/python-foreman/blob/a81e4c99fe6a9ad56e9758dbe96dd55bca67d3b8/foreman/client.py#L63-L92
train
Returns a string representation of the given response object.
david-caro/python-foreman
foreman/client.py
parse_resource_definition
def parse_resource_definition(resource_name, resource_dct): """ Returns all the info extracted from a resource section of the apipie json :param resource_name: Name of the resource that is defined by the section :param resrouce_dict: Dictionary as generated by apipie of the resource definition ...
python
def parse_resource_definition(resource_name, resource_dct): """ Returns all the info extracted from a resource section of the apipie json :param resource_name: Name of the resource that is defined by the section :param resrouce_dict: Dictionary as generated by apipie of the resource definition ...
[ "def", "parse_resource_definition", "(", "resource_name", ",", "resource_dct", ")", ":", "new_dict", "=", "{", "'__module__'", ":", "resource_dct", ".", "get", "(", "'__module__'", ",", "__name__", ")", ",", "'__doc__'", ":", "resource_dct", "[", "'full_descriptio...
Returns all the info extracted from a resource section of the apipie json :param resource_name: Name of the resource that is defined by the section :param resrouce_dict: Dictionary as generated by apipie of the resource definition
[ "Returns", "all", "the", "info", "extracted", "from", "a", "resource", "section", "of", "the", "apipie", "json" ]
a81e4c99fe6a9ad56e9758dbe96dd55bca67d3b8
https://github.com/david-caro/python-foreman/blob/a81e4c99fe6a9ad56e9758dbe96dd55bca67d3b8/foreman/client.py#L312-L406
train
Parse a resource definition and return all the info extracted from the resource section of the apipie
david-caro/python-foreman
foreman/client.py
MethodAPIDescription.parse_resource_from_url
def parse_resource_from_url(self, url): """ Returns the appropriate resource name for the given URL. :param url: API URL stub, like: '/api/hosts' :return: Resource name, like 'hosts', or None if not found """ # special case for the api root if url == '/api': ...
python
def parse_resource_from_url(self, url): """ Returns the appropriate resource name for the given URL. :param url: API URL stub, like: '/api/hosts' :return: Resource name, like 'hosts', or None if not found """ # special case for the api root if url == '/api': ...
[ "def", "parse_resource_from_url", "(", "self", ",", "url", ")", ":", "# special case for the api root", "if", "url", "==", "'/api'", ":", "return", "'api'", "elif", "url", "==", "'/katello'", ":", "return", "'katello'", "match", "=", "self", ".", "resource_patte...
Returns the appropriate resource name for the given URL. :param url: API URL stub, like: '/api/hosts' :return: Resource name, like 'hosts', or None if not found
[ "Returns", "the", "appropriate", "resource", "name", "for", "the", "given", "URL", "." ]
a81e4c99fe6a9ad56e9758dbe96dd55bca67d3b8
https://github.com/david-caro/python-foreman/blob/a81e4c99fe6a9ad56e9758dbe96dd55bca67d3b8/foreman/client.py#L137-L152
train
Parse the resource name from the given URL.
david-caro/python-foreman
foreman/client.py
MethodAPIDescription._get_name
def _get_name(self): """ There are three cases, because apipie definitions can have multiple signatures but python does not For example, the api endpoint: /api/myres/:myres_id/subres/:subres_id/subres2 for method *index* will be translated to the api method name: ...
python
def _get_name(self): """ There are three cases, because apipie definitions can have multiple signatures but python does not For example, the api endpoint: /api/myres/:myres_id/subres/:subres_id/subres2 for method *index* will be translated to the api method name: ...
[ "def", "_get_name", "(", "self", ")", ":", "if", "self", ".", "url", ".", "count", "(", "':'", ")", ">", "1", ":", "# /api/one/two/:three/four -> two_:three_four", "base_name", "=", "self", ".", "url", ".", "split", "(", "'/'", ",", "3", ")", "[", "-",...
There are three cases, because apipie definitions can have multiple signatures but python does not For example, the api endpoint: /api/myres/:myres_id/subres/:subres_id/subres2 for method *index* will be translated to the api method name: subres_index_subres2 So ...
[ "There", "are", "three", "cases", "because", "apipie", "definitions", "can", "have", "multiple", "signatures", "but", "python", "does", "not", "For", "example", "the", "api", "endpoint", ":", "/", "api", "/", "myres", "/", ":", "myres_id", "/", "subres", "...
a81e4c99fe6a9ad56e9758dbe96dd55bca67d3b8
https://github.com/david-caro/python-foreman/blob/a81e4c99fe6a9ad56e9758dbe96dd55bca67d3b8/foreman/client.py#L154-L191
train
Get the name of the current object.
david-caro/python-foreman
foreman/client.py
MethodAPIDescription.generate_func
def generate_func(self, as_global=False): """ Generate function for specific method and using specific api :param as_global: if set, will use the global function name, instead of the class method (usually {resource}_{class_method}) when defining the function """ ...
python
def generate_func(self, as_global=False): """ Generate function for specific method and using specific api :param as_global: if set, will use the global function name, instead of the class method (usually {resource}_{class_method}) when defining the function """ ...
[ "def", "generate_func", "(", "self", ",", "as_global", "=", "False", ")", ":", "keywords", "=", "[", "]", "params_def", "=", "[", "]", "params_doc", "=", "\"\"", "original_names", "=", "{", "}", "params", "=", "dict", "(", "(", "param", "[", "'name'", ...
Generate function for specific method and using specific api :param as_global: if set, will use the global function name, instead of the class method (usually {resource}_{class_method}) when defining the function
[ "Generate", "function", "for", "specific", "method", "and", "using", "specific", "api" ]
a81e4c99fe6a9ad56e9758dbe96dd55bca67d3b8
https://github.com/david-caro/python-foreman/blob/a81e4c99fe6a9ad56e9758dbe96dd55bca67d3b8/foreman/client.py#L196-L287
train
Generates function for specific method and using specific api
david-caro/python-foreman
foreman/client.py
MethodAPIDescription.create_param_doc
def create_param_doc(cls, param, prefix=None): """ Generate documentation for single parameter of function :param param: dict contains info about parameter :param sub: prefix string for recursive purposes """ desc = cls.exclude_html_reg.sub('', param['description']).strip...
python
def create_param_doc(cls, param, prefix=None): """ Generate documentation for single parameter of function :param param: dict contains info about parameter :param sub: prefix string for recursive purposes """ desc = cls.exclude_html_reg.sub('', param['description']).strip...
[ "def", "create_param_doc", "(", "cls", ",", "param", ",", "prefix", "=", "None", ")", ":", "desc", "=", "cls", ".", "exclude_html_reg", ".", "sub", "(", "''", ",", "param", "[", "'description'", "]", ")", ".", "strip", "(", ")", "if", "not", "desc", ...
Generate documentation for single parameter of function :param param: dict contains info about parameter :param sub: prefix string for recursive purposes
[ "Generate", "documentation", "for", "single", "parameter", "of", "function", ":", "param", "param", ":", "dict", "contains", "info", "about", "parameter", ":", "param", "sub", ":", "prefix", "string", "for", "recursive", "purposes" ]
a81e4c99fe6a9ad56e9758dbe96dd55bca67d3b8
https://github.com/david-caro/python-foreman/blob/a81e4c99fe6a9ad56e9758dbe96dd55bca67d3b8/foreman/client.py#L290-L309
train
Generate documentation for single parameter of function
david-caro/python-foreman
foreman/client.py
MetaForeman.convert_plugin_def
def convert_plugin_def(http_method, funcs): """ This function parses one of the elements of the definitions dict for a plugin and extracts the relevant information :param http_method: HTTP method that uses (GET, POST, DELETE, ...) :param funcs: functions related to that HTTP met...
python
def convert_plugin_def(http_method, funcs): """ This function parses one of the elements of the definitions dict for a plugin and extracts the relevant information :param http_method: HTTP method that uses (GET, POST, DELETE, ...) :param funcs: functions related to that HTTP met...
[ "def", "convert_plugin_def", "(", "http_method", ",", "funcs", ")", ":", "methods", "=", "[", "]", "if", "http_method", "not", "in", "(", "'GET'", ",", "'PUT'", ",", "'POST'", ",", "'DELETE'", ")", ":", "logger", ".", "error", "(", "'Plugin load failure, H...
This function parses one of the elements of the definitions dict for a plugin and extracts the relevant information :param http_method: HTTP method that uses (GET, POST, DELETE, ...) :param funcs: functions related to that HTTP method
[ "This", "function", "parses", "one", "of", "the", "elements", "of", "the", "definitions", "dict", "for", "a", "plugin", "and", "extracts", "the", "relevant", "information" ]
a81e4c99fe6a9ad56e9758dbe96dd55bca67d3b8
https://github.com/david-caro/python-foreman/blob/a81e4c99fe6a9ad56e9758dbe96dd55bca67d3b8/foreman/client.py#L510-L542
train
This function parses the plugin definition dict for a plugin and extracts the relevant information.
david-caro/python-foreman
scripts/version_manager.py
get_current_version
def get_current_version(repo_path): """ Given a repo will return the version string, according to semantic versioning, counting as non-backwards compatible commit any one with a message header that matches (case insensitive):: sem-ver: .*break.* And as features any commit with a header mat...
python
def get_current_version(repo_path): """ Given a repo will return the version string, according to semantic versioning, counting as non-backwards compatible commit any one with a message header that matches (case insensitive):: sem-ver: .*break.* And as features any commit with a header mat...
[ "def", "get_current_version", "(", "repo_path", ")", ":", "repo", "=", "dulwich", ".", "repo", ".", "Repo", "(", "repo_path", ")", "tags", "=", "get_tags", "(", "repo", ")", "maj_version", "=", "0", "feat_version", "=", "0", "fix_version", "=", "0", "for...
Given a repo will return the version string, according to semantic versioning, counting as non-backwards compatible commit any one with a message header that matches (case insensitive):: sem-ver: .*break.* And as features any commit with a header matching:: sem-ver: feature And count...
[ "Given", "a", "repo", "will", "return", "the", "version", "string", "according", "to", "semantic", "versioning", "counting", "as", "non", "-", "backwards", "compatible", "commit", "any", "one", "with", "a", "message", "header", "that", "matches", "(", "case", ...
a81e4c99fe6a9ad56e9758dbe96dd55bca67d3b8
https://github.com/david-caro/python-foreman/blob/a81e4c99fe6a9ad56e9758dbe96dd55bca67d3b8/scripts/version_manager.py#L402-L435
train
Given a repo will return the current version of the current version
david-caro/python-foreman
scripts/version_manager.py
get_authors
def get_authors(repo_path, from_commit): """ Given a repo and optionally a base revision to start from, will return the list of authors. """ repo = dulwich.repo.Repo(repo_path) refs = get_refs(repo) start_including = False authors = set() if from_commit is None: start_includ...
python
def get_authors(repo_path, from_commit): """ Given a repo and optionally a base revision to start from, will return the list of authors. """ repo = dulwich.repo.Repo(repo_path) refs = get_refs(repo) start_including = False authors = set() if from_commit is None: start_includ...
[ "def", "get_authors", "(", "repo_path", ",", "from_commit", ")", ":", "repo", "=", "dulwich", ".", "repo", ".", "Repo", "(", "repo_path", ")", "refs", "=", "get_refs", "(", "repo", ")", "start_including", "=", "False", "authors", "=", "set", "(", ")", ...
Given a repo and optionally a base revision to start from, will return the list of authors.
[ "Given", "a", "repo", "and", "optionally", "a", "base", "revision", "to", "start", "from", "will", "return", "the", "list", "of", "authors", "." ]
a81e4c99fe6a9ad56e9758dbe96dd55bca67d3b8
https://github.com/david-caro/python-foreman/blob/a81e4c99fe6a9ad56e9758dbe96dd55bca67d3b8/scripts/version_manager.py#L438-L465
train
Given a repo and optionally a base revision to start from will return a list of authors.
pystorm/pystorm
pystorm/spout.py
Spout.emit
def emit( self, tup, tup_id=None, stream=None, direct_task=None, need_task_ids=False ): """Emit a spout Tuple message. :param tup: the Tuple to send to Storm, should contain only JSON-serializable data. :type tup: list or tuple :param tup_id: the ID for t...
python
def emit( self, tup, tup_id=None, stream=None, direct_task=None, need_task_ids=False ): """Emit a spout Tuple message. :param tup: the Tuple to send to Storm, should contain only JSON-serializable data. :type tup: list or tuple :param tup_id: the ID for t...
[ "def", "emit", "(", "self", ",", "tup", ",", "tup_id", "=", "None", ",", "stream", "=", "None", ",", "direct_task", "=", "None", ",", "need_task_ids", "=", "False", ")", ":", "return", "super", "(", "Spout", ",", "self", ")", ".", "emit", "(", "tup...
Emit a spout Tuple message. :param tup: the Tuple to send to Storm, should contain only JSON-serializable data. :type tup: list or tuple :param tup_id: the ID for the Tuple. Leave this blank for an unreliable emit. :type tup_id: str :pa...
[ "Emit", "a", "spout", "Tuple", "message", "." ]
0f853e007c79e03cefdb4a0794423f84dce4c2f3
https://github.com/pystorm/pystorm/blob/0f853e007c79e03cefdb4a0794423f84dce4c2f3/pystorm/spout.py#L50-L82
train
Emit a spout Tuple message.
pystorm/pystorm
pystorm/spout.py
Spout._run
def _run(self): """The inside of ``run``'s infinite loop. Separated out so it can be properly unit tested. """ cmd = self.read_command() if cmd["command"] == "next": self.next_tuple() elif cmd["command"] == "ack": self.ack(cmd["id"]) elif ...
python
def _run(self): """The inside of ``run``'s infinite loop. Separated out so it can be properly unit tested. """ cmd = self.read_command() if cmd["command"] == "next": self.next_tuple() elif cmd["command"] == "ack": self.ack(cmd["id"]) elif ...
[ "def", "_run", "(", "self", ")", ":", "cmd", "=", "self", ".", "read_command", "(", ")", "if", "cmd", "[", "\"command\"", "]", "==", "\"next\"", ":", "self", ".", "next_tuple", "(", ")", "elif", "cmd", "[", "\"command\"", "]", "==", "\"ack\"", ":", ...
The inside of ``run``'s infinite loop. Separated out so it can be properly unit tested.
[ "The", "inside", "of", "run", "s", "infinite", "loop", "." ]
0f853e007c79e03cefdb4a0794423f84dce4c2f3
https://github.com/pystorm/pystorm/blob/0f853e007c79e03cefdb4a0794423f84dce4c2f3/pystorm/spout.py#L100-L118
train
The inside of run so it can be properly unit tested.
pystorm/pystorm
pystorm/spout.py
ReliableSpout.ack
def ack(self, tup_id): """Called when a bolt acknowledges a Tuple in the topology. :param tup_id: the ID of the Tuple that has been fully acknowledged in the topology. :type tup_id: str """ self.failed_tuples.pop(tup_id, None) try: del ...
python
def ack(self, tup_id): """Called when a bolt acknowledges a Tuple in the topology. :param tup_id: the ID of the Tuple that has been fully acknowledged in the topology. :type tup_id: str """ self.failed_tuples.pop(tup_id, None) try: del ...
[ "def", "ack", "(", "self", ",", "tup_id", ")", ":", "self", ".", "failed_tuples", ".", "pop", "(", "tup_id", ",", "None", ")", "try", ":", "del", "self", ".", "unacked_tuples", "[", "tup_id", "]", "except", "KeyError", ":", "self", ".", "logger", "."...
Called when a bolt acknowledges a Tuple in the topology. :param tup_id: the ID of the Tuple that has been fully acknowledged in the topology. :type tup_id: str
[ "Called", "when", "a", "bolt", "acknowledges", "a", "Tuple", "in", "the", "topology", "." ]
0f853e007c79e03cefdb4a0794423f84dce4c2f3
https://github.com/pystorm/pystorm/blob/0f853e007c79e03cefdb4a0794423f84dce4c2f3/pystorm/spout.py#L137-L148
train
Called when a bolt acknowledges a tuple in the topology.
pystorm/pystorm
pystorm/spout.py
ReliableSpout.fail
def fail(self, tup_id): """Called when a Tuple fails in the topology A reliable spout will replay a failed tuple up to ``max_fails`` times. :param tup_id: the ID of the Tuple that has failed in the topology either due to a bolt calling ``fail()`` or a Tuple ...
python
def fail(self, tup_id): """Called when a Tuple fails in the topology A reliable spout will replay a failed tuple up to ``max_fails`` times. :param tup_id: the ID of the Tuple that has failed in the topology either due to a bolt calling ``fail()`` or a Tuple ...
[ "def", "fail", "(", "self", ",", "tup_id", ")", ":", "saved_args", "=", "self", ".", "unacked_tuples", ".", "get", "(", "tup_id", ")", "if", "saved_args", "is", "None", ":", "self", ".", "logger", ".", "error", "(", "\"Received fail for unknown tuple ID: %r\...
Called when a Tuple fails in the topology A reliable spout will replay a failed tuple up to ``max_fails`` times. :param tup_id: the ID of the Tuple that has failed in the topology either due to a bolt calling ``fail()`` or a Tuple timing out. :type...
[ "Called", "when", "a", "Tuple", "fails", "in", "the", "topology" ]
0f853e007c79e03cefdb4a0794423f84dce4c2f3
https://github.com/pystorm/pystorm/blob/0f853e007c79e03cefdb4a0794423f84dce4c2f3/pystorm/spout.py#L150-L181
train
Called when a Tuple fails in the topology.
pystorm/pystorm
pystorm/spout.py
ReliableSpout.emit
def emit( self, tup, tup_id=None, stream=None, direct_task=None, need_task_ids=False ): """Emit a spout Tuple & add metadata about it to `unacked_tuples`. In order for this to work, `tup_id` is a required parameter. See :meth:`Bolt.emit`. """ if tup_id is None: ...
python
def emit( self, tup, tup_id=None, stream=None, direct_task=None, need_task_ids=False ): """Emit a spout Tuple & add metadata about it to `unacked_tuples`. In order for this to work, `tup_id` is a required parameter. See :meth:`Bolt.emit`. """ if tup_id is None: ...
[ "def", "emit", "(", "self", ",", "tup", ",", "tup_id", "=", "None", ",", "stream", "=", "None", ",", "direct_task", "=", "None", ",", "need_task_ids", "=", "False", ")", ":", "if", "tup_id", "is", "None", ":", "raise", "ValueError", "(", "\"You must pr...
Emit a spout Tuple & add metadata about it to `unacked_tuples`. In order for this to work, `tup_id` is a required parameter. See :meth:`Bolt.emit`.
[ "Emit", "a", "spout", "Tuple", "&", "add", "metadata", "about", "it", "to", "unacked_tuples", "." ]
0f853e007c79e03cefdb4a0794423f84dce4c2f3
https://github.com/pystorm/pystorm/blob/0f853e007c79e03cefdb4a0794423f84dce4c2f3/pystorm/spout.py#L183-L206
train
Emit a single entry in the unacked_tuples dictionary.
pystorm/pystorm
pystorm/component.py
remote_pdb_handler
def remote_pdb_handler(signum, frame): """ Handler to drop us into a remote debugger upon receiving SIGUSR1 """ try: from remote_pdb import RemotePdb rdb = RemotePdb(host="127.0.0.1", port=0) rdb.set_trace(frame=frame) except ImportError: log.warning( "remote_pdb...
python
def remote_pdb_handler(signum, frame): """ Handler to drop us into a remote debugger upon receiving SIGUSR1 """ try: from remote_pdb import RemotePdb rdb = RemotePdb(host="127.0.0.1", port=0) rdb.set_trace(frame=frame) except ImportError: log.warning( "remote_pdb...
[ "def", "remote_pdb_handler", "(", "signum", ",", "frame", ")", ":", "try", ":", "from", "remote_pdb", "import", "RemotePdb", "rdb", "=", "RemotePdb", "(", "host", "=", "\"127.0.0.1\"", ",", "port", "=", "0", ")", "rdb", ".", "set_trace", "(", "frame", "=...
Handler to drop us into a remote debugger upon receiving SIGUSR1
[ "Handler", "to", "drop", "us", "into", "a", "remote", "debugger", "upon", "receiving", "SIGUSR1" ]
0f853e007c79e03cefdb4a0794423f84dce4c2f3
https://github.com/pystorm/pystorm/blob/0f853e007c79e03cefdb4a0794423f84dce4c2f3/pystorm/component.py#L50-L63
train
Handler to drop us into a remote debugger upon receiving SIGUSR1
pystorm/pystorm
pystorm/component.py
StormHandler.emit
def emit(self, record): """ Emit a record. If a formatter is specified, it is used to format the record. If exception information is present, it is formatted using traceback.print_exception and sent to Storm. """ try: msg = self.format(record) ...
python
def emit(self, record): """ Emit a record. If a formatter is specified, it is used to format the record. If exception information is present, it is formatted using traceback.print_exception and sent to Storm. """ try: msg = self.format(record) ...
[ "def", "emit", "(", "self", ",", "record", ")", ":", "try", ":", "msg", "=", "self", ".", "format", "(", "record", ")", "level", "=", "_STORM_LOG_LEVELS", ".", "get", "(", "record", ".", "levelname", ".", "lower", "(", ")", ",", "_STORM_LOG_INFO", ")...
Emit a record. If a formatter is specified, it is used to format the record. If exception information is present, it is formatted using traceback.print_exception and sent to Storm.
[ "Emit", "a", "record", "." ]
0f853e007c79e03cefdb4a0794423f84dce4c2f3
https://github.com/pystorm/pystorm/blob/0f853e007c79e03cefdb4a0794423f84dce4c2f3/pystorm/component.py#L78-L93
train
Emit a record to Storm.
pystorm/pystorm
pystorm/component.py
Component._setup_component
def _setup_component(self, storm_conf, context): """Add helpful instance variables to component after initial handshake with Storm. Also configure logging. """ self.topology_name = storm_conf.get("topology.name", "") self.task_id = context.get("taskid", "") self.componen...
python
def _setup_component(self, storm_conf, context): """Add helpful instance variables to component after initial handshake with Storm. Also configure logging. """ self.topology_name = storm_conf.get("topology.name", "") self.task_id = context.get("taskid", "") self.componen...
[ "def", "_setup_component", "(", "self", ",", "storm_conf", ",", "context", ")", ":", "self", ".", "topology_name", "=", "storm_conf", ".", "get", "(", "\"topology.name\"", ",", "\"\"", ")", "self", ".", "task_id", "=", "context", ".", "get", "(", "\"taskid...
Add helpful instance variables to component after initial handshake with Storm. Also configure logging.
[ "Add", "helpful", "instance", "variables", "to", "component", "after", "initial", "handshake", "with", "Storm", ".", "Also", "configure", "logging", "." ]
0f853e007c79e03cefdb4a0794423f84dce4c2f3
https://github.com/pystorm/pystorm/blob/0f853e007c79e03cefdb4a0794423f84dce4c2f3/pystorm/component.py#L230-L300
train
Setup the component with the given storm_conf and context.
pystorm/pystorm
pystorm/component.py
Component.read_handshake
def read_handshake(self): """Read and process an initial handshake message from Storm.""" msg = self.read_message() pid_dir, _conf, _context = msg["pidDir"], msg["conf"], msg["context"] # Write a blank PID file out to the pidDir open(join(pid_dir, str(self.pid)), "w").close() ...
python
def read_handshake(self): """Read and process an initial handshake message from Storm.""" msg = self.read_message() pid_dir, _conf, _context = msg["pidDir"], msg["conf"], msg["context"] # Write a blank PID file out to the pidDir open(join(pid_dir, str(self.pid)), "w").close() ...
[ "def", "read_handshake", "(", "self", ")", ":", "msg", "=", "self", ".", "read_message", "(", ")", "pid_dir", ",", "_conf", ",", "_context", "=", "msg", "[", "\"pidDir\"", "]", ",", "msg", "[", "\"conf\"", "]", ",", "msg", "[", "\"context\"", "]", "#...
Read and process an initial handshake message from Storm.
[ "Read", "and", "process", "an", "initial", "handshake", "message", "from", "Storm", "." ]
0f853e007c79e03cefdb4a0794423f84dce4c2f3
https://github.com/pystorm/pystorm/blob/0f853e007c79e03cefdb4a0794423f84dce4c2f3/pystorm/component.py#L326-L335
train
Read and process an initial handshake message from Storm.
pystorm/pystorm
pystorm/component.py
Component.send_message
def send_message(self, message): """Send a message to Storm via stdout.""" if not isinstance(message, dict): logger = self.logger if self.logger else log logger.error( "%s.%d attempted to send a non dict message to Storm: " "%r", self.component_nam...
python
def send_message(self, message): """Send a message to Storm via stdout.""" if not isinstance(message, dict): logger = self.logger if self.logger else log logger.error( "%s.%d attempted to send a non dict message to Storm: " "%r", self.component_nam...
[ "def", "send_message", "(", "self", ",", "message", ")", ":", "if", "not", "isinstance", "(", "message", ",", "dict", ")", ":", "logger", "=", "self", ".", "logger", "if", "self", ".", "logger", "else", "log", "logger", ".", "error", "(", "\"%s.%d atte...
Send a message to Storm via stdout.
[ "Send", "a", "message", "to", "Storm", "via", "stdout", "." ]
0f853e007c79e03cefdb4a0794423f84dce4c2f3
https://github.com/pystorm/pystorm/blob/0f853e007c79e03cefdb4a0794423f84dce4c2f3/pystorm/component.py#L337-L348
train
Send a message to Storm via stdout.
pystorm/pystorm
pystorm/component.py
Component.raise_exception
def raise_exception(self, exception, tup=None): """Report an exception back to Storm via logging. :param exception: a Python exception. :param tup: a :class:`Tuple` object. """ if tup: message = ( "Python {exception_name} raised while processing Tuple...
python
def raise_exception(self, exception, tup=None): """Report an exception back to Storm via logging. :param exception: a Python exception. :param tup: a :class:`Tuple` object. """ if tup: message = ( "Python {exception_name} raised while processing Tuple...
[ "def", "raise_exception", "(", "self", ",", "exception", ",", "tup", "=", "None", ")", ":", "if", "tup", ":", "message", "=", "(", "\"Python {exception_name} raised while processing Tuple \"", "\"{tup!r}\\n{traceback}\"", ")", "else", ":", "message", "=", "\"Python ...
Report an exception back to Storm via logging. :param exception: a Python exception. :param tup: a :class:`Tuple` object.
[ "Report", "an", "exception", "back", "to", "Storm", "via", "logging", "." ]
0f853e007c79e03cefdb4a0794423f84dce4c2f3
https://github.com/pystorm/pystorm/blob/0f853e007c79e03cefdb4a0794423f84dce4c2f3/pystorm/component.py#L350-L367
train
Report an exception back to Storm via logging.
pystorm/pystorm
pystorm/component.py
Component.log
def log(self, message, level=None): """Log a message to Storm optionally providing a logging level. :param message: the log message to send to Storm. :type message: str :param level: the logging level that Storm should use when writing the ``message``. Can be one o...
python
def log(self, message, level=None): """Log a message to Storm optionally providing a logging level. :param message: the log message to send to Storm. :type message: str :param level: the logging level that Storm should use when writing the ``message``. Can be one o...
[ "def", "log", "(", "self", ",", "message", ",", "level", "=", "None", ")", ":", "level", "=", "_STORM_LOG_LEVELS", ".", "get", "(", "level", ",", "_STORM_LOG_INFO", ")", "self", ".", "send_message", "(", "{", "\"command\"", ":", "\"log\"", ",", "\"msg\""...
Log a message to Storm optionally providing a logging level. :param message: the log message to send to Storm. :type message: str :param level: the logging level that Storm should use when writing the ``message``. Can be one of: trace, debug, info, warn, or ...
[ "Log", "a", "message", "to", "Storm", "optionally", "providing", "a", "logging", "level", "." ]
0f853e007c79e03cefdb4a0794423f84dce4c2f3
https://github.com/pystorm/pystorm/blob/0f853e007c79e03cefdb4a0794423f84dce4c2f3/pystorm/component.py#L384-L404
train
Log a message to Storm optionally providing a logging level.
pystorm/pystorm
pystorm/component.py
Component.emit
def emit( self, tup, tup_id=None, stream=None, anchors=None, direct_task=None, need_task_ids=False, ): """Emit a new Tuple to a stream. :param tup: the Tuple payload to send to Storm, should contain only JSON-serializable d...
python
def emit( self, tup, tup_id=None, stream=None, anchors=None, direct_task=None, need_task_ids=False, ): """Emit a new Tuple to a stream. :param tup: the Tuple payload to send to Storm, should contain only JSON-serializable d...
[ "def", "emit", "(", "self", ",", "tup", ",", "tup_id", "=", "None", ",", "stream", "=", "None", ",", "anchors", "=", "None", ",", "direct_task", "=", "None", ",", "need_task_ids", "=", "False", ",", ")", ":", "if", "not", "isinstance", "(", "tup", ...
Emit a new Tuple to a stream. :param tup: the Tuple payload to send to Storm, should contain only JSON-serializable data. :type tup: :class:`list` or :class:`pystorm.component.Tuple` :param tup_id: the ID for the Tuple. If omitted by a :class:`pystorm....
[ "Emit", "a", "new", "Tuple", "to", "a", "stream", "." ]
0f853e007c79e03cefdb4a0794423f84dce4c2f3
https://github.com/pystorm/pystorm/blob/0f853e007c79e03cefdb4a0794423f84dce4c2f3/pystorm/component.py#L406-L478
train
Emit a new tuple to a stream.
pystorm/pystorm
pystorm/component.py
Component.run
def run(self): """Main run loop for all components. Performs initial handshake with Storm and reads Tuples handing them off to subclasses. Any exceptions are caught and logged back to Storm prior to the Python process exiting. .. warning:: Subclasses should **not*...
python
def run(self): """Main run loop for all components. Performs initial handshake with Storm and reads Tuples handing them off to subclasses. Any exceptions are caught and logged back to Storm prior to the Python process exiting. .. warning:: Subclasses should **not*...
[ "def", "run", "(", "self", ")", ":", "storm_conf", ",", "context", "=", "self", ".", "read_handshake", "(", ")", "self", ".", "_setup_component", "(", "storm_conf", ",", "context", ")", "self", ".", "initialize", "(", "storm_conf", ",", "context", ")", "...
Main run loop for all components. Performs initial handshake with Storm and reads Tuples handing them off to subclasses. Any exceptions are caught and logged back to Storm prior to the Python process exiting. .. warning:: Subclasses should **not** override this method.
[ "Main", "run", "loop", "for", "all", "components", "." ]
0f853e007c79e03cefdb4a0794423f84dce4c2f3
https://github.com/pystorm/pystorm/blob/0f853e007c79e03cefdb4a0794423f84dce4c2f3/pystorm/component.py#L504-L542
train
Main run loop for all components.