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
1 value
deepmind/sonnet
sonnet/python/modules/conv.py
_ConvND._pad_input
def _pad_input(self, inputs): """Pad input in case the desired padding type requires it. VALID and SAME padding types are directly supported by tensorflow convolution ops, so don't require us to pad input ourselves, at least in cases where the same method is used for all dimensions. Other padding ...
python
def _pad_input(self, inputs): """Pad input in case the desired padding type requires it. VALID and SAME padding types are directly supported by tensorflow convolution ops, so don't require us to pad input ourselves, at least in cases where the same method is used for all dimensions. Other padding ...
[ "def", "_pad_input", "(", "self", ",", "inputs", ")", ":", "if", "all", "(", "p", "==", "self", ".", "_conv_op_padding", "for", "p", "in", "self", ".", "_padding", ")", ":", "# All axes require the same padding type that we're going to use for the", "# underlying co...
Pad input in case the desired padding type requires it. VALID and SAME padding types are directly supported by tensorflow convolution ops, so don't require us to pad input ourselves, at least in cases where the same method is used for all dimensions. Other padding types (FULL, CAUSAL, REVERSE_CAUSAL) ...
[ "Pad", "input", "in", "case", "the", "desired", "padding", "type", "requires", "it", "." ]
00612ca3178964d86b556e062694d808ff81fcca
https://github.com/deepmind/sonnet/blob/00612ca3178964d86b556e062694d808ff81fcca/sonnet/python/modules/conv.py#L572-L626
train
deepmind/sonnet
sonnet/python/modules/conv.py
_ConvND._apply_conv
def _apply_conv(self, inputs, w): """Apply a convolution operation on `inputs` using variable `w`. Args: inputs: A Tensor of shape `data_format` and of type `tf.float16`, `tf.bfloat16` or `tf.float32`. w: A weight matrix of the same type as `inputs`. Returns: outputs: The resul...
python
def _apply_conv(self, inputs, w): """Apply a convolution operation on `inputs` using variable `w`. Args: inputs: A Tensor of shape `data_format` and of type `tf.float16`, `tf.bfloat16` or `tf.float32`. w: A weight matrix of the same type as `inputs`. Returns: outputs: The resul...
[ "def", "_apply_conv", "(", "self", ",", "inputs", ",", "w", ")", ":", "outputs", "=", "tf", ".", "nn", ".", "convolution", "(", "inputs", ",", "w", ",", "strides", "=", "self", ".", "_stride", ",", "padding", "=", "self", ".", "_conv_op_padding", ","...
Apply a convolution operation on `inputs` using variable `w`. Args: inputs: A Tensor of shape `data_format` and of type `tf.float16`, `tf.bfloat16` or `tf.float32`. w: A weight matrix of the same type as `inputs`. Returns: outputs: The result of the convolution operation on `inputs...
[ "Apply", "a", "convolution", "operation", "on", "inputs", "using", "variable", "w", "." ]
00612ca3178964d86b556e062694d808ff81fcca
https://github.com/deepmind/sonnet/blob/00612ca3178964d86b556e062694d808ff81fcca/sonnet/python/modules/conv.py#L628-L643
train
deepmind/sonnet
sonnet/python/modules/conv.py
_ConvND._apply_mask
def _apply_mask(self): """Applies the passed-in mask to the convolution matrix. Returns: w: A copy of the convolution matrix that has had the mask applied. Raises: base.IncompatibleShapeError: If the mask shape has more dimensions than the weight matrix. base.IncompatibleShapeE...
python
def _apply_mask(self): """Applies the passed-in mask to the convolution matrix. Returns: w: A copy of the convolution matrix that has had the mask applied. Raises: base.IncompatibleShapeError: If the mask shape has more dimensions than the weight matrix. base.IncompatibleShapeE...
[ "def", "_apply_mask", "(", "self", ")", ":", "w", "=", "self", ".", "_w", "w_shape", "=", "w", ".", "get_shape", "(", ")", "mask_shape", "=", "self", ".", "_mask", ".", "get_shape", "(", ")", "if", "mask_shape", ".", "ndims", ">", "w_shape", ".", "...
Applies the passed-in mask to the convolution matrix. Returns: w: A copy of the convolution matrix that has had the mask applied. Raises: base.IncompatibleShapeError: If the mask shape has more dimensions than the weight matrix. base.IncompatibleShapeError: If the mask and the weig...
[ "Applies", "the", "passed", "-", "in", "mask", "to", "the", "convolution", "matrix", "." ]
00612ca3178964d86b556e062694d808ff81fcca
https://github.com/deepmind/sonnet/blob/00612ca3178964d86b556e062694d808ff81fcca/sonnet/python/modules/conv.py#L673-L710
train
deepmind/sonnet
sonnet/python/modules/conv.py
_ConvND.output_channels
def output_channels(self): """Returns the number of output channels.""" if callable(self._output_channels): self._output_channels = self._output_channels() # Channel must be integer. self._output_channels = int(self._output_channels) return self._output_channels
python
def output_channels(self): """Returns the number of output channels.""" if callable(self._output_channels): self._output_channels = self._output_channels() # Channel must be integer. self._output_channels = int(self._output_channels) return self._output_channels
[ "def", "output_channels", "(", "self", ")", ":", "if", "callable", "(", "self", ".", "_output_channels", ")", ":", "self", ".", "_output_channels", "=", "self", ".", "_output_channels", "(", ")", "# Channel must be integer.", "self", ".", "_output_channels", "="...
Returns the number of output channels.
[ "Returns", "the", "number", "of", "output", "channels", "." ]
00612ca3178964d86b556e062694d808ff81fcca
https://github.com/deepmind/sonnet/blob/00612ca3178964d86b556e062694d808ff81fcca/sonnet/python/modules/conv.py#L713-L719
train
deepmind/sonnet
sonnet/python/modules/conv.py
_ConvND.padding
def padding(self): """Returns the padding algorithm used, if this is the same for all dims. Use `.paddings` if you want a tuple with the padding algorithm used for each dimension. Returns: The padding algorithm used, if this is the same for all dimensions. Raises: ValueError: If diffe...
python
def padding(self): """Returns the padding algorithm used, if this is the same for all dims. Use `.paddings` if you want a tuple with the padding algorithm used for each dimension. Returns: The padding algorithm used, if this is the same for all dimensions. Raises: ValueError: If diffe...
[ "def", "padding", "(", "self", ")", ":", "# This is for backwards compatibility -- previously only a single", "# padding setting was supported across all dimensions.", "if", "all", "(", "p", "==", "self", ".", "_padding", "[", "0", "]", "for", "p", "in", "self", ".", ...
Returns the padding algorithm used, if this is the same for all dims. Use `.paddings` if you want a tuple with the padding algorithm used for each dimension. Returns: The padding algorithm used, if this is the same for all dimensions. Raises: ValueError: If different padding algorithms ar...
[ "Returns", "the", "padding", "algorithm", "used", "if", "this", "is", "the", "same", "for", "all", "dims", "." ]
00612ca3178964d86b556e062694d808ff81fcca
https://github.com/deepmind/sonnet/blob/00612ca3178964d86b556e062694d808ff81fcca/sonnet/python/modules/conv.py#L739-L759
train
deepmind/sonnet
sonnet/python/modules/conv.py
_ConvND.clone
def clone(self, name=None): """Returns a cloned `_ConvND` module. Args: name: Optional string assigning name of cloned module. The default name is constructed by appending "_clone" to `self.module_name`. Returns: A copy of the current class. """ if name is None: name = se...
python
def clone(self, name=None): """Returns a cloned `_ConvND` module. Args: name: Optional string assigning name of cloned module. The default name is constructed by appending "_clone" to `self.module_name`. Returns: A copy of the current class. """ if name is None: name = se...
[ "def", "clone", "(", "self", ",", "name", "=", "None", ")", ":", "if", "name", "is", "None", ":", "name", "=", "self", ".", "module_name", "+", "\"_clone\"", "return", "type", "(", "self", ")", "(", "output_channels", "=", "self", ".", "output_channels...
Returns a cloned `_ConvND` module. Args: name: Optional string assigning name of cloned module. The default name is constructed by appending "_clone" to `self.module_name`. Returns: A copy of the current class.
[ "Returns", "a", "cloned", "_ConvND", "module", "." ]
00612ca3178964d86b556e062694d808ff81fcca
https://github.com/deepmind/sonnet/blob/00612ca3178964d86b556e062694d808ff81fcca/sonnet/python/modules/conv.py#L839-L864
train
deepmind/sonnet
sonnet/python/modules/conv.py
_ConvNDTranspose._build
def _build(self, inputs): """Connects the _ConvNDTranspose module into the graph. If this is not the first time the module has been connected to the graph, the input Tensor provided here must have the same final N dimensions, in order for the existing variables to be the correct size for the multip...
python
def _build(self, inputs): """Connects the _ConvNDTranspose module into the graph. If this is not the first time the module has been connected to the graph, the input Tensor provided here must have the same final N dimensions, in order for the existing variables to be the correct size for the multip...
[ "def", "_build", "(", "self", ",", "inputs", ")", ":", "_verify_inputs", "(", "inputs", ",", "self", ".", "_channel_index", ",", "self", ".", "_data_format", ")", "self", ".", "_input_shape", "=", "tuple", "(", "inputs", ".", "get_shape", "(", ")", ".", ...
Connects the _ConvNDTranspose module into the graph. If this is not the first time the module has been connected to the graph, the input Tensor provided here must have the same final N dimensions, in order for the existing variables to be the correct size for the multiplication. The batch size may diff...
[ "Connects", "the", "_ConvNDTranspose", "module", "into", "the", "graph", "." ]
00612ca3178964d86b556e062694d808ff81fcca
https://github.com/deepmind/sonnet/blob/00612ca3178964d86b556e062694d808ff81fcca/sonnet/python/modules/conv.py#L994-L1093
train
deepmind/sonnet
sonnet/python/modules/conv.py
_ConvNDTranspose._infer_all_output_dims
def _infer_all_output_dims(self, inputs): """Calculate the output shape for `inputs` after a deconvolution. Args: inputs: A Tensor of shape `data_format` and of type `tf.float16`, `tf.bfloat16` or `tf.float32`. Returns: output_shape: A tensor of shape (`batch_size`, `conv_output_shap...
python
def _infer_all_output_dims(self, inputs): """Calculate the output shape for `inputs` after a deconvolution. Args: inputs: A Tensor of shape `data_format` and of type `tf.float16`, `tf.bfloat16` or `tf.float32`. Returns: output_shape: A tensor of shape (`batch_size`, `conv_output_shap...
[ "def", "_infer_all_output_dims", "(", "self", ",", "inputs", ")", ":", "# Use tensorflow shape op to manipulate inputs shape, so that unknown batch", "# size - which can happen when using input placeholders - is handled", "# correcly.", "batch_size", "=", "tf", ".", "expand_dims", "(...
Calculate the output shape for `inputs` after a deconvolution. Args: inputs: A Tensor of shape `data_format` and of type `tf.float16`, `tf.bfloat16` or `tf.float32`. Returns: output_shape: A tensor of shape (`batch_size`, `conv_output_shape`).
[ "Calculate", "the", "output", "shape", "for", "inputs", "after", "a", "deconvolution", "." ]
00612ca3178964d86b556e062694d808ff81fcca
https://github.com/deepmind/sonnet/blob/00612ca3178964d86b556e062694d808ff81fcca/sonnet/python/modules/conv.py#L1128-L1157
train
deepmind/sonnet
sonnet/python/modules/conv.py
_ConvNDTranspose._recover_shape_information
def _recover_shape_information(self, inputs, outputs): """Recover output tensor shape value to enable shape inference. The batch size of `inputs` isn't preserved by the convolution op. Calculate what the proper output shape will be for `outputs`. Args: inputs: A Tensor of shape `data_format` and...
python
def _recover_shape_information(self, inputs, outputs): """Recover output tensor shape value to enable shape inference. The batch size of `inputs` isn't preserved by the convolution op. Calculate what the proper output shape will be for `outputs`. Args: inputs: A Tensor of shape `data_format` and...
[ "def", "_recover_shape_information", "(", "self", ",", "inputs", ",", "outputs", ")", ":", "batch_size_value", "=", "inputs", ".", "get_shape", "(", ")", "[", "0", "]", "if", "self", ".", "_data_format", ".", "startswith", "(", "\"NC\"", ")", ":", "output_...
Recover output tensor shape value to enable shape inference. The batch size of `inputs` isn't preserved by the convolution op. Calculate what the proper output shape will be for `outputs`. Args: inputs: A Tensor of shape `data_format` and of type `tf.float16`, `tf.bfloat16` or `tf.float32`...
[ "Recover", "output", "tensor", "shape", "value", "to", "enable", "shape", "inference", "." ]
00612ca3178964d86b556e062694d808ff81fcca
https://github.com/deepmind/sonnet/blob/00612ca3178964d86b556e062694d808ff81fcca/sonnet/python/modules/conv.py#L1159-L1183
train
deepmind/sonnet
sonnet/python/modules/conv.py
_ConvNDTranspose.output_shape
def output_shape(self): """Returns the output shape.""" if self._output_shape is None: self._ensure_is_connected() if callable(self._output_shape): self._output_shape = tuple(self._output_shape()) return self._output_shape
python
def output_shape(self): """Returns the output shape.""" if self._output_shape is None: self._ensure_is_connected() if callable(self._output_shape): self._output_shape = tuple(self._output_shape()) return self._output_shape
[ "def", "output_shape", "(", "self", ")", ":", "if", "self", ".", "_output_shape", "is", "None", ":", "self", ".", "_ensure_is_connected", "(", ")", "if", "callable", "(", "self", ".", "_output_shape", ")", ":", "self", ".", "_output_shape", "=", "tuple", ...
Returns the output shape.
[ "Returns", "the", "output", "shape", "." ]
00612ca3178964d86b556e062694d808ff81fcca
https://github.com/deepmind/sonnet/blob/00612ca3178964d86b556e062694d808ff81fcca/sonnet/python/modules/conv.py#L1205-L1211
train
deepmind/sonnet
sonnet/python/modules/conv.py
Conv1DTranspose.transpose
def transpose(self, name=None): """Returns matching `Conv1D` module. Args: name: Optional string assigning name of transpose module. The default name is constructed by appending "_transpose" to `self.name`. Returns: `Conv1D` module. """ if name is None: name = self.module...
python
def transpose(self, name=None): """Returns matching `Conv1D` module. Args: name: Optional string assigning name of transpose module. The default name is constructed by appending "_transpose" to `self.name`. Returns: `Conv1D` module. """ if name is None: name = self.module...
[ "def", "transpose", "(", "self", ",", "name", "=", "None", ")", ":", "if", "name", "is", "None", ":", "name", "=", "self", ".", "module_name", "+", "\"_transpose\"", "if", "self", ".", "_data_format", "==", "DATA_FORMAT_NWC", ":", "stride", "=", "self", ...
Returns matching `Conv1D` module. Args: name: Optional string assigning name of transpose module. The default name is constructed by appending "_transpose" to `self.name`. Returns: `Conv1D` module.
[ "Returns", "matching", "Conv1D", "module", "." ]
00612ca3178964d86b556e062694d808ff81fcca
https://github.com/deepmind/sonnet/blob/00612ca3178964d86b556e062694d808ff81fcca/sonnet/python/modules/conv.py#L1517-L1545
train
deepmind/sonnet
sonnet/python/modules/conv.py
Conv2D.transpose
def transpose(self, name=None): """Returns matching `Conv2DTranspose` module. Args: name: Optional string assigning name of transpose module. The default name is constructed by appending "_transpose" to `self.name`. Returns: `Conv2DTranspose` module. Raises: base.NotSupported...
python
def transpose(self, name=None): """Returns matching `Conv2DTranspose` module. Args: name: Optional string assigning name of transpose module. The default name is constructed by appending "_transpose" to `self.name`. Returns: `Conv2DTranspose` module. Raises: base.NotSupported...
[ "def", "transpose", "(", "self", ",", "name", "=", "None", ")", ":", "if", "any", "(", "x", ">", "1", "for", "x", "in", "self", ".", "_rate", ")", ":", "raise", "base", ".", "NotSupportedError", "(", "\"Cannot transpose a dilated convolution module.\"", ")...
Returns matching `Conv2DTranspose` module. Args: name: Optional string assigning name of transpose module. The default name is constructed by appending "_transpose" to `self.name`. Returns: `Conv2DTranspose` module. Raises: base.NotSupportedError: If `rate` in any dimension > 1.
[ "Returns", "matching", "Conv2DTranspose", "module", "." ]
00612ca3178964d86b556e062694d808ff81fcca
https://github.com/deepmind/sonnet/blob/00612ca3178964d86b556e062694d808ff81fcca/sonnet/python/modules/conv.py#L1760-L1802
train
deepmind/sonnet
sonnet/python/modules/conv.py
Conv2DTranspose.transpose
def transpose(self, name=None): """Returns matching `Conv2D` module. Args: name: Optional string assigning name of transpose module. The default name is constructed by appending "_transpose" to `self.name`. Returns: `Conv2D` module. """ if name is None: name = self.modu...
python
def transpose(self, name=None): """Returns matching `Conv2D` module. Args: name: Optional string assigning name of transpose module. The default name is constructed by appending "_transpose" to `self.name`. Returns: `Conv2D` module. """ if name is None: name = self.modu...
[ "def", "transpose", "(", "self", ",", "name", "=", "None", ")", ":", "if", "name", "is", "None", ":", "name", "=", "self", ".", "module_name", "+", "\"_transpose\"", "if", "self", ".", "_data_format", "==", "DATA_FORMAT_NHWC", ":", "stride", "=", "self",...
Returns matching `Conv2D` module. Args: name: Optional string assigning name of transpose module. The default name is constructed by appending "_transpose" to `self.name`. Returns: `Conv2D` module.
[ "Returns", "matching", "Conv2D", "module", "." ]
00612ca3178964d86b556e062694d808ff81fcca
https://github.com/deepmind/sonnet/blob/00612ca3178964d86b556e062694d808ff81fcca/sonnet/python/modules/conv.py#L1892-L1920
train
deepmind/sonnet
sonnet/python/modules/conv.py
InPlaneConv2D._construct_w
def _construct_w(self, inputs): """Construct the convolution weight matrix. Figures out the shape of the weight matrix, initialize it, and return it. Args: inputs: A Tensor of shape `data_format` and of type `tf.float16`, `tf.bfloat16` or `tf.float32`. Returns: w: A weight matri...
python
def _construct_w(self, inputs): """Construct the convolution weight matrix. Figures out the shape of the weight matrix, initialize it, and return it. Args: inputs: A Tensor of shape `data_format` and of type `tf.float16`, `tf.bfloat16` or `tf.float32`. Returns: w: A weight matri...
[ "def", "_construct_w", "(", "self", ",", "inputs", ")", ":", "weight_shape", "=", "self", ".", "_kernel_shape", "+", "(", "1", ",", "1", ")", "if", "\"w\"", "not", "in", "self", ".", "_initializers", ":", "self", ".", "_initializers", "[", "\"w\"", "]"...
Construct the convolution weight matrix. Figures out the shape of the weight matrix, initialize it, and return it. Args: inputs: A Tensor of shape `data_format` and of type `tf.float16`, `tf.bfloat16` or `tf.float32`. Returns: w: A weight matrix of the same type as `inputs` and of s...
[ "Construct", "the", "convolution", "weight", "matrix", "." ]
00612ca3178964d86b556e062694d808ff81fcca
https://github.com/deepmind/sonnet/blob/00612ca3178964d86b556e062694d808ff81fcca/sonnet/python/modules/conv.py#L2270-L2295
train
deepmind/sonnet
sonnet/python/modules/conv.py
InPlaneConv2D._apply_conv
def _apply_conv(self, inputs, w): """Apply a depthwise_conv2d operation on `inputs` using variable `w`. Args: inputs: A Tensor of shape `data_format` and of type `tf.float16`, `tf.bfloat16` or `tf.float32`. w: A weight matrix of the same type as `inputs`. Returns: outputs: The ...
python
def _apply_conv(self, inputs, w): """Apply a depthwise_conv2d operation on `inputs` using variable `w`. Args: inputs: A Tensor of shape `data_format` and of type `tf.float16`, `tf.bfloat16` or `tf.float32`. w: A weight matrix of the same type as `inputs`. Returns: outputs: The ...
[ "def", "_apply_conv", "(", "self", ",", "inputs", ",", "w", ")", ":", "tiled_weights", "=", "tf", ".", "tile", "(", "w", ",", "[", "1", ",", "1", ",", "self", ".", "_input_channels", ",", "1", "]", ")", "outputs", "=", "tf", ".", "nn", ".", "de...
Apply a depthwise_conv2d operation on `inputs` using variable `w`. Args: inputs: A Tensor of shape `data_format` and of type `tf.float16`, `tf.bfloat16` or `tf.float32`. w: A weight matrix of the same type as `inputs`. Returns: outputs: The result of the convolution operation on `i...
[ "Apply", "a", "depthwise_conv2d", "operation", "on", "inputs", "using", "variable", "w", "." ]
00612ca3178964d86b556e062694d808ff81fcca
https://github.com/deepmind/sonnet/blob/00612ca3178964d86b556e062694d808ff81fcca/sonnet/python/modules/conv.py#L2297-L2314
train
deepmind/sonnet
sonnet/python/modules/conv.py
SeparableConv2D._construct_w
def _construct_w(self, inputs): """Connects the module into the graph, with input Tensor `inputs`. Args: inputs: A 4D Tensor of shape: [batch_size, input_height, input_width, input_channels] and of type `tf.float16`, `tf.bfloat16` or `tf.float32`. Returns: A tuple of two 4D...
python
def _construct_w(self, inputs): """Connects the module into the graph, with input Tensor `inputs`. Args: inputs: A 4D Tensor of shape: [batch_size, input_height, input_width, input_channels] and of type `tf.float16`, `tf.bfloat16` or `tf.float32`. Returns: A tuple of two 4D...
[ "def", "_construct_w", "(", "self", ",", "inputs", ")", ":", "depthwise_weight_shape", "=", "self", ".", "_kernel_shape", "+", "(", "self", ".", "_input_channels", ",", "self", ".", "_channel_multiplier", ")", "pointwise_input_size", "=", "self", ".", "_channel_...
Connects the module into the graph, with input Tensor `inputs`. Args: inputs: A 4D Tensor of shape: [batch_size, input_height, input_width, input_channels] and of type `tf.float16`, `tf.bfloat16` or `tf.float32`. Returns: A tuple of two 4D Tensors, each with the same dtype as `...
[ "Connects", "the", "module", "into", "the", "graph", "with", "input", "Tensor", "inputs", "." ]
00612ca3178964d86b556e062694d808ff81fcca
https://github.com/deepmind/sonnet/blob/00612ca3178964d86b556e062694d808ff81fcca/sonnet/python/modules/conv.py#L2631-L2677
train
deepmind/sonnet
sonnet/python/modules/conv.py
SeparableConv2D._apply_conv
def _apply_conv(self, inputs, w): """Apply a `separable_conv2d` operation on `inputs` using `w`. Args: inputs: A Tensor of shape `data_format` and of type `tf.float16`, `tf.bfloat16` or `tf.float32`. w: A tuple of weight matrices of the same type as `inputs`, the first being the d...
python
def _apply_conv(self, inputs, w): """Apply a `separable_conv2d` operation on `inputs` using `w`. Args: inputs: A Tensor of shape `data_format` and of type `tf.float16`, `tf.bfloat16` or `tf.float32`. w: A tuple of weight matrices of the same type as `inputs`, the first being the d...
[ "def", "_apply_conv", "(", "self", ",", "inputs", ",", "w", ")", ":", "w_dw", ",", "w_pw", "=", "w", "outputs", "=", "tf", ".", "nn", ".", "separable_conv2d", "(", "inputs", ",", "w_dw", ",", "w_pw", ",", "rate", "=", "self", ".", "_rate", ",", "...
Apply a `separable_conv2d` operation on `inputs` using `w`. Args: inputs: A Tensor of shape `data_format` and of type `tf.float16`, `tf.bfloat16` or `tf.float32`. w: A tuple of weight matrices of the same type as `inputs`, the first being the depthwise weight matrix, and the second be...
[ "Apply", "a", "separable_conv2d", "operation", "on", "inputs", "using", "w", "." ]
00612ca3178964d86b556e062694d808ff81fcca
https://github.com/deepmind/sonnet/blob/00612ca3178964d86b556e062694d808ff81fcca/sonnet/python/modules/conv.py#L2679-L2700
train
deepmind/sonnet
sonnet/python/modules/conv.py
SeparableConv1D._apply_conv
def _apply_conv(self, inputs, w): """Apply a `separable_conv2d` operation on `inputs` using `w`. Args: inputs: A Tensor of shape `data_format` and of type `tf.float16`, `tf.bfloat16` or `tf.float32`. w: A tuple of weight matrices of the same type as `inputs`, the first being the d...
python
def _apply_conv(self, inputs, w): """Apply a `separable_conv2d` operation on `inputs` using `w`. Args: inputs: A Tensor of shape `data_format` and of type `tf.float16`, `tf.bfloat16` or `tf.float32`. w: A tuple of weight matrices of the same type as `inputs`, the first being the d...
[ "def", "_apply_conv", "(", "self", ",", "inputs", ",", "w", ")", ":", "if", "self", ".", "_data_format", "==", "DATA_FORMAT_NWC", ":", "h_dim", "=", "1", "two_dim_conv_data_format", "=", "DATA_FORMAT_NHWC", "else", ":", "h_dim", "=", "2", "two_dim_conv_data_fo...
Apply a `separable_conv2d` operation on `inputs` using `w`. Args: inputs: A Tensor of shape `data_format` and of type `tf.float16`, `tf.bfloat16` or `tf.float32`. w: A tuple of weight matrices of the same type as `inputs`, the first being the depthwise weight matrix, and the second be...
[ "Apply", "a", "separable_conv2d", "operation", "on", "inputs", "using", "w", "." ]
00612ca3178964d86b556e062694d808ff81fcca
https://github.com/deepmind/sonnet/blob/00612ca3178964d86b556e062694d808ff81fcca/sonnet/python/modules/conv.py#L2905-L2940
train
deepmind/sonnet
sonnet/python/modules/sequential.py
Sequential._build
def _build(self, *args): """Connects the Sequential module into the graph. Args: *args: A tuple of inputs, to be unpacked as the arguments to the first layer. Returns: The output value of the last layer. """ net = args if not self._layers: # If the sequential is pa...
python
def _build(self, *args): """Connects the Sequential module into the graph. Args: *args: A tuple of inputs, to be unpacked as the arguments to the first layer. Returns: The output value of the last layer. """ net = args if not self._layers: # If the sequential is pa...
[ "def", "_build", "(", "self", ",", "*", "args", ")", ":", "net", "=", "args", "if", "not", "self", ".", "_layers", ":", "# If the sequential is passed a single arg, this will end up being", "# wrapped in an extra layer of tuple by *args. Normally we internally", "# handle thi...
Connects the Sequential module into the graph. Args: *args: A tuple of inputs, to be unpacked as the arguments to the first layer. Returns: The output value of the last layer.
[ "Connects", "the", "Sequential", "module", "into", "the", "graph", "." ]
00612ca3178964d86b556e062694d808ff81fcca
https://github.com/deepmind/sonnet/blob/00612ca3178964d86b556e062694d808ff81fcca/sonnet/python/modules/sequential.py#L79-L107
train
deepmind/sonnet
sonnet/python/modules/sequential.py
Sequential.get_variables
def get_variables(self, *args, **kwargs): """Provide a warning that get_variables on Sequential always returns ().""" tf.logging.warning( "Calling Sequential.get_variables, which will always return an empty " "tuple. get_variables() can only return variables created directly by " "a Modu...
python
def get_variables(self, *args, **kwargs): """Provide a warning that get_variables on Sequential always returns ().""" tf.logging.warning( "Calling Sequential.get_variables, which will always return an empty " "tuple. get_variables() can only return variables created directly by " "a Modu...
[ "def", "get_variables", "(", "self", ",", "*", "args", ",", "*", "*", "kwargs", ")", ":", "tf", ".", "logging", ".", "warning", "(", "\"Calling Sequential.get_variables, which will always return an empty \"", "\"tuple. get_variables() can only return variables created directl...
Provide a warning that get_variables on Sequential always returns ().
[ "Provide", "a", "warning", "that", "get_variables", "on", "Sequential", "always", "returns", "()", "." ]
00612ca3178964d86b556e062694d808ff81fcca
https://github.com/deepmind/sonnet/blob/00612ca3178964d86b556e062694d808ff81fcca/sonnet/python/modules/sequential.py#L113-L124
train
deepmind/sonnet
sonnet/python/custom_getters/override_args.py
override_args
def override_args(**kwargs): """Creates a custom getter that applies specified named arguments. Args: **kwargs: Overriding arguments for the custom getter to use in preference the named arguments it's called with. Returns: Custom getter. """ override_kwargs = kwargs def custom_getter(gette...
python
def override_args(**kwargs): """Creates a custom getter that applies specified named arguments. Args: **kwargs: Overriding arguments for the custom getter to use in preference the named arguments it's called with. Returns: Custom getter. """ override_kwargs = kwargs def custom_getter(gette...
[ "def", "override_args", "(", "*", "*", "kwargs", ")", ":", "override_kwargs", "=", "kwargs", "def", "custom_getter", "(", "getter", ",", "*", "args", ",", "*", "*", "kwargs", ")", ":", "\"\"\"Custom getter with certain named arguments overridden.\n\n Args:\n g...
Creates a custom getter that applies specified named arguments. Args: **kwargs: Overriding arguments for the custom getter to use in preference the named arguments it's called with. Returns: Custom getter.
[ "Creates", "a", "custom", "getter", "that", "applies", "specified", "named", "arguments", "." ]
00612ca3178964d86b556e062694d808ff81fcca
https://github.com/deepmind/sonnet/blob/00612ca3178964d86b556e062694d808ff81fcca/sonnet/python/custom_getters/override_args.py#L24-L52
train
deepmind/sonnet
sonnet/python/custom_getters/override_args.py
override_default_args
def override_default_args(**kwargs): """Creates a custom getter that applies specified named arguments. The returned custom getter treats the specified named arguments as revised defaults, and does not override any non-`None` argument values supplied by the original get_variable call (or by a nested scope's cu...
python
def override_default_args(**kwargs): """Creates a custom getter that applies specified named arguments. The returned custom getter treats the specified named arguments as revised defaults, and does not override any non-`None` argument values supplied by the original get_variable call (or by a nested scope's cu...
[ "def", "override_default_args", "(", "*", "*", "kwargs", ")", ":", "override_default_kwargs", "=", "kwargs", "def", "custom_getter", "(", "getter", ",", "*", "args", ",", "*", "*", "kwargs", ")", ":", "\"\"\"Custom getter with certain named arguments overridden.\n\n ...
Creates a custom getter that applies specified named arguments. The returned custom getter treats the specified named arguments as revised defaults, and does not override any non-`None` argument values supplied by the original get_variable call (or by a nested scope's custom getter). Args: **kwargs: Overr...
[ "Creates", "a", "custom", "getter", "that", "applies", "specified", "named", "arguments", "." ]
00612ca3178964d86b556e062694d808ff81fcca
https://github.com/deepmind/sonnet/blob/00612ca3178964d86b556e062694d808ff81fcca/sonnet/python/custom_getters/override_args.py#L55-L89
train
deepmind/sonnet
sonnet/util/migrate_checkpoint.py
_build_migrated_variables
def _build_migrated_variables(checkpoint_reader, name_value_fn): """Builds the TensorFlow variables of the migrated checkpoint. Args: checkpoint_reader: A `tf.train.NewCheckPointReader` of the checkpoint to be read from. name_value_fn: Function taking two arguments, `name` and `value`, which re...
python
def _build_migrated_variables(checkpoint_reader, name_value_fn): """Builds the TensorFlow variables of the migrated checkpoint. Args: checkpoint_reader: A `tf.train.NewCheckPointReader` of the checkpoint to be read from. name_value_fn: Function taking two arguments, `name` and `value`, which re...
[ "def", "_build_migrated_variables", "(", "checkpoint_reader", ",", "name_value_fn", ")", ":", "names_to_shapes", "=", "checkpoint_reader", ".", "get_variable_to_shape_map", "(", ")", "new_name_to_variable", "=", "{", "}", "name_to_new_name", "=", "{", "}", "for", "nam...
Builds the TensorFlow variables of the migrated checkpoint. Args: checkpoint_reader: A `tf.train.NewCheckPointReader` of the checkpoint to be read from. name_value_fn: Function taking two arguments, `name` and `value`, which returns the pair of new name and value for that a variable of that name....
[ "Builds", "the", "TensorFlow", "variables", "of", "the", "migrated", "checkpoint", "." ]
00612ca3178964d86b556e062694d808ff81fcca
https://github.com/deepmind/sonnet/blob/00612ca3178964d86b556e062694d808ff81fcca/sonnet/util/migrate_checkpoint.py#L33-L62
train
deepmind/sonnet
sonnet/python/modules/base_info.py
_to_proto_sparse_tensor
def _to_proto_sparse_tensor(sparse_tensor, nested_proto, process_leafs, already_processed): """Serializes a `tf.SparseTensor` into `nested_proto`. Args: sparse_tensor: An instance of `tf.SparseTensor`. nested_proto: A `module_pb2.NestedData` instance to be filled from `spa...
python
def _to_proto_sparse_tensor(sparse_tensor, nested_proto, process_leafs, already_processed): """Serializes a `tf.SparseTensor` into `nested_proto`. Args: sparse_tensor: An instance of `tf.SparseTensor`. nested_proto: A `module_pb2.NestedData` instance to be filled from `spa...
[ "def", "_to_proto_sparse_tensor", "(", "sparse_tensor", ",", "nested_proto", ",", "process_leafs", ",", "already_processed", ")", ":", "already_processed", ".", "add", "(", "id", "(", "sparse_tensor", ")", ")", "nested_proto", ".", "named_tuple", ".", "name", "=",...
Serializes a `tf.SparseTensor` into `nested_proto`. Args: sparse_tensor: An instance of `tf.SparseTensor`. nested_proto: A `module_pb2.NestedData` instance to be filled from `sparse_tensor`. process_leafs: A function to be applied to the leaf valued of the nested structure. already_proces...
[ "Serializes", "a", "tf", ".", "SparseTensor", "into", "nested_proto", "." ]
00612ca3178964d86b556e062694d808ff81fcca
https://github.com/deepmind/sonnet/blob/00612ca3178964d86b556e062694d808ff81fcca/sonnet/python/modules/base_info.py#L99-L116
train
deepmind/sonnet
sonnet/python/modules/base_info.py
_from_proto_sparse_tensor
def _from_proto_sparse_tensor(sparse_tensor_proto, process_leafs): """Deserializes a `tf.SparseTensor` from `sparse_tensor_proto`. Args: sparse_tensor_proto: A proto representing a `tf.SparseTensor`. process_leafs: A function to be applied to the leaf valued of the nested structure. Returns: A...
python
def _from_proto_sparse_tensor(sparse_tensor_proto, process_leafs): """Deserializes a `tf.SparseTensor` from `sparse_tensor_proto`. Args: sparse_tensor_proto: A proto representing a `tf.SparseTensor`. process_leafs: A function to be applied to the leaf valued of the nested structure. Returns: A...
[ "def", "_from_proto_sparse_tensor", "(", "sparse_tensor_proto", ",", "process_leafs", ")", ":", "if", "not", "sparse_tensor_proto", ".", "HasField", "(", "\"named_tuple\"", ")", ":", "raise", "base_errors", ".", "ModuleInfoError", "(", "\"Error while deserializing a Spars...
Deserializes a `tf.SparseTensor` from `sparse_tensor_proto`. Args: sparse_tensor_proto: A proto representing a `tf.SparseTensor`. process_leafs: A function to be applied to the leaf valued of the nested structure. Returns: An instance of `tf.SparseTensor`.
[ "Deserializes", "a", "tf", ".", "SparseTensor", "from", "sparse_tensor_proto", "." ]
00612ca3178964d86b556e062694d808ff81fcca
https://github.com/deepmind/sonnet/blob/00612ca3178964d86b556e062694d808ff81fcca/sonnet/python/modules/base_info.py#L119-L142
train
deepmind/sonnet
sonnet/python/modules/base_info.py
_nested_to_proto
def _nested_to_proto(nested_value, nested_proto, process_leafs, already_processed): """Serializes `nested_value` into `nested_proto`. Args: nested_value: A nested Python value. nested_proto: A `module_pb2.NestedData` instance to be filled from the value in `nested_value`. pro...
python
def _nested_to_proto(nested_value, nested_proto, process_leafs, already_processed): """Serializes `nested_value` into `nested_proto`. Args: nested_value: A nested Python value. nested_proto: A `module_pb2.NestedData` instance to be filled from the value in `nested_value`. pro...
[ "def", "_nested_to_proto", "(", "nested_value", ",", "nested_proto", ",", "process_leafs", ",", "already_processed", ")", ":", "if", "not", "isinstance", "(", "nested_proto", ",", "module_pb2", ".", "NestedData", ")", ":", "raise", "base_errors", ".", "ModuleInfoE...
Serializes `nested_value` into `nested_proto`. Args: nested_value: A nested Python value. nested_proto: A `module_pb2.NestedData` instance to be filled from the value in `nested_value`. process_leafs: A function to be applied to the leaf values of the nested structure. already_processed: ...
[ "Serializes", "nested_value", "into", "nested_proto", "." ]
00612ca3178964d86b556e062694d808ff81fcca
https://github.com/deepmind/sonnet/blob/00612ca3178964d86b556e062694d808ff81fcca/sonnet/python/modules/base_info.py#L160-L223
train
deepmind/sonnet
sonnet/python/modules/base_info.py
_module_info_to_proto
def _module_info_to_proto(module_info, export_scope=None): """Serializes `module_into`. Args: module_info: An instance of `ModuleInfo`. export_scope: Optional `string`. Name scope to remove. Returns: An instance of `module_pb2.SonnetModule`. """ def strip_name_scope(name_scope): return ops.s...
python
def _module_info_to_proto(module_info, export_scope=None): """Serializes `module_into`. Args: module_info: An instance of `ModuleInfo`. export_scope: Optional `string`. Name scope to remove. Returns: An instance of `module_pb2.SonnetModule`. """ def strip_name_scope(name_scope): return ops.s...
[ "def", "_module_info_to_proto", "(", "module_info", ",", "export_scope", "=", "None", ")", ":", "def", "strip_name_scope", "(", "name_scope", ")", ":", "return", "ops", ".", "strip_name_scope", "(", "name_scope", ",", "export_scope", ")", "def", "process_leafs", ...
Serializes `module_into`. Args: module_info: An instance of `ModuleInfo`. export_scope: Optional `string`. Name scope to remove. Returns: An instance of `module_pb2.SonnetModule`.
[ "Serializes", "module_into", "." ]
00612ca3178964d86b556e062694d808ff81fcca
https://github.com/deepmind/sonnet/blob/00612ca3178964d86b556e062694d808ff81fcca/sonnet/python/modules/base_info.py#L226-L256
train
deepmind/sonnet
sonnet/python/modules/base_info.py
_nested_from_proto
def _nested_from_proto(nested_proto, process_leafs): """Deserializes `nested_proto`. Args: nested_proto: An instance of `module_pb2.NestedData`. process_leafs: A function to be applied to the leaf values of the nested structure. Returns: An instance of `string`, `tuple`, `dict` or `namedtuple`...
python
def _nested_from_proto(nested_proto, process_leafs): """Deserializes `nested_proto`. Args: nested_proto: An instance of `module_pb2.NestedData`. process_leafs: A function to be applied to the leaf values of the nested structure. Returns: An instance of `string`, `tuple`, `dict` or `namedtuple`...
[ "def", "_nested_from_proto", "(", "nested_proto", ",", "process_leafs", ")", ":", "if", "not", "isinstance", "(", "nested_proto", ",", "module_pb2", ".", "NestedData", ")", ":", "raise", "base_errors", ".", "ModuleInfoError", "(", "\"Expected module_pb2.NestedData.\""...
Deserializes `nested_proto`. Args: nested_proto: An instance of `module_pb2.NestedData`. process_leafs: A function to be applied to the leaf values of the nested structure. Returns: An instance of `string`, `tuple`, `dict` or `namedtuple`. Raises: base_errors.ModuleInfoError: If the probo...
[ "Deserializes", "nested_proto", "." ]
00612ca3178964d86b556e062694d808ff81fcca
https://github.com/deepmind/sonnet/blob/00612ca3178964d86b556e062694d808ff81fcca/sonnet/python/modules/base_info.py#L259-L307
train
deepmind/sonnet
sonnet/python/modules/base_info.py
_module_info_from_proto
def _module_info_from_proto(module_info_def, import_scope=None): """Deserializes `module_info_def` proto. Args: module_info_def: An instance of `module_pb2.SonnetModule`. import_scope: Optional `string`. Name scope to use. Returns: An instance of `ModuleInfo`. Raises: base_errors.ModuleInfoEr...
python
def _module_info_from_proto(module_info_def, import_scope=None): """Deserializes `module_info_def` proto. Args: module_info_def: An instance of `module_pb2.SonnetModule`. import_scope: Optional `string`. Name scope to use. Returns: An instance of `ModuleInfo`. Raises: base_errors.ModuleInfoEr...
[ "def", "_module_info_from_proto", "(", "module_info_def", ",", "import_scope", "=", "None", ")", ":", "graph", "=", "tf", ".", "get_default_graph", "(", ")", "def", "prepend_name_scope", "(", "name_scope", ")", ":", "return", "ops", ".", "prepend_name_scope", "(...
Deserializes `module_info_def` proto. Args: module_info_def: An instance of `module_pb2.SonnetModule`. import_scope: Optional `string`. Name scope to use. Returns: An instance of `ModuleInfo`. Raises: base_errors.ModuleInfoError: If the probobuf is of the wrong type or if some of its fiel...
[ "Deserializes", "module_info_def", "proto", "." ]
00612ca3178964d86b556e062694d808ff81fcca
https://github.com/deepmind/sonnet/blob/00612ca3178964d86b556e062694d808ff81fcca/sonnet/python/modules/base_info.py#L310-L344
train
deepmind/sonnet
sonnet/python/modules/base_info.py
_module_info_from_proto_safe
def _module_info_from_proto_safe(module_info_def, import_scope=None): """Deserializes the `module_info_def` proto without raising exceptions. Args: module_info_def: An instance of `module_pb2.SonnetModule`. import_scope: Optional `string`. Name scope to use. Returns: An instance of `ModuleInfo`. "...
python
def _module_info_from_proto_safe(module_info_def, import_scope=None): """Deserializes the `module_info_def` proto without raising exceptions. Args: module_info_def: An instance of `module_pb2.SonnetModule`. import_scope: Optional `string`. Name scope to use. Returns: An instance of `ModuleInfo`. "...
[ "def", "_module_info_from_proto_safe", "(", "module_info_def", ",", "import_scope", "=", "None", ")", ":", "try", ":", "return", "_module_info_from_proto", "(", "module_info_def", ",", "import_scope", ")", "except", "Exception", "as", "e", ":", "# pylint: disable=broa...
Deserializes the `module_info_def` proto without raising exceptions. Args: module_info_def: An instance of `module_pb2.SonnetModule`. import_scope: Optional `string`. Name scope to use. Returns: An instance of `ModuleInfo`.
[ "Deserializes", "the", "module_info_def", "proto", "without", "raising", "exceptions", "." ]
00612ca3178964d86b556e062694d808ff81fcca
https://github.com/deepmind/sonnet/blob/00612ca3178964d86b556e062694d808ff81fcca/sonnet/python/modules/base_info.py#L347-L362
train
deepmind/sonnet
sonnet/examples/rnn_shakespeare.py
_configure_saver
def _configure_saver(checkpoint_dir, checkpoint_interval): """Returns a tf.train.CheckpointSaverHook for autosaving checkpoints.""" saver = tf.train.Saver() return tf.train.CheckpointSaverHook( checkpoint_dir=checkpoint_dir, save_steps=checkpoint_interval, saver=saver)
python
def _configure_saver(checkpoint_dir, checkpoint_interval): """Returns a tf.train.CheckpointSaverHook for autosaving checkpoints.""" saver = tf.train.Saver() return tf.train.CheckpointSaverHook( checkpoint_dir=checkpoint_dir, save_steps=checkpoint_interval, saver=saver)
[ "def", "_configure_saver", "(", "checkpoint_dir", ",", "checkpoint_interval", ")", ":", "saver", "=", "tf", ".", "train", ".", "Saver", "(", ")", "return", "tf", ".", "train", ".", "CheckpointSaverHook", "(", "checkpoint_dir", "=", "checkpoint_dir", ",", "save...
Returns a tf.train.CheckpointSaverHook for autosaving checkpoints.
[ "Returns", "a", "tf", ".", "train", ".", "CheckpointSaverHook", "for", "autosaving", "checkpoints", "." ]
00612ca3178964d86b556e062694d808ff81fcca
https://github.com/deepmind/sonnet/blob/00612ca3178964d86b556e062694d808ff81fcca/sonnet/examples/rnn_shakespeare.py#L55-L61
train
deepmind/sonnet
sonnet/examples/rnn_shakespeare.py
build_graph
def build_graph(lstm_depth=3, batch_size=32, num_embedding=32, num_hidden=128, truncation_length=64, sample_length=1000, max_grad_norm=5, initial_learning_rate=0.1, reduce_learning_rate_multiplier=0.1, optimizer_epsilon=0.01): """Constructs the computation graph.""" ...
python
def build_graph(lstm_depth=3, batch_size=32, num_embedding=32, num_hidden=128, truncation_length=64, sample_length=1000, max_grad_norm=5, initial_learning_rate=0.1, reduce_learning_rate_multiplier=0.1, optimizer_epsilon=0.01): """Constructs the computation graph.""" ...
[ "def", "build_graph", "(", "lstm_depth", "=", "3", ",", "batch_size", "=", "32", ",", "num_embedding", "=", "32", ",", "num_hidden", "=", "128", ",", "truncation_length", "=", "64", ",", "sample_length", "=", "1000", ",", "max_grad_norm", "=", "5", ",", ...
Constructs the computation graph.
[ "Constructs", "the", "computation", "graph", "." ]
00612ca3178964d86b556e062694d808ff81fcca
https://github.com/deepmind/sonnet/blob/00612ca3178964d86b556e062694d808ff81fcca/sonnet/examples/rnn_shakespeare.py#L64-L168
train
deepmind/sonnet
sonnet/examples/rnn_shakespeare.py
train
def train(num_training_iterations, report_interval, reduce_learning_rate_interval): """Trains a deep LSTM model on the Tiny Shakespeare dataset.""" # Build the computation graph. graph_tensors, dataset_train = build_graph( lstm_depth=FLAGS.lstm_depth, batch_size=FLAGS.batch_size, num_embedd...
python
def train(num_training_iterations, report_interval, reduce_learning_rate_interval): """Trains a deep LSTM model on the Tiny Shakespeare dataset.""" # Build the computation graph. graph_tensors, dataset_train = build_graph( lstm_depth=FLAGS.lstm_depth, batch_size=FLAGS.batch_size, num_embedd...
[ "def", "train", "(", "num_training_iterations", ",", "report_interval", ",", "reduce_learning_rate_interval", ")", ":", "# Build the computation graph.", "graph_tensors", ",", "dataset_train", "=", "build_graph", "(", "lstm_depth", "=", "FLAGS", ".", "lstm_depth", ",", ...
Trains a deep LSTM model on the Tiny Shakespeare dataset.
[ "Trains", "a", "deep", "LSTM", "model", "on", "the", "Tiny", "Shakespeare", "dataset", "." ]
00612ca3178964d86b556e062694d808ff81fcca
https://github.com/deepmind/sonnet/blob/00612ca3178964d86b556e062694d808ff81fcca/sonnet/examples/rnn_shakespeare.py#L171-L223
train
deepmind/sonnet
sonnet/examples/rnn_shakespeare.py
TextModel._build
def _build(self, one_hot_input_sequence): """Builds the deep LSTM model sub-graph. Args: one_hot_input_sequence: A Tensor with the input sequence encoded as a one-hot representation. Its dimensions should be `[truncation_length, batch_size, output_size]`. Returns: Tuple of the ...
python
def _build(self, one_hot_input_sequence): """Builds the deep LSTM model sub-graph. Args: one_hot_input_sequence: A Tensor with the input sequence encoded as a one-hot representation. Its dimensions should be `[truncation_length, batch_size, output_size]`. Returns: Tuple of the ...
[ "def", "_build", "(", "self", ",", "one_hot_input_sequence", ")", ":", "input_shape", "=", "one_hot_input_sequence", ".", "get_shape", "(", ")", "batch_size", "=", "input_shape", "[", "1", "]", "batch_embed_module", "=", "snt", ".", "BatchApply", "(", "self", ...
Builds the deep LSTM model sub-graph. Args: one_hot_input_sequence: A Tensor with the input sequence encoded as a one-hot representation. Its dimensions should be `[truncation_length, batch_size, output_size]`. Returns: Tuple of the Tensor of output logits for the batch, with dimen...
[ "Builds", "the", "deep", "LSTM", "model", "sub", "-", "graph", "." ]
00612ca3178964d86b556e062694d808ff81fcca
https://github.com/deepmind/sonnet/blob/00612ca3178964d86b556e062694d808ff81fcca/sonnet/examples/rnn_shakespeare.py#L280-L320
train
deepmind/sonnet
sonnet/examples/rnn_shakespeare.py
TextModel.generate_string
def generate_string(self, initial_logits, initial_state, sequence_length): """Builds sub-graph to generate a string, sampled from the model. Args: initial_logits: Starting logits to sample from. initial_state: Starting state for the RNN core. sequence_length: Number of characters to sample. ...
python
def generate_string(self, initial_logits, initial_state, sequence_length): """Builds sub-graph to generate a string, sampled from the model. Args: initial_logits: Starting logits to sample from. initial_state: Starting state for the RNN core. sequence_length: Number of characters to sample. ...
[ "def", "generate_string", "(", "self", ",", "initial_logits", ",", "initial_state", ",", "sequence_length", ")", ":", "current_logits", "=", "initial_logits", "current_state", "=", "initial_state", "generated_letters", "=", "[", "]", "for", "_", "in", "range", "("...
Builds sub-graph to generate a string, sampled from the model. Args: initial_logits: Starting logits to sample from. initial_state: Starting state for the RNN core. sequence_length: Number of characters to sample. Returns: A Tensor of characters, with dimensions `[sequence_length, batc...
[ "Builds", "sub", "-", "graph", "to", "generate", "a", "string", "sampled", "from", "the", "model", "." ]
00612ca3178964d86b556e062694d808ff81fcca
https://github.com/deepmind/sonnet/blob/00612ca3178964d86b556e062694d808ff81fcca/sonnet/examples/rnn_shakespeare.py#L323-L354
train
deepmind/sonnet
sonnet/python/modules/nets/vqvae.py
VectorQuantizer._build
def _build(self, inputs, is_training): """Connects the module to some inputs. Args: inputs: Tensor, final dimension must be equal to embedding_dim. All other leading dimensions will be flattened and treated as a large batch. is_training: boolean, whether this connection is to training data....
python
def _build(self, inputs, is_training): """Connects the module to some inputs. Args: inputs: Tensor, final dimension must be equal to embedding_dim. All other leading dimensions will be flattened and treated as a large batch. is_training: boolean, whether this connection is to training data....
[ "def", "_build", "(", "self", ",", "inputs", ",", "is_training", ")", ":", "# Assert last dimension is same as self._embedding_dim", "input_shape", "=", "tf", ".", "shape", "(", "inputs", ")", "with", "tf", ".", "control_dependencies", "(", "[", "tf", ".", "Asse...
Connects the module to some inputs. Args: inputs: Tensor, final dimension must be equal to embedding_dim. All other leading dimensions will be flattened and treated as a large batch. is_training: boolean, whether this connection is to training data. Returns: dict containing the follo...
[ "Connects", "the", "module", "to", "some", "inputs", "." ]
00612ca3178964d86b556e062694d808ff81fcca
https://github.com/deepmind/sonnet/blob/00612ca3178964d86b556e062694d808ff81fcca/sonnet/python/modules/nets/vqvae.py#L66-L112
train
deepmind/sonnet
sonnet/python/modules/nets/vqvae.py
VectorQuantizerEMA._build
def _build(self, inputs, is_training): """Connects the module to some inputs. Args: inputs: Tensor, final dimension must be equal to embedding_dim. All other leading dimensions will be flattened and treated as a large batch. is_training: boolean, whether this connection is to training data....
python
def _build(self, inputs, is_training): """Connects the module to some inputs. Args: inputs: Tensor, final dimension must be equal to embedding_dim. All other leading dimensions will be flattened and treated as a large batch. is_training: boolean, whether this connection is to training data....
[ "def", "_build", "(", "self", ",", "inputs", ",", "is_training", ")", ":", "# Ensure that the weights are read fresh for each timestep, which otherwise", "# would not be guaranteed in an RNN setup. Note that this relies on inputs", "# having a data dependency with the output of the previous ...
Connects the module to some inputs. Args: inputs: Tensor, final dimension must be equal to embedding_dim. All other leading dimensions will be flattened and treated as a large batch. is_training: boolean, whether this connection is to training data. When this is set to False, the intern...
[ "Connects", "the", "module", "to", "some", "inputs", "." ]
00612ca3178964d86b556e062694d808ff81fcca
https://github.com/deepmind/sonnet/blob/00612ca3178964d86b556e062694d808ff81fcca/sonnet/python/modules/nets/vqvae.py#L181-L252
train
deepmind/sonnet
sonnet/python/modules/pondering_rnn.py
_nested_add
def _nested_add(nested_a, nested_b): """Add two arbitrarily nested `Tensors`.""" return nest.map(lambda a, b: a + b, nested_a, nested_b)
python
def _nested_add(nested_a, nested_b): """Add two arbitrarily nested `Tensors`.""" return nest.map(lambda a, b: a + b, nested_a, nested_b)
[ "def", "_nested_add", "(", "nested_a", ",", "nested_b", ")", ":", "return", "nest", ".", "map", "(", "lambda", "a", ",", "b", ":", "a", "+", "b", ",", "nested_a", ",", "nested_b", ")" ]
Add two arbitrarily nested `Tensors`.
[ "Add", "two", "arbitrarily", "nested", "Tensors", "." ]
00612ca3178964d86b556e062694d808ff81fcca
https://github.com/deepmind/sonnet/blob/00612ca3178964d86b556e062694d808ff81fcca/sonnet/python/modules/pondering_rnn.py#L33-L35
train
deepmind/sonnet
sonnet/python/modules/pondering_rnn.py
_nested_unary_mul
def _nested_unary_mul(nested_a, p): """Multiply `Tensors` in arbitrarily nested `Tensor` `nested_a` with `p`.""" def mul_with_broadcast(tensor): ndims = tensor.shape.ndims if ndims != 2: p_reshaped = tf.reshape(p, [-1] + [1] * (ndims - 1)) return p_reshaped * tensor else: return p * te...
python
def _nested_unary_mul(nested_a, p): """Multiply `Tensors` in arbitrarily nested `Tensor` `nested_a` with `p`.""" def mul_with_broadcast(tensor): ndims = tensor.shape.ndims if ndims != 2: p_reshaped = tf.reshape(p, [-1] + [1] * (ndims - 1)) return p_reshaped * tensor else: return p * te...
[ "def", "_nested_unary_mul", "(", "nested_a", ",", "p", ")", ":", "def", "mul_with_broadcast", "(", "tensor", ")", ":", "ndims", "=", "tensor", ".", "shape", ".", "ndims", "if", "ndims", "!=", "2", ":", "p_reshaped", "=", "tf", ".", "reshape", "(", "p",...
Multiply `Tensors` in arbitrarily nested `Tensor` `nested_a` with `p`.
[ "Multiply", "Tensors", "in", "arbitrarily", "nested", "Tensor", "nested_a", "with", "p", "." ]
00612ca3178964d86b556e062694d808ff81fcca
https://github.com/deepmind/sonnet/blob/00612ca3178964d86b556e062694d808ff81fcca/sonnet/python/modules/pondering_rnn.py#L38-L47
train
deepmind/sonnet
sonnet/python/modules/pondering_rnn.py
ACTCore._cond
def _cond(self, unused_x, unused_cumul_out, unused_prev_state, unused_cumul_state, cumul_halting, unused_iteration, unused_remainder): """The `cond` of the `tf.while_loop`.""" return tf.reduce_any(cumul_halting < 1)
python
def _cond(self, unused_x, unused_cumul_out, unused_prev_state, unused_cumul_state, cumul_halting, unused_iteration, unused_remainder): """The `cond` of the `tf.while_loop`.""" return tf.reduce_any(cumul_halting < 1)
[ "def", "_cond", "(", "self", ",", "unused_x", ",", "unused_cumul_out", ",", "unused_prev_state", ",", "unused_cumul_state", ",", "cumul_halting", ",", "unused_iteration", ",", "unused_remainder", ")", ":", "return", "tf", ".", "reduce_any", "(", "cumul_halting", "...
The `cond` of the `tf.while_loop`.
[ "The", "cond", "of", "the", "tf", ".", "while_loop", "." ]
00612ca3178964d86b556e062694d808ff81fcca
https://github.com/deepmind/sonnet/blob/00612ca3178964d86b556e062694d808ff81fcca/sonnet/python/modules/pondering_rnn.py#L132-L136
train
deepmind/sonnet
sonnet/python/modules/pondering_rnn.py
ACTCore._body
def _body(self, x, cumul_out, prev_state, cumul_state, cumul_halting, iteration, remainder, halting_linear, x_ones): """The `body` of `tf.while_loop`.""" # Increase iteration count only for those elements that are still running. all_ones = tf.constant(1, shape=(self._batch_size, 1), dtype=self._...
python
def _body(self, x, cumul_out, prev_state, cumul_state, cumul_halting, iteration, remainder, halting_linear, x_ones): """The `body` of `tf.while_loop`.""" # Increase iteration count only for those elements that are still running. all_ones = tf.constant(1, shape=(self._batch_size, 1), dtype=self._...
[ "def", "_body", "(", "self", ",", "x", ",", "cumul_out", ",", "prev_state", ",", "cumul_state", ",", "cumul_halting", ",", "iteration", ",", "remainder", ",", "halting_linear", ",", "x_ones", ")", ":", "# Increase iteration count only for those elements that are still...
The `body` of `tf.while_loop`.
[ "The", "body", "of", "tf", ".", "while_loop", "." ]
00612ca3178964d86b556e062694d808ff81fcca
https://github.com/deepmind/sonnet/blob/00612ca3178964d86b556e062694d808ff81fcca/sonnet/python/modules/pondering_rnn.py#L138-L164
train
deepmind/sonnet
sonnet/python/modules/pondering_rnn.py
ACTCore._build
def _build(self, x, prev_state): """Connects the core to the graph. Args: x: Input `Tensor` of shape `(batch_size, input_size)`. prev_state: Previous state. This could be a `Tensor`, or a tuple of `Tensor`s. Returns: The tuple `(output, state)` for this core. Raises: ...
python
def _build(self, x, prev_state): """Connects the core to the graph. Args: x: Input `Tensor` of shape `(batch_size, input_size)`. prev_state: Previous state. This could be a `Tensor`, or a tuple of `Tensor`s. Returns: The tuple `(output, state)` for this core. Raises: ...
[ "def", "_build", "(", "self", ",", "x", ",", "prev_state", ")", ":", "x", ".", "get_shape", "(", ")", ".", "with_rank", "(", "2", ")", "self", ".", "_batch_size", "=", "x", ".", "get_shape", "(", ")", ".", "as_list", "(", ")", "[", "0", "]", "s...
Connects the core to the graph. Args: x: Input `Tensor` of shape `(batch_size, input_size)`. prev_state: Previous state. This could be a `Tensor`, or a tuple of `Tensor`s. Returns: The tuple `(output, state)` for this core. Raises: ValueError: if the `Tensor` `x` does no...
[ "Connects", "the", "core", "to", "the", "graph", "." ]
00612ca3178964d86b556e062694d808ff81fcca
https://github.com/deepmind/sonnet/blob/00612ca3178964d86b556e062694d808ff81fcca/sonnet/python/modules/pondering_rnn.py#L166-L211
train
deepmind/sonnet
sonnet/python/custom_getters/restore_initializer.py
restore_initializer
def restore_initializer(filename, name_fn=None, collection=tf.GraphKeys.GLOBAL_VARIABLES): """Custom getter to restore all variables with `snt.restore_initializer`. Args: filename: The filename of the checkpoint. name_fn: A function which can map the name of the variable requested. ...
python
def restore_initializer(filename, name_fn=None, collection=tf.GraphKeys.GLOBAL_VARIABLES): """Custom getter to restore all variables with `snt.restore_initializer`. Args: filename: The filename of the checkpoint. name_fn: A function which can map the name of the variable requested. ...
[ "def", "restore_initializer", "(", "filename", ",", "name_fn", "=", "None", ",", "collection", "=", "tf", ".", "GraphKeys", ".", "GLOBAL_VARIABLES", ")", ":", "def", "_restore_initializer", "(", "getter", ",", "name", ",", "*", "args", ",", "*", "*", "kwar...
Custom getter to restore all variables with `snt.restore_initializer`. Args: filename: The filename of the checkpoint. name_fn: A function which can map the name of the variable requested. This allows restoring variables with values having different names in the checkpoint. collection: Only s...
[ "Custom", "getter", "to", "restore", "all", "variables", "with", "snt", ".", "restore_initializer", "." ]
00612ca3178964d86b556e062694d808ff81fcca
https://github.com/deepmind/sonnet/blob/00612ca3178964d86b556e062694d808ff81fcca/sonnet/python/custom_getters/restore_initializer.py#L26-L75
train
deepmind/sonnet
sonnet/python/modules/embed.py
_embedding_dim
def _embedding_dim(vocab_size): """Calculate a reasonable embedding size for a vocabulary. Rule of thumb is 6 * 4th root of vocab_size. Args: vocab_size: Size of the input vocabulary. Returns: The embedding size to use. Raises: ValueError: if `vocab_size` is invalid. """ if not vocab_size or...
python
def _embedding_dim(vocab_size): """Calculate a reasonable embedding size for a vocabulary. Rule of thumb is 6 * 4th root of vocab_size. Args: vocab_size: Size of the input vocabulary. Returns: The embedding size to use. Raises: ValueError: if `vocab_size` is invalid. """ if not vocab_size or...
[ "def", "_embedding_dim", "(", "vocab_size", ")", ":", "if", "not", "vocab_size", "or", "(", "vocab_size", "<=", "0", ")", ":", "raise", "ValueError", "(", "\"Invalid vocab_size %g.\"", "%", "vocab_size", ")", "return", "int", "(", "round", "(", "6.0", "*", ...
Calculate a reasonable embedding size for a vocabulary. Rule of thumb is 6 * 4th root of vocab_size. Args: vocab_size: Size of the input vocabulary. Returns: The embedding size to use. Raises: ValueError: if `vocab_size` is invalid.
[ "Calculate", "a", "reasonable", "embedding", "size", "for", "a", "vocabulary", "." ]
00612ca3178964d86b556e062694d808ff81fcca
https://github.com/deepmind/sonnet/blob/00612ca3178964d86b556e062694d808ff81fcca/sonnet/python/modules/embed.py#L30-L44
train
deepmind/sonnet
sonnet/python/modules/embed.py
Embed._build
def _build(self, ids): """Lookup embeddings. Looks up an embedding vector for each value in `ids`. All ids must be within [0, vocab_size), else an `InvalidArgumentError` is raised at runtime. Args: ids: Tensor of dtype int64. Returns: Tensor of tf.shape(ids) + [embedding_dim] and dtyp...
python
def _build(self, ids): """Lookup embeddings. Looks up an embedding vector for each value in `ids`. All ids must be within [0, vocab_size), else an `InvalidArgumentError` is raised at runtime. Args: ids: Tensor of dtype int64. Returns: Tensor of tf.shape(ids) + [embedding_dim] and dtyp...
[ "def", "_build", "(", "self", ",", "ids", ")", ":", "# Construct embeddings.", "if", "self", ".", "_existing_vocab", "is", "None", ":", "if", "self", ".", "EMBEDDINGS", "not", "in", "self", ".", "_initializers", ":", "self", ".", "_initializers", "[", "sel...
Lookup embeddings. Looks up an embedding vector for each value in `ids`. All ids must be within [0, vocab_size), else an `InvalidArgumentError` is raised at runtime. Args: ids: Tensor of dtype int64. Returns: Tensor of tf.shape(ids) + [embedding_dim] and dtype float32.
[ "Lookup", "embeddings", "." ]
00612ca3178964d86b556e062694d808ff81fcca
https://github.com/deepmind/sonnet/blob/00612ca3178964d86b556e062694d808ff81fcca/sonnet/python/modules/embed.py#L139-L182
train
deepmind/sonnet
sonnet/python/modules/spatial_transformer.py
_create_affine_features
def _create_affine_features(output_shape, source_shape): """Generates n-dimensional homogenous coordinates for a given grid definition. `source_shape` and `output_shape` are used to define the size of the source and output signal domains, as opposed to the shape of the respective Tensors. For example, for an i...
python
def _create_affine_features(output_shape, source_shape): """Generates n-dimensional homogenous coordinates for a given grid definition. `source_shape` and `output_shape` are used to define the size of the source and output signal domains, as opposed to the shape of the respective Tensors. For example, for an i...
[ "def", "_create_affine_features", "(", "output_shape", ",", "source_shape", ")", ":", "ranges", "=", "[", "np", ".", "linspace", "(", "-", "1", ",", "1", ",", "x", ",", "dtype", "=", "np", ".", "float32", ")", "for", "x", "in", "reversed", "(", "outp...
Generates n-dimensional homogenous coordinates for a given grid definition. `source_shape` and `output_shape` are used to define the size of the source and output signal domains, as opposed to the shape of the respective Tensors. For example, for an image of size `width=W` and `height=H`, `{source,output}_shap...
[ "Generates", "n", "-", "dimensional", "homogenous", "coordinates", "for", "a", "given", "grid", "definition", "." ]
00612ca3178964d86b556e062694d808ff81fcca
https://github.com/deepmind/sonnet/blob/00612ca3178964d86b556e062694d808ff81fcca/sonnet/python/modules/spatial_transformer.py#L107-L147
train
deepmind/sonnet
sonnet/python/modules/spatial_transformer.py
AffineGridWarper._create_features
def _create_features(self, constraints): """Creates all the matrices needed to compute the output warped grids.""" affine_warp_constraints = constraints if not isinstance(affine_warp_constraints, AffineWarpConstraints): affine_warp_constraints = AffineWarpConstraints(affine_warp_constraints) mask ...
python
def _create_features(self, constraints): """Creates all the matrices needed to compute the output warped grids.""" affine_warp_constraints = constraints if not isinstance(affine_warp_constraints, AffineWarpConstraints): affine_warp_constraints = AffineWarpConstraints(affine_warp_constraints) mask ...
[ "def", "_create_features", "(", "self", ",", "constraints", ")", ":", "affine_warp_constraints", "=", "constraints", "if", "not", "isinstance", "(", "affine_warp_constraints", ",", "AffineWarpConstraints", ")", ":", "affine_warp_constraints", "=", "AffineWarpConstraints",...
Creates all the matrices needed to compute the output warped grids.
[ "Creates", "all", "the", "matrices", "needed", "to", "compute", "the", "output", "warped", "grids", "." ]
00612ca3178964d86b556e062694d808ff81fcca
https://github.com/deepmind/sonnet/blob/00612ca3178964d86b556e062694d808ff81fcca/sonnet/python/modules/spatial_transformer.py#L214-L272
train
deepmind/sonnet
sonnet/python/modules/spatial_transformer.py
AffineGridWarper._build
def _build(self, inputs): """Assembles the module network and adds it to the graph. The internal computation graph is assembled according to the set of constraints provided at construction time. Args: inputs: Tensor containing a batch of transformation parameters. Returns: A batch of ...
python
def _build(self, inputs): """Assembles the module network and adds it to the graph. The internal computation graph is assembled according to the set of constraints provided at construction time. Args: inputs: Tensor containing a batch of transformation parameters. Returns: A batch of ...
[ "def", "_build", "(", "self", ",", "inputs", ")", ":", "input_shape", "=", "tf", ".", "shape", "(", "inputs", ")", "input_dtype", "=", "inputs", ".", "dtype", ".", "as_numpy_dtype", "batch_size", "=", "tf", ".", "expand_dims", "(", "input_shape", "[", "0...
Assembles the module network and adds it to the graph. The internal computation graph is assembled according to the set of constraints provided at construction time. Args: inputs: Tensor containing a batch of transformation parameters. Returns: A batch of warped grids. Raises: ...
[ "Assembles", "the", "module", "network", "and", "adds", "it", "to", "the", "graph", "." ]
00612ca3178964d86b556e062694d808ff81fcca
https://github.com/deepmind/sonnet/blob/00612ca3178964d86b556e062694d808ff81fcca/sonnet/python/modules/spatial_transformer.py#L274-L355
train
deepmind/sonnet
sonnet/python/modules/spatial_transformer.py
AffineGridWarper.inverse
def inverse(self, name=None): """Returns a `sonnet` module to compute inverse affine transforms. The function first assembles a network that given the constraints of the current AffineGridWarper and a set of input parameters, retrieves the coefficients of the corresponding inverse affine transfor...
python
def inverse(self, name=None): """Returns a `sonnet` module to compute inverse affine transforms. The function first assembles a network that given the constraints of the current AffineGridWarper and a set of input parameters, retrieves the coefficients of the corresponding inverse affine transfor...
[ "def", "inverse", "(", "self", ",", "name", "=", "None", ")", ":", "if", "self", ".", "_num_coeff", "!=", "6", ":", "raise", "tf", ".", "errors", ".", "UnimplementedError", "(", "'AffineGridWarper currently supports'", "'inversion only for the 2D case.'", ")", "...
Returns a `sonnet` module to compute inverse affine transforms. The function first assembles a network that given the constraints of the current AffineGridWarper and a set of input parameters, retrieves the coefficients of the corresponding inverse affine transform, then feeds its output into a...
[ "Returns", "a", "sonnet", "module", "to", "compute", "inverse", "affine", "transforms", "." ]
00612ca3178964d86b556e062694d808ff81fcca
https://github.com/deepmind/sonnet/blob/00612ca3178964d86b556e062694d808ff81fcca/sonnet/python/modules/spatial_transformer.py#L361-L458
train
deepmind/sonnet
sonnet/python/modules/spatial_transformer.py
AffineWarpConstraints._calc_mask
def _calc_mask(self): """Computes a boolean mask from the user defined constraints.""" mask = [] for row in self._constraints: mask.append(tuple(x is None for x in row)) return tuple(mask)
python
def _calc_mask(self): """Computes a boolean mask from the user defined constraints.""" mask = [] for row in self._constraints: mask.append(tuple(x is None for x in row)) return tuple(mask)
[ "def", "_calc_mask", "(", "self", ")", ":", "mask", "=", "[", "]", "for", "row", "in", "self", ".", "_constraints", ":", "mask", ".", "append", "(", "tuple", "(", "x", "is", "None", "for", "x", "in", "row", ")", ")", "return", "tuple", "(", "mask...
Computes a boolean mask from the user defined constraints.
[ "Computes", "a", "boolean", "mask", "from", "the", "user", "defined", "constraints", "." ]
00612ca3178964d86b556e062694d808ff81fcca
https://github.com/deepmind/sonnet/blob/00612ca3178964d86b556e062694d808ff81fcca/sonnet/python/modules/spatial_transformer.py#L495-L500
train
deepmind/sonnet
sonnet/python/modules/spatial_transformer.py
AffineWarpConstraints._combine
def _combine(self, x, y): """Combines two constraints, raising an error if they are not compatible.""" if x is None or y is None: return x or y if x != y: raise ValueError('Incompatible set of constraints provided.') return x
python
def _combine(self, x, y): """Combines two constraints, raising an error if they are not compatible.""" if x is None or y is None: return x or y if x != y: raise ValueError('Incompatible set of constraints provided.') return x
[ "def", "_combine", "(", "self", ",", "x", ",", "y", ")", ":", "if", "x", "is", "None", "or", "y", "is", "None", ":", "return", "x", "or", "y", "if", "x", "!=", "y", ":", "raise", "ValueError", "(", "'Incompatible set of constraints provided.'", ")", ...
Combines two constraints, raising an error if they are not compatible.
[ "Combines", "two", "constraints", "raising", "an", "error", "if", "they", "are", "not", "compatible", "." ]
00612ca3178964d86b556e062694d808ff81fcca
https://github.com/deepmind/sonnet/blob/00612ca3178964d86b556e062694d808ff81fcca/sonnet/python/modules/spatial_transformer.py#L526-L532
train
deepmind/sonnet
sonnet/python/modules/spatial_transformer.py
AffineWarpConstraints.combine_with
def combine_with(self, additional_constraints): """Combines two sets of constraints into a coherent single set.""" x = additional_constraints if not isinstance(additional_constraints, AffineWarpConstraints): x = AffineWarpConstraints(additional_constraints) new_constraints = [] for left, right...
python
def combine_with(self, additional_constraints): """Combines two sets of constraints into a coherent single set.""" x = additional_constraints if not isinstance(additional_constraints, AffineWarpConstraints): x = AffineWarpConstraints(additional_constraints) new_constraints = [] for left, right...
[ "def", "combine_with", "(", "self", ",", "additional_constraints", ")", ":", "x", "=", "additional_constraints", "if", "not", "isinstance", "(", "additional_constraints", ",", "AffineWarpConstraints", ")", ":", "x", "=", "AffineWarpConstraints", "(", "additional_const...
Combines two sets of constraints into a coherent single set.
[ "Combines", "two", "sets", "of", "constraints", "into", "a", "coherent", "single", "set", "." ]
00612ca3178964d86b556e062694d808ff81fcca
https://github.com/deepmind/sonnet/blob/00612ca3178964d86b556e062694d808ff81fcca/sonnet/python/modules/spatial_transformer.py#L538-L546
train
deepmind/sonnet
sonnet/python/ops/initializers.py
_Restore._partition_spec
def _partition_spec(self, shape, partition_info): """Build magic (and sparsely documented) shapes_and_slices spec string.""" if partition_info is None: return '' # Empty string indicates a non-partitioned tensor. ssi = tf.Variable.SaveSliceInfo( full_name=self._var_name, full_shape=pa...
python
def _partition_spec(self, shape, partition_info): """Build magic (and sparsely documented) shapes_and_slices spec string.""" if partition_info is None: return '' # Empty string indicates a non-partitioned tensor. ssi = tf.Variable.SaveSliceInfo( full_name=self._var_name, full_shape=pa...
[ "def", "_partition_spec", "(", "self", ",", "shape", ",", "partition_info", ")", ":", "if", "partition_info", "is", "None", ":", "return", "''", "# Empty string indicates a non-partitioned tensor.", "ssi", "=", "tf", ".", "Variable", ".", "SaveSliceInfo", "(", "fu...
Build magic (and sparsely documented) shapes_and_slices spec string.
[ "Build", "magic", "(", "and", "sparsely", "documented", ")", "shapes_and_slices", "spec", "string", "." ]
00612ca3178964d86b556e062694d808ff81fcca
https://github.com/deepmind/sonnet/blob/00612ca3178964d86b556e062694d808ff81fcca/sonnet/python/ops/initializers.py#L58-L67
train
ansible/molecule
molecule/provisioner/ansible_playbook.py
AnsiblePlaybook.bake
def bake(self): """ Bake an ``ansible-playbook`` command so it's ready to execute and returns ``None``. :return: None """ # Pass a directory as inventory to let Ansible merge the multiple # inventory sources located under self.add_cli_arg('inventory', ...
python
def bake(self): """ Bake an ``ansible-playbook`` command so it's ready to execute and returns ``None``. :return: None """ # Pass a directory as inventory to let Ansible merge the multiple # inventory sources located under self.add_cli_arg('inventory', ...
[ "def", "bake", "(", "self", ")", ":", "# Pass a directory as inventory to let Ansible merge the multiple", "# inventory sources located under", "self", ".", "add_cli_arg", "(", "'inventory'", ",", "self", ".", "_config", ".", "provisioner", ".", "inventory_directory", ")", ...
Bake an ``ansible-playbook`` command so it's ready to execute and returns ``None``. :return: None
[ "Bake", "an", "ansible", "-", "playbook", "command", "so", "it", "s", "ready", "to", "execute", "and", "returns", "None", "." ]
766dc35b0b0ce498cd5e3a62b40f828742d0d08c
https://github.com/ansible/molecule/blob/766dc35b0b0ce498cd5e3a62b40f828742d0d08c/molecule/provisioner/ansible_playbook.py#L51-L83
train
ansible/molecule
molecule/provisioner/ansible_playbook.py
AnsiblePlaybook.execute
def execute(self): """ Executes ``ansible-playbook`` and returns a string. :return: str """ if self._ansible_command is None: self.bake() try: self._config.driver.sanity_checks() cmd = util.run_command( self._ansible_c...
python
def execute(self): """ Executes ``ansible-playbook`` and returns a string. :return: str """ if self._ansible_command is None: self.bake() try: self._config.driver.sanity_checks() cmd = util.run_command( self._ansible_c...
[ "def", "execute", "(", "self", ")", ":", "if", "self", ".", "_ansible_command", "is", "None", ":", "self", ".", "bake", "(", ")", "try", ":", "self", ".", "_config", ".", "driver", ".", "sanity_checks", "(", ")", "cmd", "=", "util", ".", "run_command...
Executes ``ansible-playbook`` and returns a string. :return: str
[ "Executes", "ansible", "-", "playbook", "and", "returns", "a", "string", "." ]
766dc35b0b0ce498cd5e3a62b40f828742d0d08c
https://github.com/ansible/molecule/blob/766dc35b0b0ce498cd5e3a62b40f828742d0d08c/molecule/provisioner/ansible_playbook.py#L85-L101
train
ansible/molecule
molecule/command/login.py
login
def login(ctx, host, scenario_name): # pragma: no cover """ Log in to one instance. """ args = ctx.obj.get('args') subcommand = base._get_subcommand(__name__) command_args = { 'subcommand': subcommand, 'host': host, } s = scenarios.Scenarios( base.get_configs(args, comm...
python
def login(ctx, host, scenario_name): # pragma: no cover """ Log in to one instance. """ args = ctx.obj.get('args') subcommand = base._get_subcommand(__name__) command_args = { 'subcommand': subcommand, 'host': host, } s = scenarios.Scenarios( base.get_configs(args, comm...
[ "def", "login", "(", "ctx", ",", "host", ",", "scenario_name", ")", ":", "# pragma: no cover", "args", "=", "ctx", ".", "obj", ".", "get", "(", "'args'", ")", "subcommand", "=", "base", ".", "_get_subcommand", "(", "__name__", ")", "command_args", "=", "...
Log in to one instance.
[ "Log", "in", "to", "one", "instance", "." ]
766dc35b0b0ce498cd5e3a62b40f828742d0d08c
https://github.com/ansible/molecule/blob/766dc35b0b0ce498cd5e3a62b40f828742d0d08c/molecule/command/login.py#L170-L182
train
ansible/molecule
molecule/command/login.py
Login.execute
def execute(self): """ Execute the actions necessary to perform a `molecule login` and returns None. :return: None """ c = self._config if ((not c.state.created) and c.driver.managed): msg = 'Instances not created. Please create instances first.' ...
python
def execute(self): """ Execute the actions necessary to perform a `molecule login` and returns None. :return: None """ c = self._config if ((not c.state.created) and c.driver.managed): msg = 'Instances not created. Please create instances first.' ...
[ "def", "execute", "(", "self", ")", ":", "c", "=", "self", ".", "_config", "if", "(", "(", "not", "c", ".", "state", ".", "created", ")", "and", "c", ".", "driver", ".", "managed", ")", ":", "msg", "=", "'Instances not created. Please create instances f...
Execute the actions necessary to perform a `molecule login` and returns None. :return: None
[ "Execute", "the", "actions", "necessary", "to", "perform", "a", "molecule", "login", "and", "returns", "None", "." ]
766dc35b0b0ce498cd5e3a62b40f828742d0d08c
https://github.com/ansible/molecule/blob/766dc35b0b0ce498cd5e3a62b40f828742d0d08c/molecule/command/login.py#L89-L103
train
ansible/molecule
molecule/command/base.py
execute_cmdline_scenarios
def execute_cmdline_scenarios(scenario_name, args, command_args): """ Execute scenario sequences based on parsed command-line arguments. This is useful for subcommands that run scenario sequences, which excludes subcommands such as ``list``, ``login``, and ``matrix``. ``args`` and ``command_args``...
python
def execute_cmdline_scenarios(scenario_name, args, command_args): """ Execute scenario sequences based on parsed command-line arguments. This is useful for subcommands that run scenario sequences, which excludes subcommands such as ``list``, ``login``, and ``matrix``. ``args`` and ``command_args``...
[ "def", "execute_cmdline_scenarios", "(", "scenario_name", ",", "args", ",", "command_args", ")", ":", "scenarios", "=", "molecule", ".", "scenarios", ".", "Scenarios", "(", "get_configs", "(", "args", ",", "command_args", ")", ",", "scenario_name", ")", "scenari...
Execute scenario sequences based on parsed command-line arguments. This is useful for subcommands that run scenario sequences, which excludes subcommands such as ``list``, ``login``, and ``matrix``. ``args`` and ``command_args`` are combined using :func:`get_configs` to generate the scenario(s) config...
[ "Execute", "scenario", "sequences", "based", "on", "parsed", "command", "-", "line", "arguments", "." ]
766dc35b0b0ce498cd5e3a62b40f828742d0d08c
https://github.com/ansible/molecule/blob/766dc35b0b0ce498cd5e3a62b40f828742d0d08c/molecule/command/base.py#L75-L112
train
ansible/molecule
molecule/command/base.py
execute_scenario
def execute_scenario(scenario): """ Execute each command in the given scenario's configured sequence. :param scenario: The scenario to execute. :returns: None """ for action in scenario.sequence: execute_subcommand(scenario.config, action) # pruning only if a 'destroy' step was i...
python
def execute_scenario(scenario): """ Execute each command in the given scenario's configured sequence. :param scenario: The scenario to execute. :returns: None """ for action in scenario.sequence: execute_subcommand(scenario.config, action) # pruning only if a 'destroy' step was i...
[ "def", "execute_scenario", "(", "scenario", ")", ":", "for", "action", "in", "scenario", ".", "sequence", ":", "execute_subcommand", "(", "scenario", ".", "config", ",", "action", ")", "# pruning only if a 'destroy' step was in the sequence allows for normal", "# debuggin...
Execute each command in the given scenario's configured sequence. :param scenario: The scenario to execute. :returns: None
[ "Execute", "each", "command", "in", "the", "given", "scenario", "s", "configured", "sequence", "." ]
766dc35b0b0ce498cd5e3a62b40f828742d0d08c
https://github.com/ansible/molecule/blob/766dc35b0b0ce498cd5e3a62b40f828742d0d08c/molecule/command/base.py#L127-L142
train
ansible/molecule
molecule/command/base.py
get_configs
def get_configs(args, command_args, ansible_args=()): """ Glob the current directory for Molecule config files, instantiate config objects, and returns a list. :param args: A dict of options, arguments and commands from the CLI. :param command_args: A dict of options passed to the subcommand from ...
python
def get_configs(args, command_args, ansible_args=()): """ Glob the current directory for Molecule config files, instantiate config objects, and returns a list. :param args: A dict of options, arguments and commands from the CLI. :param command_args: A dict of options passed to the subcommand from ...
[ "def", "get_configs", "(", "args", ",", "command_args", ",", "ansible_args", "=", "(", ")", ")", ":", "configs", "=", "[", "config", ".", "Config", "(", "molecule_file", "=", "util", ".", "abs_path", "(", "c", ")", ",", "args", "=", "args", ",", "com...
Glob the current directory for Molecule config files, instantiate config objects, and returns a list. :param args: A dict of options, arguments and commands from the CLI. :param command_args: A dict of options passed to the subcommand from the CLI. :param ansible_args: An optional tuple of argumen...
[ "Glob", "the", "current", "directory", "for", "Molecule", "config", "files", "instantiate", "config", "objects", "and", "returns", "a", "list", "." ]
766dc35b0b0ce498cd5e3a62b40f828742d0d08c
https://github.com/ansible/molecule/blob/766dc35b0b0ce498cd5e3a62b40f828742d0d08c/molecule/command/base.py#L145-L167
train
ansible/molecule
molecule/command/base.py
_verify_configs
def _verify_configs(configs): """ Verify a Molecule config was found and returns None. :param configs: A list containing absolute paths to Molecule config files. :return: None """ if configs: scenario_names = [c.scenario.name for c in configs] for scenario_name, n in collections...
python
def _verify_configs(configs): """ Verify a Molecule config was found and returns None. :param configs: A list containing absolute paths to Molecule config files. :return: None """ if configs: scenario_names = [c.scenario.name for c in configs] for scenario_name, n in collections...
[ "def", "_verify_configs", "(", "configs", ")", ":", "if", "configs", ":", "scenario_names", "=", "[", "c", ".", "scenario", ".", "name", "for", "c", "in", "configs", "]", "for", "scenario_name", ",", "n", "in", "collections", ".", "Counter", "(", "scenar...
Verify a Molecule config was found and returns None. :param configs: A list containing absolute paths to Molecule config files. :return: None
[ "Verify", "a", "Molecule", "config", "was", "found", "and", "returns", "None", "." ]
766dc35b0b0ce498cd5e3a62b40f828742d0d08c
https://github.com/ansible/molecule/blob/766dc35b0b0ce498cd5e3a62b40f828742d0d08c/molecule/command/base.py#L170-L187
train
ansible/molecule
molecule/dependency/gilt.py
Gilt.bake
def bake(self): """ Bake a ``gilt`` command so it's ready to execute and returns None. :return: None """ self._sh_command = getattr(sh, self.command) self._sh_command = self._sh_command.bake( self.options, 'overlay', _env=self.env, ...
python
def bake(self): """ Bake a ``gilt`` command so it's ready to execute and returns None. :return: None """ self._sh_command = getattr(sh, self.command) self._sh_command = self._sh_command.bake( self.options, 'overlay', _env=self.env, ...
[ "def", "bake", "(", "self", ")", ":", "self", ".", "_sh_command", "=", "getattr", "(", "sh", ",", "self", ".", "command", ")", "self", ".", "_sh_command", "=", "self", ".", "_sh_command", ".", "bake", "(", "self", ".", "options", ",", "'overlay'", ",...
Bake a ``gilt`` command so it's ready to execute and returns None. :return: None
[ "Bake", "a", "gilt", "command", "so", "it", "s", "ready", "to", "execute", "and", "returns", "None", "." ]
766dc35b0b0ce498cd5e3a62b40f828742d0d08c
https://github.com/ansible/molecule/blob/766dc35b0b0ce498cd5e3a62b40f828742d0d08c/molecule/dependency/gilt.py#L86-L98
train
ansible/molecule
molecule/command/cleanup.py
Cleanup.execute
def execute(self): """ Execute the actions necessary to cleanup the instances and returns None. :return: None """ self.print_info() if not self._config.provisioner.playbooks.cleanup: msg = 'Skipping, cleanup playbook not configured.' LOG....
python
def execute(self): """ Execute the actions necessary to cleanup the instances and returns None. :return: None """ self.print_info() if not self._config.provisioner.playbooks.cleanup: msg = 'Skipping, cleanup playbook not configured.' LOG....
[ "def", "execute", "(", "self", ")", ":", "self", ".", "print_info", "(", ")", "if", "not", "self", ".", "_config", ".", "provisioner", ".", "playbooks", ".", "cleanup", ":", "msg", "=", "'Skipping, cleanup playbook not configured.'", "LOG", ".", "warn", "(",...
Execute the actions necessary to cleanup the instances and returns None. :return: None
[ "Execute", "the", "actions", "necessary", "to", "cleanup", "the", "instances", "and", "returns", "None", "." ]
766dc35b0b0ce498cd5e3a62b40f828742d0d08c
https://github.com/ansible/molecule/blob/766dc35b0b0ce498cd5e3a62b40f828742d0d08c/molecule/command/cleanup.py#L66-L80
train
ansible/molecule
molecule/provisioner/lint/ansible_lint.py
AnsibleLintMixin.bake
def bake(self): """ Bake an `ansible-lint` command so it's ready to execute and returns None. :return: None """ options = self.options default_exclude_list = options.pop('default_exclude') options_exclude_list = options.pop('exclude') excludes = d...
python
def bake(self): """ Bake an `ansible-lint` command so it's ready to execute and returns None. :return: None """ options = self.options default_exclude_list = options.pop('default_exclude') options_exclude_list = options.pop('exclude') excludes = d...
[ "def", "bake", "(", "self", ")", ":", "options", "=", "self", ".", "options", "default_exclude_list", "=", "options", ".", "pop", "(", "'default_exclude'", ")", "options_exclude_list", "=", "options", ".", "pop", "(", "'exclude'", ")", "excludes", "=", "defa...
Bake an `ansible-lint` command so it's ready to execute and returns None. :return: None
[ "Bake", "an", "ansible", "-", "lint", "command", "so", "it", "s", "ready", "to", "execute", "and", "returns", "None", "." ]
766dc35b0b0ce498cd5e3a62b40f828742d0d08c
https://github.com/ansible/molecule/blob/766dc35b0b0ce498cd5e3a62b40f828742d0d08c/molecule/provisioner/lint/ansible_lint.py#L64-L86
train
ansible/molecule
molecule/util.py
print_environment_vars
def print_environment_vars(env): """ Print ``Ansible`` and ``Molecule`` environment variables and returns None. :param env: A dict containing the shell's environment as collected by ``os.environ``. :return: None """ ansible_env = {k: v for (k, v) in env.items() if 'ANSIBLE_' in k} print...
python
def print_environment_vars(env): """ Print ``Ansible`` and ``Molecule`` environment variables and returns None. :param env: A dict containing the shell's environment as collected by ``os.environ``. :return: None """ ansible_env = {k: v for (k, v) in env.items() if 'ANSIBLE_' in k} print...
[ "def", "print_environment_vars", "(", "env", ")", ":", "ansible_env", "=", "{", "k", ":", "v", "for", "(", "k", ",", "v", ")", "in", "env", ".", "items", "(", ")", "if", "'ANSIBLE_'", "in", "k", "}", "print_debug", "(", "'ANSIBLE ENVIRONMENT'", ",", ...
Print ``Ansible`` and ``Molecule`` environment variables and returns None. :param env: A dict containing the shell's environment as collected by ``os.environ``. :return: None
[ "Print", "Ansible", "and", "Molecule", "environment", "variables", "and", "returns", "None", "." ]
766dc35b0b0ce498cd5e3a62b40f828742d0d08c
https://github.com/ansible/molecule/blob/766dc35b0b0ce498cd5e3a62b40f828742d0d08c/molecule/util.py#L58-L77
train
ansible/molecule
molecule/util.py
run_command
def run_command(cmd, debug=False): """ Execute the given command and returns None. :param cmd: A ``sh.Command`` object to execute. :param debug: An optional bool to toggle debug output. :return: ``sh`` object """ if debug: # WARN(retr0h): Uses an internal ``sh`` data structure to di...
python
def run_command(cmd, debug=False): """ Execute the given command and returns None. :param cmd: A ``sh.Command`` object to execute. :param debug: An optional bool to toggle debug output. :return: ``sh`` object """ if debug: # WARN(retr0h): Uses an internal ``sh`` data structure to di...
[ "def", "run_command", "(", "cmd", ",", "debug", "=", "False", ")", ":", "if", "debug", ":", "# WARN(retr0h): Uses an internal ``sh`` data structure to dig", "# the environment out of the ``sh.command`` object.", "print_environment_vars", "(", "cmd", ".", "_partial_call_args", ...
Execute the given command and returns None. :param cmd: A ``sh.Command`` object to execute. :param debug: An optional bool to toggle debug output. :return: ``sh`` object
[ "Execute", "the", "given", "command", "and", "returns", "None", "." ]
766dc35b0b0ce498cd5e3a62b40f828742d0d08c
https://github.com/ansible/molecule/blob/766dc35b0b0ce498cd5e3a62b40f828742d0d08c/molecule/util.py#L89-L103
train
ansible/molecule
molecule/util.py
write_file
def write_file(filename, content): """ Writes a file with the given filename and content and returns None. :param filename: A string containing the target filename. :param content: A string containing the data to be written. :return: None """ with open_file(filename, 'w') as f: f.wr...
python
def write_file(filename, content): """ Writes a file with the given filename and content and returns None. :param filename: A string containing the target filename. :param content: A string containing the data to be written. :return: None """ with open_file(filename, 'w') as f: f.wr...
[ "def", "write_file", "(", "filename", ",", "content", ")", ":", "with", "open_file", "(", "filename", ",", "'w'", ")", "as", "f", ":", "f", ".", "write", "(", "content", ")", "file_prepender", "(", "filename", ")" ]
Writes a file with the given filename and content and returns None. :param filename: A string containing the target filename. :param content: A string containing the data to be written. :return: None
[ "Writes", "a", "file", "with", "the", "given", "filename", "and", "content", "and", "returns", "None", "." ]
766dc35b0b0ce498cd5e3a62b40f828742d0d08c
https://github.com/ansible/molecule/blob/766dc35b0b0ce498cd5e3a62b40f828742d0d08c/molecule/util.py#L123-L134
train
ansible/molecule
molecule/util.py
file_prepender
def file_prepender(filename): """ Prepend an informational header on files managed by Molecule and returns None. :param filename: A string containing the target filename. :return: None """ with open_file(filename, 'r+') as f: content = f.read() f.seek(0, 0) f.write(m...
python
def file_prepender(filename): """ Prepend an informational header on files managed by Molecule and returns None. :param filename: A string containing the target filename. :return: None """ with open_file(filename, 'r+') as f: content = f.read() f.seek(0, 0) f.write(m...
[ "def", "file_prepender", "(", "filename", ")", ":", "with", "open_file", "(", "filename", ",", "'r+'", ")", "as", "f", ":", "content", "=", "f", ".", "read", "(", ")", "f", ".", "seek", "(", "0", ",", "0", ")", "f", ".", "write", "(", "molecule_p...
Prepend an informational header on files managed by Molecule and returns None. :param filename: A string containing the target filename. :return: None
[ "Prepend", "an", "informational", "header", "on", "files", "managed", "by", "Molecule", "and", "returns", "None", "." ]
766dc35b0b0ce498cd5e3a62b40f828742d0d08c
https://github.com/ansible/molecule/blob/766dc35b0b0ce498cd5e3a62b40f828742d0d08c/molecule/util.py#L141-L152
train
ansible/molecule
molecule/util.py
safe_dump
def safe_dump(data): """ Dump the provided data to a YAML document and returns a string. :param data: A string containing an absolute path to the file to parse. :return: str """ # TODO(retr0h): Do we need to encode? # yaml.dump(data) produces the document as a str object in both python ...
python
def safe_dump(data): """ Dump the provided data to a YAML document and returns a string. :param data: A string containing an absolute path to the file to parse. :return: str """ # TODO(retr0h): Do we need to encode? # yaml.dump(data) produces the document as a str object in both python ...
[ "def", "safe_dump", "(", "data", ")", ":", "# TODO(retr0h): Do we need to encode?", "# yaml.dump(data) produces the document as a str object in both python", "# 2 and 3.", "return", "yaml", ".", "dump", "(", "data", ",", "Dumper", "=", "SafeDumper", ",", "default_flow_style",...
Dump the provided data to a YAML document and returns a string. :param data: A string containing an absolute path to the file to parse. :return: str
[ "Dump", "the", "provided", "data", "to", "a", "YAML", "document", "and", "returns", "a", "string", "." ]
766dc35b0b0ce498cd5e3a62b40f828742d0d08c
https://github.com/ansible/molecule/blob/766dc35b0b0ce498cd5e3a62b40f828742d0d08c/molecule/util.py#L155-L166
train
ansible/molecule
molecule/util.py
safe_load
def safe_load(string): """ Parse the provided string returns a dict. :param string: A string to be parsed. :return: dict """ try: return yaml.safe_load(string) or {} except yaml.scanner.ScannerError as e: sysexit_with_message(str(e))
python
def safe_load(string): """ Parse the provided string returns a dict. :param string: A string to be parsed. :return: dict """ try: return yaml.safe_load(string) or {} except yaml.scanner.ScannerError as e: sysexit_with_message(str(e))
[ "def", "safe_load", "(", "string", ")", ":", "try", ":", "return", "yaml", ".", "safe_load", "(", "string", ")", "or", "{", "}", "except", "yaml", ".", "scanner", ".", "ScannerError", "as", "e", ":", "sysexit_with_message", "(", "str", "(", "e", ")", ...
Parse the provided string returns a dict. :param string: A string to be parsed. :return: dict
[ "Parse", "the", "provided", "string", "returns", "a", "dict", "." ]
766dc35b0b0ce498cd5e3a62b40f828742d0d08c
https://github.com/ansible/molecule/blob/766dc35b0b0ce498cd5e3a62b40f828742d0d08c/molecule/util.py#L169-L179
train
ansible/molecule
molecule/util.py
merge_dicts
def merge_dicts(a, b): """ Merges the values of B into A and returns a mutated dict A. :: dict a b: - c: 0 - c: 2 d: e: "aaa" f: 3 dict b a: 1 b: - c: 3 d: e: "bbb" Will give a...
python
def merge_dicts(a, b): """ Merges the values of B into A and returns a mutated dict A. :: dict a b: - c: 0 - c: 2 d: e: "aaa" f: 3 dict b a: 1 b: - c: 3 d: e: "bbb" Will give a...
[ "def", "merge_dicts", "(", "a", ",", "b", ")", ":", "anyconfig", ".", "merge", "(", "a", ",", "b", ",", "ac_merge", "=", "MERGE_STRATEGY", ")", "return", "a" ]
Merges the values of B into A and returns a mutated dict A. :: dict a b: - c: 0 - c: 2 d: e: "aaa" f: 3 dict b a: 1 b: - c: 3 d: e: "bbb" Will give an object such as:: {'a': 1...
[ "Merges", "the", "values", "of", "B", "into", "A", "and", "returns", "a", "mutated", "dict", "A", "." ]
766dc35b0b0ce498cd5e3a62b40f828742d0d08c
https://github.com/ansible/molecule/blob/766dc35b0b0ce498cd5e3a62b40f828742d0d08c/molecule/util.py#L265-L299
train
ansible/molecule
molecule/model/schema_v2.py
Validator._validate_unique
def _validate_unique(self, unique, field, value): """Ensure value uniqueness. The rule's arguments are validated against this schema: {'type': 'boolean'} """ if unique: root_key = self.schema_path[0] data = (doc[field] for doc in self.root_document[root_k...
python
def _validate_unique(self, unique, field, value): """Ensure value uniqueness. The rule's arguments are validated against this schema: {'type': 'boolean'} """ if unique: root_key = self.schema_path[0] data = (doc[field] for doc in self.root_document[root_k...
[ "def", "_validate_unique", "(", "self", ",", "unique", ",", "field", ",", "value", ")", ":", "if", "unique", ":", "root_key", "=", "self", ".", "schema_path", "[", "0", "]", "data", "=", "(", "doc", "[", "field", "]", "for", "doc", "in", "self", "....
Ensure value uniqueness. The rule's arguments are validated against this schema: {'type': 'boolean'}
[ "Ensure", "value", "uniqueness", "." ]
766dc35b0b0ce498cd5e3a62b40f828742d0d08c
https://github.com/ansible/molecule/blob/766dc35b0b0ce498cd5e3a62b40f828742d0d08c/molecule/model/schema_v2.py#L986-L998
train
ansible/molecule
molecule/model/schema_v2.py
Validator._validate_disallowed
def _validate_disallowed(self, disallowed, field, value): """ Readonly but with a custom error. The rule's arguments are validated against this schema: {'type': 'boolean'} """ if disallowed: msg = 'disallowed user provided config option' self._error(field...
python
def _validate_disallowed(self, disallowed, field, value): """ Readonly but with a custom error. The rule's arguments are validated against this schema: {'type': 'boolean'} """ if disallowed: msg = 'disallowed user provided config option' self._error(field...
[ "def", "_validate_disallowed", "(", "self", ",", "disallowed", ",", "field", ",", "value", ")", ":", "if", "disallowed", ":", "msg", "=", "'disallowed user provided config option'", "self", ".", "_error", "(", "field", ",", "msg", ")" ]
Readonly but with a custom error. The rule's arguments are validated against this schema: {'type': 'boolean'}
[ "Readonly", "but", "with", "a", "custom", "error", "." ]
766dc35b0b0ce498cd5e3a62b40f828742d0d08c
https://github.com/ansible/molecule/blob/766dc35b0b0ce498cd5e3a62b40f828742d0d08c/molecule/model/schema_v2.py#L1000-L1008
train
ansible/molecule
molecule/model/schema_v2.py
Validator._validate_molecule_env_var
def _validate_molecule_env_var(self, molecule_env_var, field, value): """ Readonly but with a custom error. The rule's arguments are validated against this schema: {'type': 'boolean'} """ # TODO(retr0h): This needs to be better handled. pattern = r'^[{$]+MOLECULE[_a-z0-9...
python
def _validate_molecule_env_var(self, molecule_env_var, field, value): """ Readonly but with a custom error. The rule's arguments are validated against this schema: {'type': 'boolean'} """ # TODO(retr0h): This needs to be better handled. pattern = r'^[{$]+MOLECULE[_a-z0-9...
[ "def", "_validate_molecule_env_var", "(", "self", ",", "molecule_env_var", ",", "field", ",", "value", ")", ":", "# TODO(retr0h): This needs to be better handled.", "pattern", "=", "r'^[{$]+MOLECULE[_a-z0-9A-Z]+[}]*$'", "if", "molecule_env_var", ":", "if", "re", ".", "mat...
Readonly but with a custom error. The rule's arguments are validated against this schema: {'type': 'boolean'}
[ "Readonly", "but", "with", "a", "custom", "error", "." ]
766dc35b0b0ce498cd5e3a62b40f828742d0d08c
https://github.com/ansible/molecule/blob/766dc35b0b0ce498cd5e3a62b40f828742d0d08c/molecule/model/schema_v2.py#L1021-L1034
train
ansible/molecule
molecule/command/idempotence.py
Idempotence.execute
def execute(self): """ Execute the actions necessary to perform a `molecule idempotence` and returns None. :return: None """ self.print_info() if not self._config.state.converged: msg = 'Instances not converged. Please converge instances first.' ...
python
def execute(self): """ Execute the actions necessary to perform a `molecule idempotence` and returns None. :return: None """ self.print_info() if not self._config.state.converged: msg = 'Instances not converged. Please converge instances first.' ...
[ "def", "execute", "(", "self", ")", ":", "self", ".", "print_info", "(", ")", "if", "not", "self", ".", "_config", ".", "state", ".", "converged", ":", "msg", "=", "'Instances not converged. Please converge instances first.'", "util", ".", "sysexit_with_message",...
Execute the actions necessary to perform a `molecule idempotence` and returns None. :return: None
[ "Execute", "the", "actions", "necessary", "to", "perform", "a", "molecule", "idempotence", "and", "returns", "None", "." ]
766dc35b0b0ce498cd5e3a62b40f828742d0d08c
https://github.com/ansible/molecule/blob/766dc35b0b0ce498cd5e3a62b40f828742d0d08c/molecule/command/idempotence.py#L69-L90
train
ansible/molecule
molecule/command/idempotence.py
Idempotence._is_idempotent
def _is_idempotent(self, output): """ Parses the output of the provisioning for changed and returns a bool. :param output: A string containing the output of the ansible run. :return: bool """ # Remove blank lines to make regex matches easier output = re.sub(r'\n...
python
def _is_idempotent(self, output): """ Parses the output of the provisioning for changed and returns a bool. :param output: A string containing the output of the ansible run. :return: bool """ # Remove blank lines to make regex matches easier output = re.sub(r'\n...
[ "def", "_is_idempotent", "(", "self", ",", "output", ")", ":", "# Remove blank lines to make regex matches easier", "output", "=", "re", ".", "sub", "(", "r'\\n\\s*\\n*'", ",", "'\\n'", ",", "output", ")", "# Look for any non-zero changed lines", "changed", "=", "re",...
Parses the output of the provisioning for changed and returns a bool. :param output: A string containing the output of the ansible run. :return: bool
[ "Parses", "the", "output", "of", "the", "provisioning", "for", "changed", "and", "returns", "a", "bool", "." ]
766dc35b0b0ce498cd5e3a62b40f828742d0d08c
https://github.com/ansible/molecule/blob/766dc35b0b0ce498cd5e3a62b40f828742d0d08c/molecule/command/idempotence.py#L92-L110
train
ansible/molecule
molecule/command/idempotence.py
Idempotence._non_idempotent_tasks
def _non_idempotent_tasks(self, output): """ Parses the output to identify the non idempotent tasks. :param (str) output: A string containing the output of the ansible run. :return: A list containing the names of the non idempotent tasks. """ # Remove blank lines to make...
python
def _non_idempotent_tasks(self, output): """ Parses the output to identify the non idempotent tasks. :param (str) output: A string containing the output of the ansible run. :return: A list containing the names of the non idempotent tasks. """ # Remove blank lines to make...
[ "def", "_non_idempotent_tasks", "(", "self", ",", "output", ")", ":", "# Remove blank lines to make regex matches easier.", "output", "=", "re", ".", "sub", "(", "r'\\n\\s*\\n*'", ",", "'\\n'", ",", "output", ")", "# Remove ansi escape sequences.", "output", "=", "uti...
Parses the output to identify the non idempotent tasks. :param (str) output: A string containing the output of the ansible run. :return: A list containing the names of the non idempotent tasks.
[ "Parses", "the", "output", "to", "identify", "the", "non", "idempotent", "tasks", "." ]
766dc35b0b0ce498cd5e3a62b40f828742d0d08c
https://github.com/ansible/molecule/blob/766dc35b0b0ce498cd5e3a62b40f828742d0d08c/molecule/command/idempotence.py#L112-L137
train
ansible/molecule
molecule/command/init/scenario.py
scenario
def scenario(ctx, dependency_name, driver_name, lint_name, provisioner_name, role_name, scenario_name, verifier_name): # pragma: no cover """ Initialize a new scenario for use with Molecule. """ command_args = { 'dependency_name': dependency_name, 'driver_name': driver_name, ...
python
def scenario(ctx, dependency_name, driver_name, lint_name, provisioner_name, role_name, scenario_name, verifier_name): # pragma: no cover """ Initialize a new scenario for use with Molecule. """ command_args = { 'dependency_name': dependency_name, 'driver_name': driver_name, ...
[ "def", "scenario", "(", "ctx", ",", "dependency_name", ",", "driver_name", ",", "lint_name", ",", "provisioner_name", ",", "role_name", ",", "scenario_name", ",", "verifier_name", ")", ":", "# pragma: no cover", "command_args", "=", "{", "'dependency_name'", ":", ...
Initialize a new scenario for use with Molecule.
[ "Initialize", "a", "new", "scenario", "for", "use", "with", "Molecule", "." ]
766dc35b0b0ce498cd5e3a62b40f828742d0d08c
https://github.com/ansible/molecule/blob/766dc35b0b0ce498cd5e3a62b40f828742d0d08c/molecule/command/init/scenario.py#L162-L186
train
ansible/molecule
molecule/command/init/scenario.py
Scenario.execute
def execute(self): """ Execute the actions necessary to perform a `molecule init scenario` and returns None. :return: None """ scenario_name = self._command_args['scenario_name'] role_name = os.getcwd().split(os.sep)[-1] role_directory = util.abs_path(os....
python
def execute(self): """ Execute the actions necessary to perform a `molecule init scenario` and returns None. :return: None """ scenario_name = self._command_args['scenario_name'] role_name = os.getcwd().split(os.sep)[-1] role_directory = util.abs_path(os....
[ "def", "execute", "(", "self", ")", ":", "scenario_name", "=", "self", ".", "_command_args", "[", "'scenario_name'", "]", "role_name", "=", "os", ".", "getcwd", "(", ")", ".", "split", "(", "os", ".", "sep", ")", "[", "-", "1", "]", "role_directory", ...
Execute the actions necessary to perform a `molecule init scenario` and returns None. :return: None
[ "Execute", "the", "actions", "necessary", "to", "perform", "a", "molecule", "init", "scenario", "and", "returns", "None", "." ]
766dc35b0b0ce498cd5e3a62b40f828742d0d08c
https://github.com/ansible/molecule/blob/766dc35b0b0ce498cd5e3a62b40f828742d0d08c/molecule/command/init/scenario.py#L53-L89
train
ansible/molecule
molecule/driver/docker.py
Docker.sanity_checks
def sanity_checks(self): """Implement Docker driver sanity checks.""" if self._config.state.sanity_checked: return log.info("Sanity checks: '{}'".format(self._name)) HAS_DOCKER_PY = None try: from ansible.module_utils.docker_common import HAS_DOCKER_PY ...
python
def sanity_checks(self): """Implement Docker driver sanity checks.""" if self._config.state.sanity_checked: return log.info("Sanity checks: '{}'".format(self._name)) HAS_DOCKER_PY = None try: from ansible.module_utils.docker_common import HAS_DOCKER_PY ...
[ "def", "sanity_checks", "(", "self", ")", ":", "if", "self", ".", "_config", ".", "state", ".", "sanity_checked", ":", "return", "log", ".", "info", "(", "\"Sanity checks: '{}'\"", ".", "format", "(", "self", ".", "_name", ")", ")", "HAS_DOCKER_PY", "=", ...
Implement Docker driver sanity checks.
[ "Implement", "Docker", "driver", "sanity", "checks", "." ]
766dc35b0b0ce498cd5e3a62b40f828742d0d08c
https://github.com/ansible/molecule/blob/766dc35b0b0ce498cd5e3a62b40f828742d0d08c/molecule/driver/docker.py#L191-L227
train
ansible/molecule
molecule/verifier/lint/flake8.py
Flake8.bake
def bake(self): """ Bake a `flake8` command so it's ready to execute and returns None. :return: None """ self._flake8_command = sh.flake8.bake( self.options, self._tests, _env=self.env, _out=LOG.out, _err=LOG.error)
python
def bake(self): """ Bake a `flake8` command so it's ready to execute and returns None. :return: None """ self._flake8_command = sh.flake8.bake( self.options, self._tests, _env=self.env, _out=LOG.out, _err=LOG.error)
[ "def", "bake", "(", "self", ")", ":", "self", ".", "_flake8_command", "=", "sh", ".", "flake8", ".", "bake", "(", "self", ".", "options", ",", "self", ".", "_tests", ",", "_env", "=", "self", ".", "env", ",", "_out", "=", "LOG", ".", "out", ",", ...
Bake a `flake8` command so it's ready to execute and returns None. :return: None
[ "Bake", "a", "flake8", "command", "so", "it", "s", "ready", "to", "execute", "and", "returns", "None", "." ]
766dc35b0b0ce498cd5e3a62b40f828742d0d08c
https://github.com/ansible/molecule/blob/766dc35b0b0ce498cd5e3a62b40f828742d0d08c/molecule/verifier/lint/flake8.py#L94-L105
train
ansible/molecule
molecule/dependency/ansible_galaxy.py
AnsibleGalaxy._setup
def _setup(self): """ Prepare the system for using ``ansible-galaxy`` and returns None. :return: None """ role_directory = os.path.join(self._config.scenario.directory, self.options['roles-path']) if not os.path.isdir(role_directory)...
python
def _setup(self): """ Prepare the system for using ``ansible-galaxy`` and returns None. :return: None """ role_directory = os.path.join(self._config.scenario.directory, self.options['roles-path']) if not os.path.isdir(role_directory)...
[ "def", "_setup", "(", "self", ")", ":", "role_directory", "=", "os", ".", "path", ".", "join", "(", "self", ".", "_config", ".", "scenario", ".", "directory", ",", "self", ".", "options", "[", "'roles-path'", "]", ")", "if", "not", "os", ".", "path",...
Prepare the system for using ``ansible-galaxy`` and returns None. :return: None
[ "Prepare", "the", "system", "for", "using", "ansible", "-", "galaxy", "and", "returns", "None", "." ]
766dc35b0b0ce498cd5e3a62b40f828742d0d08c
https://github.com/ansible/molecule/blob/766dc35b0b0ce498cd5e3a62b40f828742d0d08c/molecule/dependency/ansible_galaxy.py#L154-L163
train
ansible/molecule
molecule/command/converge.py
converge
def converge(ctx, scenario_name, ansible_args): # pragma: no cover """ Use the provisioner to configure instances (dependency, create, prepare converge). """ args = ctx.obj.get('args') subcommand = base._get_subcommand(__name__) command_args = { 'subcommand': subcommand, } ...
python
def converge(ctx, scenario_name, ansible_args): # pragma: no cover """ Use the provisioner to configure instances (dependency, create, prepare converge). """ args = ctx.obj.get('args') subcommand = base._get_subcommand(__name__) command_args = { 'subcommand': subcommand, } ...
[ "def", "converge", "(", "ctx", ",", "scenario_name", ",", "ansible_args", ")", ":", "# pragma: no cover", "args", "=", "ctx", ".", "obj", ".", "get", "(", "'args'", ")", "subcommand", "=", "base", ".", "_get_subcommand", "(", "__name__", ")", "command_args",...
Use the provisioner to configure instances (dependency, create, prepare converge).
[ "Use", "the", "provisioner", "to", "configure", "instances", "(", "dependency", "create", "prepare", "converge", ")", "." ]
766dc35b0b0ce498cd5e3a62b40f828742d0d08c
https://github.com/ansible/molecule/blob/766dc35b0b0ce498cd5e3a62b40f828742d0d08c/molecule/command/converge.py#L93-L105
train
ansible/molecule
molecule/command/converge.py
Converge.execute
def execute(self): """ Execute the actions necessary to perform a `molecule converge` and returns None. :return: None """ self.print_info() self._config.provisioner.converge() self._config.state.change_state('converged', True)
python
def execute(self): """ Execute the actions necessary to perform a `molecule converge` and returns None. :return: None """ self.print_info() self._config.provisioner.converge() self._config.state.change_state('converged', True)
[ "def", "execute", "(", "self", ")", ":", "self", ".", "print_info", "(", ")", "self", ".", "_config", ".", "provisioner", ".", "converge", "(", ")", "self", ".", "_config", ".", "state", ".", "change_state", "(", "'converged'", ",", "True", ")" ]
Execute the actions necessary to perform a `molecule converge` and returns None. :return: None
[ "Execute", "the", "actions", "necessary", "to", "perform", "a", "molecule", "converge", "and", "returns", "None", "." ]
766dc35b0b0ce498cd5e3a62b40f828742d0d08c
https://github.com/ansible/molecule/blob/766dc35b0b0ce498cd5e3a62b40f828742d0d08c/molecule/command/converge.py#L72-L81
train
ansible/molecule
molecule/scenarios.py
Scenarios.all
def all(self): """ Return a list containing all scenario objects. :return: list """ if self._scenario_name: scenarios = self._filter_for_scenario() self._verify() return scenarios scenarios = [c.scenario for c in self._configs] ...
python
def all(self): """ Return a list containing all scenario objects. :return: list """ if self._scenario_name: scenarios = self._filter_for_scenario() self._verify() return scenarios scenarios = [c.scenario for c in self._configs] ...
[ "def", "all", "(", "self", ")", ":", "if", "self", ".", "_scenario_name", ":", "scenarios", "=", "self", ".", "_filter_for_scenario", "(", ")", "self", ".", "_verify", "(", ")", "return", "scenarios", "scenarios", "=", "[", "c", ".", "scenario", "for", ...
Return a list containing all scenario objects. :return: list
[ "Return", "a", "list", "containing", "all", "scenario", "objects", "." ]
766dc35b0b0ce498cd5e3a62b40f828742d0d08c
https://github.com/ansible/molecule/blob/766dc35b0b0ce498cd5e3a62b40f828742d0d08c/molecule/scenarios.py#L60-L74
train
ansible/molecule
molecule/scenarios.py
Scenarios._verify
def _verify(self): """ Verify the specified scenario was found and returns None. :return: None """ scenario_names = [c.scenario.name for c in self._configs] if self._scenario_name not in scenario_names: msg = ("Scenario '{}' not found. " '...
python
def _verify(self): """ Verify the specified scenario was found and returns None. :return: None """ scenario_names = [c.scenario.name for c in self._configs] if self._scenario_name not in scenario_names: msg = ("Scenario '{}' not found. " '...
[ "def", "_verify", "(", "self", ")", ":", "scenario_names", "=", "[", "c", ".", "scenario", ".", "name", "for", "c", "in", "self", ".", "_configs", "]", "if", "self", ".", "_scenario_name", "not", "in", "scenario_names", ":", "msg", "=", "(", "\"Scenari...
Verify the specified scenario was found and returns None. :return: None
[ "Verify", "the", "specified", "scenario", "was", "found", "and", "returns", "None", "." ]
766dc35b0b0ce498cd5e3a62b40f828742d0d08c
https://github.com/ansible/molecule/blob/766dc35b0b0ce498cd5e3a62b40f828742d0d08c/molecule/scenarios.py#L92-L102
train
ansible/molecule
molecule/scenarios.py
Scenarios._filter_for_scenario
def _filter_for_scenario(self): """ Find the scenario matching the provided scenario name and returns a list. :return: list """ return [ c.scenario for c in self._configs if c.scenario.name == self._scenario_name ]
python
def _filter_for_scenario(self): """ Find the scenario matching the provided scenario name and returns a list. :return: list """ return [ c.scenario for c in self._configs if c.scenario.name == self._scenario_name ]
[ "def", "_filter_for_scenario", "(", "self", ")", ":", "return", "[", "c", ".", "scenario", "for", "c", "in", "self", ".", "_configs", "if", "c", ".", "scenario", ".", "name", "==", "self", ".", "_scenario_name", "]" ]
Find the scenario matching the provided scenario name and returns a list. :return: list
[ "Find", "the", "scenario", "matching", "the", "provided", "scenario", "name", "and", "returns", "a", "list", "." ]
766dc35b0b0ce498cd5e3a62b40f828742d0d08c
https://github.com/ansible/molecule/blob/766dc35b0b0ce498cd5e3a62b40f828742d0d08c/molecule/scenarios.py#L104-L114
train
ansible/molecule
molecule/scenarios.py
Scenarios._get_matrix
def _get_matrix(self): """ Build a matrix of scenarios with sequence to include and returns a dict. { scenario_1: { 'subcommand': [ 'action-1', 'action-2', ], }, scenario_2: { ...
python
def _get_matrix(self): """ Build a matrix of scenarios with sequence to include and returns a dict. { scenario_1: { 'subcommand': [ 'action-1', 'action-2', ], }, scenario_2: { ...
[ "def", "_get_matrix", "(", "self", ")", ":", "return", "dict", "(", "{", "scenario", ".", "name", ":", "{", "'check'", ":", "scenario", ".", "check_sequence", ",", "'cleanup'", ":", "scenario", ".", "cleanup_sequence", ",", "'converge'", ":", "scenario", "...
Build a matrix of scenarios with sequence to include and returns a dict. { scenario_1: { 'subcommand': [ 'action-1', 'action-2', ], }, scenario_2: { 'subcommand': [ ...
[ "Build", "a", "matrix", "of", "scenarios", "with", "sequence", "to", "include", "and", "returns", "a", "dict", "." ]
766dc35b0b0ce498cd5e3a62b40f828742d0d08c
https://github.com/ansible/molecule/blob/766dc35b0b0ce498cd5e3a62b40f828742d0d08c/molecule/scenarios.py#L116-L154
train
ansible/molecule
molecule/logger.py
get_logger
def get_logger(name=None): """ Build a logger with the given name and returns the logger. :param name: The name for the logger. This is usually the module name, ``__name__``. :return: logger object """ logging.setLoggerClass(CustomLogger) logger = logging.getLogger(name) ...
python
def get_logger(name=None): """ Build a logger with the given name and returns the logger. :param name: The name for the logger. This is usually the module name, ``__name__``. :return: logger object """ logging.setLoggerClass(CustomLogger) logger = logging.getLogger(name) ...
[ "def", "get_logger", "(", "name", "=", "None", ")", ":", "logging", ".", "setLoggerClass", "(", "CustomLogger", ")", "logger", "=", "logging", ".", "getLogger", "(", "name", ")", "logger", ".", "setLevel", "(", "logging", ".", "DEBUG", ")", "logger", "."...
Build a logger with the given name and returns the logger. :param name: The name for the logger. This is usually the module name, ``__name__``. :return: logger object
[ "Build", "a", "logger", "with", "the", "given", "name", "and", "returns", "the", "logger", "." ]
766dc35b0b0ce498cd5e3a62b40f828742d0d08c
https://github.com/ansible/molecule/blob/766dc35b0b0ce498cd5e3a62b40f828742d0d08c/molecule/logger.py#L86-L107
train
ansible/molecule
molecule/command/lint.py
lint
def lint(ctx, scenario_name): # pragma: no cover """ Lint the role. """ args = ctx.obj.get('args') subcommand = base._get_subcommand(__name__) command_args = { 'subcommand': subcommand, } base.execute_cmdline_scenarios(scenario_name, args, command_args)
python
def lint(ctx, scenario_name): # pragma: no cover """ Lint the role. """ args = ctx.obj.get('args') subcommand = base._get_subcommand(__name__) command_args = { 'subcommand': subcommand, } base.execute_cmdline_scenarios(scenario_name, args, command_args)
[ "def", "lint", "(", "ctx", ",", "scenario_name", ")", ":", "# pragma: no cover", "args", "=", "ctx", ".", "obj", ".", "get", "(", "'args'", ")", "subcommand", "=", "base", ".", "_get_subcommand", "(", "__name__", ")", "command_args", "=", "{", "'subcommand...
Lint the role.
[ "Lint", "the", "role", "." ]
766dc35b0b0ce498cd5e3a62b40f828742d0d08c
https://github.com/ansible/molecule/blob/766dc35b0b0ce498cd5e3a62b40f828742d0d08c/molecule/command/lint.py#L91-L99
train
ansible/molecule
molecule/command/lint.py
Lint.execute
def execute(self): """ Execute the actions necessary to perform a `molecule lint` and returns None. :return: None """ self.print_info() linters = [ l for l in [ self._config.lint, self._config.verifier.lint, ...
python
def execute(self): """ Execute the actions necessary to perform a `molecule lint` and returns None. :return: None """ self.print_info() linters = [ l for l in [ self._config.lint, self._config.verifier.lint, ...
[ "def", "execute", "(", "self", ")", ":", "self", ".", "print_info", "(", ")", "linters", "=", "[", "l", "for", "l", "in", "[", "self", ".", "_config", ".", "lint", ",", "self", ".", "_config", ".", "verifier", ".", "lint", ",", "self", ".", "_con...
Execute the actions necessary to perform a `molecule lint` and returns None. :return: None
[ "Execute", "the", "actions", "necessary", "to", "perform", "a", "molecule", "lint", "and", "returns", "None", "." ]
766dc35b0b0ce498cd5e3a62b40f828742d0d08c
https://github.com/ansible/molecule/blob/766dc35b0b0ce498cd5e3a62b40f828742d0d08c/molecule/command/lint.py#L63-L80
train
ansible/molecule
molecule/provisioner/ansible.py
Ansible.inventory
def inventory(self): """ Create an inventory structure and returns a dict. .. code-block:: yaml ungrouped: vars: foo: bar hosts: instance-1: instance-2: children: $child_group_n...
python
def inventory(self): """ Create an inventory structure and returns a dict. .. code-block:: yaml ungrouped: vars: foo: bar hosts: instance-1: instance-2: children: $child_group_n...
[ "def", "inventory", "(", "self", ")", ":", "dd", "=", "self", ".", "_vivify", "(", ")", "for", "platform", "in", "self", ".", "_config", ".", "platforms", ".", "instances", ":", "for", "group", "in", "platform", ".", "get", "(", "'groups'", ",", "[",...
Create an inventory structure and returns a dict. .. code-block:: yaml ungrouped: vars: foo: bar hosts: instance-1: instance-2: children: $child_group_name: hosts: ...
[ "Create", "an", "inventory", "structure", "and", "returns", "a", "dict", "." ]
766dc35b0b0ce498cd5e3a62b40f828742d0d08c
https://github.com/ansible/molecule/blob/766dc35b0b0ce498cd5e3a62b40f828742d0d08c/molecule/provisioner/ansible.py#L529-L588
train
ansible/molecule
molecule/provisioner/ansible.py
Ansible.cleanup
def cleanup(self): """ Executes `ansible-playbook` against the cleanup playbook and returns None. :return: None """ pb = self._get_ansible_playbook(self.playbooks.cleanup) pb.execute()
python
def cleanup(self): """ Executes `ansible-playbook` against the cleanup playbook and returns None. :return: None """ pb = self._get_ansible_playbook(self.playbooks.cleanup) pb.execute()
[ "def", "cleanup", "(", "self", ")", ":", "pb", "=", "self", ".", "_get_ansible_playbook", "(", "self", ".", "playbooks", ".", "cleanup", ")", "pb", ".", "execute", "(", ")" ]
Executes `ansible-playbook` against the cleanup playbook and returns None. :return: None
[ "Executes", "ansible", "-", "playbook", "against", "the", "cleanup", "playbook", "and", "returns", "None", "." ]
766dc35b0b0ce498cd5e3a62b40f828742d0d08c
https://github.com/ansible/molecule/blob/766dc35b0b0ce498cd5e3a62b40f828742d0d08c/molecule/provisioner/ansible.py#L614-L622
train
ansible/molecule
molecule/provisioner/ansible.py
Ansible.converge
def converge(self, playbook=None, **kwargs): """ Executes ``ansible-playbook`` against the converge playbook unless specified otherwise and returns a string. :param playbook: An optional string containing an absolute path to a playbook. :param kwargs: An optional keywor...
python
def converge(self, playbook=None, **kwargs): """ Executes ``ansible-playbook`` against the converge playbook unless specified otherwise and returns a string. :param playbook: An optional string containing an absolute path to a playbook. :param kwargs: An optional keywor...
[ "def", "converge", "(", "self", ",", "playbook", "=", "None", ",", "*", "*", "kwargs", ")", ":", "if", "playbook", "is", "None", ":", "pb", "=", "self", ".", "_get_ansible_playbook", "(", "self", ".", "playbooks", ".", "converge", ",", "*", "*", "kwa...
Executes ``ansible-playbook`` against the converge playbook unless specified otherwise and returns a string. :param playbook: An optional string containing an absolute path to a playbook. :param kwargs: An optional keyword arguments. :return: str
[ "Executes", "ansible", "-", "playbook", "against", "the", "converge", "playbook", "unless", "specified", "otherwise", "and", "returns", "a", "string", "." ]
766dc35b0b0ce498cd5e3a62b40f828742d0d08c
https://github.com/ansible/molecule/blob/766dc35b0b0ce498cd5e3a62b40f828742d0d08c/molecule/provisioner/ansible.py#L641-L656
train
ansible/molecule
molecule/provisioner/ansible.py
Ansible.destroy
def destroy(self): """ Executes ``ansible-playbook`` against the destroy playbook and returns None. :return: None """ pb = self._get_ansible_playbook(self.playbooks.destroy) pb.execute()
python
def destroy(self): """ Executes ``ansible-playbook`` against the destroy playbook and returns None. :return: None """ pb = self._get_ansible_playbook(self.playbooks.destroy) pb.execute()
[ "def", "destroy", "(", "self", ")", ":", "pb", "=", "self", ".", "_get_ansible_playbook", "(", "self", ".", "playbooks", ".", "destroy", ")", "pb", ".", "execute", "(", ")" ]
Executes ``ansible-playbook`` against the destroy playbook and returns None. :return: None
[ "Executes", "ansible", "-", "playbook", "against", "the", "destroy", "playbook", "and", "returns", "None", "." ]
766dc35b0b0ce498cd5e3a62b40f828742d0d08c
https://github.com/ansible/molecule/blob/766dc35b0b0ce498cd5e3a62b40f828742d0d08c/molecule/provisioner/ansible.py#L658-L666
train
ansible/molecule
molecule/provisioner/ansible.py
Ansible.side_effect
def side_effect(self): """ Executes ``ansible-playbook`` against the side_effect playbook and returns None. :return: None """ pb = self._get_ansible_playbook(self.playbooks.side_effect) pb.execute()
python
def side_effect(self): """ Executes ``ansible-playbook`` against the side_effect playbook and returns None. :return: None """ pb = self._get_ansible_playbook(self.playbooks.side_effect) pb.execute()
[ "def", "side_effect", "(", "self", ")", ":", "pb", "=", "self", ".", "_get_ansible_playbook", "(", "self", ".", "playbooks", ".", "side_effect", ")", "pb", ".", "execute", "(", ")" ]
Executes ``ansible-playbook`` against the side_effect playbook and returns None. :return: None
[ "Executes", "ansible", "-", "playbook", "against", "the", "side_effect", "playbook", "and", "returns", "None", "." ]
766dc35b0b0ce498cd5e3a62b40f828742d0d08c
https://github.com/ansible/molecule/blob/766dc35b0b0ce498cd5e3a62b40f828742d0d08c/molecule/provisioner/ansible.py#L668-L676
train
ansible/molecule
molecule/provisioner/ansible.py
Ansible.create
def create(self): """ Executes ``ansible-playbook`` against the create playbook and returns None. :return: None """ pb = self._get_ansible_playbook(self.playbooks.create) pb.execute()
python
def create(self): """ Executes ``ansible-playbook`` against the create playbook and returns None. :return: None """ pb = self._get_ansible_playbook(self.playbooks.create) pb.execute()
[ "def", "create", "(", "self", ")", ":", "pb", "=", "self", ".", "_get_ansible_playbook", "(", "self", ".", "playbooks", ".", "create", ")", "pb", ".", "execute", "(", ")" ]
Executes ``ansible-playbook`` against the create playbook and returns None. :return: None
[ "Executes", "ansible", "-", "playbook", "against", "the", "create", "playbook", "and", "returns", "None", "." ]
766dc35b0b0ce498cd5e3a62b40f828742d0d08c
https://github.com/ansible/molecule/blob/766dc35b0b0ce498cd5e3a62b40f828742d0d08c/molecule/provisioner/ansible.py#L678-L686
train
ansible/molecule
molecule/provisioner/ansible.py
Ansible.prepare
def prepare(self): """ Executes ``ansible-playbook`` against the prepare playbook and returns None. :return: None """ pb = self._get_ansible_playbook(self.playbooks.prepare) pb.execute()
python
def prepare(self): """ Executes ``ansible-playbook`` against the prepare playbook and returns None. :return: None """ pb = self._get_ansible_playbook(self.playbooks.prepare) pb.execute()
[ "def", "prepare", "(", "self", ")", ":", "pb", "=", "self", ".", "_get_ansible_playbook", "(", "self", ".", "playbooks", ".", "prepare", ")", "pb", ".", "execute", "(", ")" ]
Executes ``ansible-playbook`` against the prepare playbook and returns None. :return: None
[ "Executes", "ansible", "-", "playbook", "against", "the", "prepare", "playbook", "and", "returns", "None", "." ]
766dc35b0b0ce498cd5e3a62b40f828742d0d08c
https://github.com/ansible/molecule/blob/766dc35b0b0ce498cd5e3a62b40f828742d0d08c/molecule/provisioner/ansible.py#L688-L696
train
ansible/molecule
molecule/provisioner/ansible.py
Ansible.syntax
def syntax(self): """ Executes ``ansible-playbook`` against the converge playbook with the ``-syntax-check`` flag and returns None. :return: None """ pb = self._get_ansible_playbook(self.playbooks.converge) pb.add_cli_arg('syntax-check', True) pb.execute(...
python
def syntax(self): """ Executes ``ansible-playbook`` against the converge playbook with the ``-syntax-check`` flag and returns None. :return: None """ pb = self._get_ansible_playbook(self.playbooks.converge) pb.add_cli_arg('syntax-check', True) pb.execute(...
[ "def", "syntax", "(", "self", ")", ":", "pb", "=", "self", ".", "_get_ansible_playbook", "(", "self", ".", "playbooks", ".", "converge", ")", "pb", ".", "add_cli_arg", "(", "'syntax-check'", ",", "True", ")", "pb", ".", "execute", "(", ")" ]
Executes ``ansible-playbook`` against the converge playbook with the ``-syntax-check`` flag and returns None. :return: None
[ "Executes", "ansible", "-", "playbook", "against", "the", "converge", "playbook", "with", "the", "-", "syntax", "-", "check", "flag", "and", "returns", "None", "." ]
766dc35b0b0ce498cd5e3a62b40f828742d0d08c
https://github.com/ansible/molecule/blob/766dc35b0b0ce498cd5e3a62b40f828742d0d08c/molecule/provisioner/ansible.py#L698-L707
train
ansible/molecule
molecule/provisioner/ansible.py
Ansible.verify
def verify(self): """ Executes ``ansible-playbook`` against the verify playbook and returns None. :return: None """ pb = self._get_ansible_playbook(self.playbooks.verify) pb.execute()
python
def verify(self): """ Executes ``ansible-playbook`` against the verify playbook and returns None. :return: None """ pb = self._get_ansible_playbook(self.playbooks.verify) pb.execute()
[ "def", "verify", "(", "self", ")", ":", "pb", "=", "self", ".", "_get_ansible_playbook", "(", "self", ".", "playbooks", ".", "verify", ")", "pb", ".", "execute", "(", ")" ]
Executes ``ansible-playbook`` against the verify playbook and returns None. :return: None
[ "Executes", "ansible", "-", "playbook", "against", "the", "verify", "playbook", "and", "returns", "None", "." ]
766dc35b0b0ce498cd5e3a62b40f828742d0d08c
https://github.com/ansible/molecule/blob/766dc35b0b0ce498cd5e3a62b40f828742d0d08c/molecule/provisioner/ansible.py#L709-L717
train