partition
stringclasses
3 values
func_name
stringlengths
1
134
docstring
stringlengths
1
46.9k
path
stringlengths
4
223
original_string
stringlengths
75
104k
code
stringlengths
75
104k
docstring_tokens
listlengths
1
1.97k
repo
stringlengths
7
55
language
stringclasses
1 value
url
stringlengths
87
315
code_tokens
listlengths
19
28.4k
sha
stringlengths
40
40
train
SamApiProvider._merge_apis
Quite often, an API is defined both in Implicit and Explicit API definitions. In such cases, Implicit API definition wins because that conveys clear intent that the API is backed by a function. This method will merge two such list of Apis with the right order of precedence. If a Path+Method combination ...
samcli/commands/local/lib/sam_api_provider.py
def _merge_apis(collector): """ Quite often, an API is defined both in Implicit and Explicit API definitions. In such cases, Implicit API definition wins because that conveys clear intent that the API is backed by a function. This method will merge two such list of Apis with the right or...
def _merge_apis(collector): """ Quite often, an API is defined both in Implicit and Explicit API definitions. In such cases, Implicit API definition wins because that conveys clear intent that the API is backed by a function. This method will merge two such list of Apis with the right or...
[ "Quite", "often", "an", "API", "is", "defined", "both", "in", "Implicit", "and", "Explicit", "API", "definitions", ".", "In", "such", "cases", "Implicit", "API", "definition", "wins", "because", "that", "conveys", "clear", "intent", "that", "the", "API", "is...
awslabs/aws-sam-cli
python
https://github.com/awslabs/aws-sam-cli/blob/c05af5e7378c6f05f7d82ad3f0bca17204177db6/samcli/commands/local/lib/sam_api_provider.py#L150-L198
[ "def", "_merge_apis", "(", "collector", ")", ":", "implicit_apis", "=", "[", "]", "explicit_apis", "=", "[", "]", "# Store implicit and explicit APIs separately in order to merge them later in the correct order", "# Implicit APIs are defined on a resource with logicalID ServerlessRestA...
c05af5e7378c6f05f7d82ad3f0bca17204177db6
train
SamApiProvider._normalize_apis
Normalize the APIs to use standard method name Parameters ---------- apis : list of samcli.commands.local.lib.provider.Api List of APIs to replace normalize Returns ------- list of samcli.commands.local.lib.provider.Api List of normalized APIs
samcli/commands/local/lib/sam_api_provider.py
def _normalize_apis(apis): """ Normalize the APIs to use standard method name Parameters ---------- apis : list of samcli.commands.local.lib.provider.Api List of APIs to replace normalize Returns ------- list of samcli.commands.local.lib.prov...
def _normalize_apis(apis): """ Normalize the APIs to use standard method name Parameters ---------- apis : list of samcli.commands.local.lib.provider.Api List of APIs to replace normalize Returns ------- list of samcli.commands.local.lib.prov...
[ "Normalize", "the", "APIs", "to", "use", "standard", "method", "name" ]
awslabs/aws-sam-cli
python
https://github.com/awslabs/aws-sam-cli/blob/c05af5e7378c6f05f7d82ad3f0bca17204177db6/samcli/commands/local/lib/sam_api_provider.py#L201-L222
[ "def", "_normalize_apis", "(", "apis", ")", ":", "result", "=", "list", "(", ")", "for", "api", "in", "apis", ":", "for", "normalized_method", "in", "SamApiProvider", ".", "_normalize_http_methods", "(", "api", ".", "method", ")", ":", "# _replace returns a co...
c05af5e7378c6f05f7d82ad3f0bca17204177db6
train
SamApiProvider._extract_apis_from_function
Fetches a list of APIs configured for this SAM Function resource. Parameters ---------- logical_id : str Logical ID of the resource function_resource : dict Contents of the function resource including its properties collector : ApiCollector ...
samcli/commands/local/lib/sam_api_provider.py
def _extract_apis_from_function(logical_id, function_resource, collector): """ Fetches a list of APIs configured for this SAM Function resource. Parameters ---------- logical_id : str Logical ID of the resource function_resource : dict Contents o...
def _extract_apis_from_function(logical_id, function_resource, collector): """ Fetches a list of APIs configured for this SAM Function resource. Parameters ---------- logical_id : str Logical ID of the resource function_resource : dict Contents o...
[ "Fetches", "a", "list", "of", "APIs", "configured", "for", "this", "SAM", "Function", "resource", "." ]
awslabs/aws-sam-cli
python
https://github.com/awslabs/aws-sam-cli/blob/c05af5e7378c6f05f7d82ad3f0bca17204177db6/samcli/commands/local/lib/sam_api_provider.py#L225-L243
[ "def", "_extract_apis_from_function", "(", "logical_id", ",", "function_resource", ",", "collector", ")", ":", "resource_properties", "=", "function_resource", ".", "get", "(", "\"Properties\"", ",", "{", "}", ")", "serverless_function_events", "=", "resource_properties...
c05af5e7378c6f05f7d82ad3f0bca17204177db6
train
SamApiProvider._extract_apis_from_events
Given an AWS::Serverless::Function Event Dictionary, extract out all 'Api' events and store within the collector Parameters ---------- function_logical_id : str LogicalId of the AWS::Serverless::Function serverless_function_events : dict Event Dictionar...
samcli/commands/local/lib/sam_api_provider.py
def _extract_apis_from_events(function_logical_id, serverless_function_events, collector): """ Given an AWS::Serverless::Function Event Dictionary, extract out all 'Api' events and store within the collector Parameters ---------- function_logical_id : str Lo...
def _extract_apis_from_events(function_logical_id, serverless_function_events, collector): """ Given an AWS::Serverless::Function Event Dictionary, extract out all 'Api' events and store within the collector Parameters ---------- function_logical_id : str Lo...
[ "Given", "an", "AWS", "::", "Serverless", "::", "Function", "Event", "Dictionary", "extract", "out", "all", "Api", "events", "and", "store", "within", "the", "collector" ]
awslabs/aws-sam-cli
python
https://github.com/awslabs/aws-sam-cli/blob/c05af5e7378c6f05f7d82ad3f0bca17204177db6/samcli/commands/local/lib/sam_api_provider.py#L246-L270
[ "def", "_extract_apis_from_events", "(", "function_logical_id", ",", "serverless_function_events", ",", "collector", ")", ":", "count", "=", "0", "for", "_", ",", "event", "in", "serverless_function_events", ".", "items", "(", ")", ":", "if", "SamApiProvider", "."...
c05af5e7378c6f05f7d82ad3f0bca17204177db6
train
SamApiProvider._convert_event_api
Converts a AWS::Serverless::Function's Event Property to an Api configuration usable by the provider. :param str lambda_logical_id: Logical Id of the AWS::Serverless::Function :param dict event_properties: Dictionary of the Event's Property :return tuple: tuple of API resource name and Api name...
samcli/commands/local/lib/sam_api_provider.py
def _convert_event_api(lambda_logical_id, event_properties): """ Converts a AWS::Serverless::Function's Event Property to an Api configuration usable by the provider. :param str lambda_logical_id: Logical Id of the AWS::Serverless::Function :param dict event_properties: Dictionary of th...
def _convert_event_api(lambda_logical_id, event_properties): """ Converts a AWS::Serverless::Function's Event Property to an Api configuration usable by the provider. :param str lambda_logical_id: Logical Id of the AWS::Serverless::Function :param dict event_properties: Dictionary of th...
[ "Converts", "a", "AWS", "::", "Serverless", "::", "Function", "s", "Event", "Property", "to", "an", "Api", "configuration", "usable", "by", "the", "provider", "." ]
awslabs/aws-sam-cli
python
https://github.com/awslabs/aws-sam-cli/blob/c05af5e7378c6f05f7d82ad3f0bca17204177db6/samcli/commands/local/lib/sam_api_provider.py#L273-L298
[ "def", "_convert_event_api", "(", "lambda_logical_id", ",", "event_properties", ")", ":", "path", "=", "event_properties", ".", "get", "(", "SamApiProvider", ".", "_EVENT_PATH", ")", "method", "=", "event_properties", ".", "get", "(", "SamApiProvider", ".", "_EVEN...
c05af5e7378c6f05f7d82ad3f0bca17204177db6
train
SamApiProvider._normalize_http_methods
Normalizes Http Methods. Api Gateway allows a Http Methods of ANY. This is a special verb to denote all supported Http Methods on Api Gateway. :param str http_method: Http method :yield str: Either the input http_method or one of the _ANY_HTTP_METHODS (normalized Http Methods)
samcli/commands/local/lib/sam_api_provider.py
def _normalize_http_methods(http_method): """ Normalizes Http Methods. Api Gateway allows a Http Methods of ANY. This is a special verb to denote all supported Http Methods on Api Gateway. :param str http_method: Http method :yield str: Either the input http_method or one of the...
def _normalize_http_methods(http_method): """ Normalizes Http Methods. Api Gateway allows a Http Methods of ANY. This is a special verb to denote all supported Http Methods on Api Gateway. :param str http_method: Http method :yield str: Either the input http_method or one of the...
[ "Normalizes", "Http", "Methods", ".", "Api", "Gateway", "allows", "a", "Http", "Methods", "of", "ANY", ".", "This", "is", "a", "special", "verb", "to", "denote", "all", "supported", "Http", "Methods", "on", "Api", "Gateway", "." ]
awslabs/aws-sam-cli
python
https://github.com/awslabs/aws-sam-cli/blob/c05af5e7378c6f05f7d82ad3f0bca17204177db6/samcli/commands/local/lib/sam_api_provider.py#L301-L314
[ "def", "_normalize_http_methods", "(", "http_method", ")", ":", "if", "http_method", ".", "upper", "(", ")", "==", "'ANY'", ":", "for", "method", "in", "SamApiProvider", ".", "_ANY_HTTP_METHODS", ":", "yield", "method", ".", "upper", "(", ")", "else", ":", ...
c05af5e7378c6f05f7d82ad3f0bca17204177db6
train
ApiCollector.add_apis
Stores the given APIs tagged under the given logicalId Parameters ---------- logical_id : str LogicalId of the AWS::Serverless::Api resource apis : list of samcli.commands.local.lib.provider.Api List of APIs available in this resource
samcli/commands/local/lib/sam_api_provider.py
def add_apis(self, logical_id, apis): """ Stores the given APIs tagged under the given logicalId Parameters ---------- logical_id : str LogicalId of the AWS::Serverless::Api resource apis : list of samcli.commands.local.lib.provider.Api List of A...
def add_apis(self, logical_id, apis): """ Stores the given APIs tagged under the given logicalId Parameters ---------- logical_id : str LogicalId of the AWS::Serverless::Api resource apis : list of samcli.commands.local.lib.provider.Api List of A...
[ "Stores", "the", "given", "APIs", "tagged", "under", "the", "given", "logicalId" ]
awslabs/aws-sam-cli
python
https://github.com/awslabs/aws-sam-cli/blob/c05af5e7378c6f05f7d82ad3f0bca17204177db6/samcli/commands/local/lib/sam_api_provider.py#L350-L363
[ "def", "add_apis", "(", "self", ",", "logical_id", ",", "apis", ")", ":", "properties", "=", "self", ".", "_get_properties", "(", "logical_id", ")", "properties", ".", "apis", ".", "extend", "(", "apis", ")" ]
c05af5e7378c6f05f7d82ad3f0bca17204177db6
train
ApiCollector.add_binary_media_types
Stores the binary media type configuration for the API with given logical ID Parameters ---------- logical_id : str LogicalId of the AWS::Serverless::Api resource binary_media_types : list of str List of binary media types supported by this resource
samcli/commands/local/lib/sam_api_provider.py
def add_binary_media_types(self, logical_id, binary_media_types): """ Stores the binary media type configuration for the API with given logical ID Parameters ---------- logical_id : str LogicalId of the AWS::Serverless::Api resource binary_media_types : list...
def add_binary_media_types(self, logical_id, binary_media_types): """ Stores the binary media type configuration for the API with given logical ID Parameters ---------- logical_id : str LogicalId of the AWS::Serverless::Api resource binary_media_types : list...
[ "Stores", "the", "binary", "media", "type", "configuration", "for", "the", "API", "with", "given", "logical", "ID" ]
awslabs/aws-sam-cli
python
https://github.com/awslabs/aws-sam-cli/blob/c05af5e7378c6f05f7d82ad3f0bca17204177db6/samcli/commands/local/lib/sam_api_provider.py#L365-L388
[ "def", "add_binary_media_types", "(", "self", ",", "logical_id", ",", "binary_media_types", ")", ":", "properties", "=", "self", ".", "_get_properties", "(", "logical_id", ")", "binary_media_types", "=", "binary_media_types", "or", "[", "]", "for", "value", "in", ...
c05af5e7378c6f05f7d82ad3f0bca17204177db6
train
ApiCollector._get_apis_with_config
Returns the list of APIs in this resource along with other extra configuration such as binary media types, cors etc. Additional configuration is merged directly into the API data because these properties, although defined globally, actually apply to each API. Parameters ---------- ...
samcli/commands/local/lib/sam_api_provider.py
def _get_apis_with_config(self, logical_id): """ Returns the list of APIs in this resource along with other extra configuration such as binary media types, cors etc. Additional configuration is merged directly into the API data because these properties, although defined globally, actuall...
def _get_apis_with_config(self, logical_id): """ Returns the list of APIs in this resource along with other extra configuration such as binary media types, cors etc. Additional configuration is merged directly into the API data because these properties, although defined globally, actuall...
[ "Returns", "the", "list", "of", "APIs", "in", "this", "resource", "along", "with", "other", "extra", "configuration", "such", "as", "binary", "media", "types", "cors", "etc", ".", "Additional", "configuration", "is", "merged", "directly", "into", "the", "API",...
awslabs/aws-sam-cli
python
https://github.com/awslabs/aws-sam-cli/blob/c05af5e7378c6f05f7d82ad3f0bca17204177db6/samcli/commands/local/lib/sam_api_provider.py#L390-L421
[ "def", "_get_apis_with_config", "(", "self", ",", "logical_id", ")", ":", "properties", "=", "self", ".", "_get_properties", "(", "logical_id", ")", "# These configs need to be applied to each API", "binary_media", "=", "sorted", "(", "list", "(", "properties", ".", ...
c05af5e7378c6f05f7d82ad3f0bca17204177db6
train
ApiCollector._get_properties
Returns the properties of resource with given logical ID. If a resource is not found, then it returns an empty data. Parameters ---------- logical_id : str Logical ID of the resource Returns ------- samcli.commands.local.lib.sam_api_provider.ApiColle...
samcli/commands/local/lib/sam_api_provider.py
def _get_properties(self, logical_id): """ Returns the properties of resource with given logical ID. If a resource is not found, then it returns an empty data. Parameters ---------- logical_id : str Logical ID of the resource Returns ------- ...
def _get_properties(self, logical_id): """ Returns the properties of resource with given logical ID. If a resource is not found, then it returns an empty data. Parameters ---------- logical_id : str Logical ID of the resource Returns ------- ...
[ "Returns", "the", "properties", "of", "resource", "with", "given", "logical", "ID", ".", "If", "a", "resource", "is", "not", "found", "then", "it", "returns", "an", "empty", "data", "." ]
awslabs/aws-sam-cli
python
https://github.com/awslabs/aws-sam-cli/blob/c05af5e7378c6f05f7d82ad3f0bca17204177db6/samcli/commands/local/lib/sam_api_provider.py#L423-L445
[ "def", "_get_properties", "(", "self", ",", "logical_id", ")", ":", "if", "logical_id", "not", "in", "self", ".", "by_resource", ":", "self", ".", "by_resource", "[", "logical_id", "]", "=", "self", ".", "Properties", "(", "apis", "=", "[", "]", ",", "...
c05af5e7378c6f05f7d82ad3f0bca17204177db6
train
_unzip_file
Helper method to unzip a file to a temporary directory :param string filepath: Absolute path to this file :return string: Path to the temporary directory where it was unzipped
samcli/local/lambdafn/runtime.py
def _unzip_file(filepath): """ Helper method to unzip a file to a temporary directory :param string filepath: Absolute path to this file :return string: Path to the temporary directory where it was unzipped """ temp_dir = tempfile.mkdtemp() if os.name == 'posix': os.chmod(temp_dir...
def _unzip_file(filepath): """ Helper method to unzip a file to a temporary directory :param string filepath: Absolute path to this file :return string: Path to the temporary directory where it was unzipped """ temp_dir = tempfile.mkdtemp() if os.name == 'posix': os.chmod(temp_dir...
[ "Helper", "method", "to", "unzip", "a", "file", "to", "a", "temporary", "directory" ]
awslabs/aws-sam-cli
python
https://github.com/awslabs/aws-sam-cli/blob/c05af5e7378c6f05f7d82ad3f0bca17204177db6/samcli/local/lambdafn/runtime.py#L184-L205
[ "def", "_unzip_file", "(", "filepath", ")", ":", "temp_dir", "=", "tempfile", ".", "mkdtemp", "(", ")", "if", "os", ".", "name", "==", "'posix'", ":", "os", ".", "chmod", "(", "temp_dir", ",", "0o755", ")", "LOG", ".", "info", "(", "\"Decompressing %s\...
c05af5e7378c6f05f7d82ad3f0bca17204177db6
train
LambdaRuntime.invoke
Invoke the given Lambda function locally. ##### NOTE: THIS IS A LONG BLOCKING CALL ##### This method will block until either the Lambda function completes or timed out, which could be seconds. A blocking call will block the thread preventing any other operations from happening. If you are using...
samcli/local/lambdafn/runtime.py
def invoke(self, function_config, event, debug_context=None, stdout=None, stderr=None): """ Invoke the given Lambda function locally. ##### NOTE: THIS IS A LONG BLOCKING CALL ##### This method will block until ei...
def invoke(self, function_config, event, debug_context=None, stdout=None, stderr=None): """ Invoke the given Lambda function locally. ##### NOTE: THIS IS A LONG BLOCKING CALL ##### This method will block until ei...
[ "Invoke", "the", "given", "Lambda", "function", "locally", "." ]
awslabs/aws-sam-cli
python
https://github.com/awslabs/aws-sam-cli/blob/c05af5e7378c6f05f7d82ad3f0bca17204177db6/samcli/local/lambdafn/runtime.py#L42-L116
[ "def", "invoke", "(", "self", ",", "function_config", ",", "event", ",", "debug_context", "=", "None", ",", "stdout", "=", "None", ",", "stderr", "=", "None", ")", ":", "timer", "=", "None", "# Update with event input", "environ", "=", "function_config", "."...
c05af5e7378c6f05f7d82ad3f0bca17204177db6
train
LambdaRuntime._configure_interrupt
When a Lambda function is executing, we setup certain interrupt handlers to stop the execution. Usually, we setup a function timeout interrupt to kill the container after timeout expires. If debugging though, we don't enforce a timeout. But we setup a SIGINT interrupt to catch Ctrl+C and terminate the c...
samcli/local/lambdafn/runtime.py
def _configure_interrupt(self, function_name, timeout, container, is_debugging): """ When a Lambda function is executing, we setup certain interrupt handlers to stop the execution. Usually, we setup a function timeout interrupt to kill the container after timeout expires. If debugging though, ...
def _configure_interrupt(self, function_name, timeout, container, is_debugging): """ When a Lambda function is executing, we setup certain interrupt handlers to stop the execution. Usually, we setup a function timeout interrupt to kill the container after timeout expires. If debugging though, ...
[ "When", "a", "Lambda", "function", "is", "executing", "we", "setup", "certain", "interrupt", "handlers", "to", "stop", "the", "execution", ".", "Usually", "we", "setup", "a", "function", "timeout", "interrupt", "to", "kill", "the", "container", "after", "timeo...
awslabs/aws-sam-cli
python
https://github.com/awslabs/aws-sam-cli/blob/c05af5e7378c6f05f7d82ad3f0bca17204177db6/samcli/local/lambdafn/runtime.py#L118-L149
[ "def", "_configure_interrupt", "(", "self", ",", "function_name", ",", "timeout", ",", "container", ",", "is_debugging", ")", ":", "def", "timer_handler", "(", ")", ":", "# NOTE: This handler runs in a separate thread. So don't try to mutate any non-thread-safe data structures"...
c05af5e7378c6f05f7d82ad3f0bca17204177db6
train
LambdaRuntime._get_code_dir
Method to get a path to a directory where the Lambda function code is available. This directory will be mounted directly inside the Docker container. This method handles a few different cases for ``code_path``: - ``code_path``is a existent zip/jar file: Unzip in a temp directory and return ...
samcli/local/lambdafn/runtime.py
def _get_code_dir(self, code_path): """ Method to get a path to a directory where the Lambda function code is available. This directory will be mounted directly inside the Docker container. This method handles a few different cases for ``code_path``: - ``code_path``is a exis...
def _get_code_dir(self, code_path): """ Method to get a path to a directory where the Lambda function code is available. This directory will be mounted directly inside the Docker container. This method handles a few different cases for ``code_path``: - ``code_path``is a exis...
[ "Method", "to", "get", "a", "path", "to", "a", "directory", "where", "the", "Lambda", "function", "code", "is", "available", ".", "This", "directory", "will", "be", "mounted", "directly", "inside", "the", "Docker", "container", "." ]
awslabs/aws-sam-cli
python
https://github.com/awslabs/aws-sam-cli/blob/c05af5e7378c6f05f7d82ad3f0bca17204177db6/samcli/local/lambdafn/runtime.py#L152-L181
[ "def", "_get_code_dir", "(", "self", ",", "code_path", ")", ":", "decompressed_dir", "=", "None", "try", ":", "if", "os", ".", "path", ".", "isfile", "(", "code_path", ")", "and", "code_path", ".", "endswith", "(", "self", ".", "SUPPORTED_ARCHIVE_EXTENSIONS"...
c05af5e7378c6f05f7d82ad3f0bca17204177db6
train
LambdaImage.build
Build the image if one is not already on the system that matches the runtime and layers Parameters ---------- runtime str Name of the Lambda runtime layers list(samcli.commands.local.lib.provider.Layer) List of layers Returns ------- str ...
samcli/local/docker/lambda_image.py
def build(self, runtime, layers): """ Build the image if one is not already on the system that matches the runtime and layers Parameters ---------- runtime str Name of the Lambda runtime layers list(samcli.commands.local.lib.provider.Layer) List o...
def build(self, runtime, layers): """ Build the image if one is not already on the system that matches the runtime and layers Parameters ---------- runtime str Name of the Lambda runtime layers list(samcli.commands.local.lib.provider.Layer) List o...
[ "Build", "the", "image", "if", "one", "is", "not", "already", "on", "the", "system", "that", "matches", "the", "runtime", "and", "layers" ]
awslabs/aws-sam-cli
python
https://github.com/awslabs/aws-sam-cli/blob/c05af5e7378c6f05f7d82ad3f0bca17204177db6/samcli/local/docker/lambda_image.py#L73-L115
[ "def", "build", "(", "self", ",", "runtime", ",", "layers", ")", ":", "base_image", "=", "\"{}:{}\"", ".", "format", "(", "self", ".", "_DOCKER_LAMBDA_REPO_NAME", ",", "runtime", ")", "# Don't build the image if there are no layers.", "if", "not", "layers", ":", ...
c05af5e7378c6f05f7d82ad3f0bca17204177db6
train
LambdaImage._generate_docker_image_version
Generate the Docker TAG that will be used to create the image Parameters ---------- layers list(samcli.commands.local.lib.provider.Layer) List of the layers runtime str Runtime of the image to create Returns ------- str Strin...
samcli/local/docker/lambda_image.py
def _generate_docker_image_version(layers, runtime): """ Generate the Docker TAG that will be used to create the image Parameters ---------- layers list(samcli.commands.local.lib.provider.Layer) List of the layers runtime str Runtime of the image...
def _generate_docker_image_version(layers, runtime): """ Generate the Docker TAG that will be used to create the image Parameters ---------- layers list(samcli.commands.local.lib.provider.Layer) List of the layers runtime str Runtime of the image...
[ "Generate", "the", "Docker", "TAG", "that", "will", "be", "used", "to", "create", "the", "image" ]
awslabs/aws-sam-cli
python
https://github.com/awslabs/aws-sam-cli/blob/c05af5e7378c6f05f7d82ad3f0bca17204177db6/samcli/local/docker/lambda_image.py#L118-L142
[ "def", "_generate_docker_image_version", "(", "layers", ",", "runtime", ")", ":", "# Docker has a concept of a TAG on an image. This is plus the REPOSITORY is a way to determine", "# a version of the image. We will produced a TAG for a combination of the runtime with the layers", "# specified in...
c05af5e7378c6f05f7d82ad3f0bca17204177db6
train
LambdaImage._build_image
Builds the image Parameters ---------- base_image str Base Image to use for the new image docker_tag Docker tag (REPOSITORY:TAG) to use when building the image layers list(samcli.commands.local.lib.provider.Layer) List of Layers to be use to m...
samcli/local/docker/lambda_image.py
def _build_image(self, base_image, docker_tag, layers): """ Builds the image Parameters ---------- base_image str Base Image to use for the new image docker_tag Docker tag (REPOSITORY:TAG) to use when building the image layers list(samcli....
def _build_image(self, base_image, docker_tag, layers): """ Builds the image Parameters ---------- base_image str Base Image to use for the new image docker_tag Docker tag (REPOSITORY:TAG) to use when building the image layers list(samcli....
[ "Builds", "the", "image" ]
awslabs/aws-sam-cli
python
https://github.com/awslabs/aws-sam-cli/blob/c05af5e7378c6f05f7d82ad3f0bca17204177db6/samcli/local/docker/lambda_image.py#L144-L192
[ "def", "_build_image", "(", "self", ",", "base_image", ",", "docker_tag", ",", "layers", ")", ":", "dockerfile_content", "=", "self", ".", "_generate_dockerfile", "(", "base_image", ",", "layers", ")", "# Create dockerfile in the same directory of the layer cache", "doc...
c05af5e7378c6f05f7d82ad3f0bca17204177db6
train
LambdaImage._generate_dockerfile
Generate the Dockerfile contents A generated Dockerfile will look like the following: ``` FROM lambci/lambda:python3.6 ADD --chown=sbx_user1051:495 layer1 /opt ADD --chown=sbx_user1051:495 layer2 /opt ``` Parameters ---------- base_image str ...
samcli/local/docker/lambda_image.py
def _generate_dockerfile(base_image, layers): """ Generate the Dockerfile contents A generated Dockerfile will look like the following: ``` FROM lambci/lambda:python3.6 ADD --chown=sbx_user1051:495 layer1 /opt ADD --chown=sbx_user1051:495 layer2 /opt ```...
def _generate_dockerfile(base_image, layers): """ Generate the Dockerfile contents A generated Dockerfile will look like the following: ``` FROM lambci/lambda:python3.6 ADD --chown=sbx_user1051:495 layer1 /opt ADD --chown=sbx_user1051:495 layer2 /opt ```...
[ "Generate", "the", "Dockerfile", "contents" ]
awslabs/aws-sam-cli
python
https://github.com/awslabs/aws-sam-cli/blob/c05af5e7378c6f05f7d82ad3f0bca17204177db6/samcli/local/docker/lambda_image.py#L195-L225
[ "def", "_generate_dockerfile", "(", "base_image", ",", "layers", ")", ":", "dockerfile_content", "=", "\"FROM {}\\n\"", ".", "format", "(", "base_image", ")", "for", "layer", "in", "layers", ":", "dockerfile_content", "=", "dockerfile_content", "+", "\"ADD --chown=s...
c05af5e7378c6f05f7d82ad3f0bca17204177db6
train
LocalApiService.start
Creates and starts the local API Gateway service. This method will block until the service is stopped manually using an interrupt. After the service is started, callers can make HTTP requests to the endpoint to invoke the Lambda function and receive a response. NOTE: This is a blocking call tha...
samcli/commands/local/lib/local_api_service.py
def start(self): """ Creates and starts the local API Gateway service. This method will block until the service is stopped manually using an interrupt. After the service is started, callers can make HTTP requests to the endpoint to invoke the Lambda function and receive a response. ...
def start(self): """ Creates and starts the local API Gateway service. This method will block until the service is stopped manually using an interrupt. After the service is started, callers can make HTTP requests to the endpoint to invoke the Lambda function and receive a response. ...
[ "Creates", "and", "starts", "the", "local", "API", "Gateway", "service", ".", "This", "method", "will", "block", "until", "the", "service", "is", "stopped", "manually", "using", "an", "interrupt", ".", "After", "the", "service", "is", "started", "callers", "...
awslabs/aws-sam-cli
python
https://github.com/awslabs/aws-sam-cli/blob/c05af5e7378c6f05f7d82ad3f0bca17204177db6/samcli/commands/local/lib/local_api_service.py#L47-L83
[ "def", "start", "(", "self", ")", ":", "routing_list", "=", "self", ".", "_make_routing_list", "(", "self", ".", "api_provider", ")", "if", "not", "routing_list", ":", "raise", "NoApisDefined", "(", "\"No APIs available in SAM template\"", ")", "static_dir_path", ...
c05af5e7378c6f05f7d82ad3f0bca17204177db6
train
LocalApiService._make_routing_list
Returns a list of routes to configure the Local API Service based on the APIs configured in the template. Parameters ---------- api_provider : samcli.commands.local.lib.sam_api_provider.SamApiProvider Returns ------- list(samcli.local.apigw.service.Route) Li...
samcli/commands/local/lib/local_api_service.py
def _make_routing_list(api_provider): """ Returns a list of routes to configure the Local API Service based on the APIs configured in the template. Parameters ---------- api_provider : samcli.commands.local.lib.sam_api_provider.SamApiProvider Returns ------- ...
def _make_routing_list(api_provider): """ Returns a list of routes to configure the Local API Service based on the APIs configured in the template. Parameters ---------- api_provider : samcli.commands.local.lib.sam_api_provider.SamApiProvider Returns ------- ...
[ "Returns", "a", "list", "of", "routes", "to", "configure", "the", "Local", "API", "Service", "based", "on", "the", "APIs", "configured", "in", "the", "template", "." ]
awslabs/aws-sam-cli
python
https://github.com/awslabs/aws-sam-cli/blob/c05af5e7378c6f05f7d82ad3f0bca17204177db6/samcli/commands/local/lib/local_api_service.py#L86-L106
[ "def", "_make_routing_list", "(", "api_provider", ")", ":", "routes", "=", "[", "]", "for", "api", "in", "api_provider", ".", "get_all", "(", ")", ":", "route", "=", "Route", "(", "methods", "=", "[", "api", ".", "method", "]", ",", "function_name", "=...
c05af5e7378c6f05f7d82ad3f0bca17204177db6
train
LocalApiService._print_routes
Helper method to print the APIs that will be mounted. This method is purely for printing purposes. This method takes in a list of Route Configurations and prints out the Routes grouped by path. Grouping routes by Function Name + Path is the bulk of the logic. Example output: Mountin...
samcli/commands/local/lib/local_api_service.py
def _print_routes(api_provider, host, port): """ Helper method to print the APIs that will be mounted. This method is purely for printing purposes. This method takes in a list of Route Configurations and prints out the Routes grouped by path. Grouping routes by Function Name + Path is th...
def _print_routes(api_provider, host, port): """ Helper method to print the APIs that will be mounted. This method is purely for printing purposes. This method takes in a list of Route Configurations and prints out the Routes grouped by path. Grouping routes by Function Name + Path is th...
[ "Helper", "method", "to", "print", "the", "APIs", "that", "will", "be", "mounted", ".", "This", "method", "is", "purely", "for", "printing", "purposes", ".", "This", "method", "takes", "in", "a", "list", "of", "Route", "Configurations", "and", "prints", "o...
awslabs/aws-sam-cli
python
https://github.com/awslabs/aws-sam-cli/blob/c05af5e7378c6f05f7d82ad3f0bca17204177db6/samcli/commands/local/lib/local_api_service.py#L109-L151
[ "def", "_print_routes", "(", "api_provider", ",", "host", ",", "port", ")", ":", "grouped_api_configs", "=", "{", "}", "for", "api", "in", "api_provider", ".", "get_all", "(", ")", ":", "key", "=", "\"{}-{}\"", ".", "format", "(", "api", ".", "function_n...
c05af5e7378c6f05f7d82ad3f0bca17204177db6
train
LocalApiService._make_static_dir_path
This method returns the path to the directory where static files are to be served from. If static_dir is a relative path, then it is resolved to be relative to the current working directory. If no static directory is provided, or if the resolved directory does not exist, this method will return None ...
samcli/commands/local/lib/local_api_service.py
def _make_static_dir_path(cwd, static_dir): """ This method returns the path to the directory where static files are to be served from. If static_dir is a relative path, then it is resolved to be relative to the current working directory. If no static directory is provided, or if the res...
def _make_static_dir_path(cwd, static_dir): """ This method returns the path to the directory where static files are to be served from. If static_dir is a relative path, then it is resolved to be relative to the current working directory. If no static directory is provided, or if the res...
[ "This", "method", "returns", "the", "path", "to", "the", "directory", "where", "static", "files", "are", "to", "be", "served", "from", ".", "If", "static_dir", "is", "a", "relative", "path", "then", "it", "is", "resolved", "to", "be", "relative", "to", "...
awslabs/aws-sam-cli
python
https://github.com/awslabs/aws-sam-cli/blob/c05af5e7378c6f05f7d82ad3f0bca17204177db6/samcli/commands/local/lib/local_api_service.py#L154-L170
[ "def", "_make_static_dir_path", "(", "cwd", ",", "static_dir", ")", ":", "if", "not", "static_dir", ":", "return", "None", "static_dir_path", "=", "os", ".", "path", ".", "join", "(", "cwd", ",", "static_dir", ")", "if", "os", ".", "path", ".", "exists",...
c05af5e7378c6f05f7d82ad3f0bca17204177db6
train
LocalLambdaInvokeService.create
Creates a Flask Application that can be started.
samcli/local/lambda_service/local_lambda_invoke_service.py
def create(self): """ Creates a Flask Application that can be started. """ self._app = Flask(__name__) path = '/2015-03-31/functions/<function_name>/invocations' self._app.add_url_rule(path, endpoint=path, vie...
def create(self): """ Creates a Flask Application that can be started. """ self._app = Flask(__name__) path = '/2015-03-31/functions/<function_name>/invocations' self._app.add_url_rule(path, endpoint=path, vie...
[ "Creates", "a", "Flask", "Application", "that", "can", "be", "started", "." ]
awslabs/aws-sam-cli
python
https://github.com/awslabs/aws-sam-cli/blob/c05af5e7378c6f05f7d82ad3f0bca17204177db6/samcli/local/lambda_service/local_lambda_invoke_service.py#L38-L54
[ "def", "create", "(", "self", ")", ":", "self", ".", "_app", "=", "Flask", "(", "__name__", ")", "path", "=", "'/2015-03-31/functions/<function_name>/invocations'", "self", ".", "_app", ".", "add_url_rule", "(", "path", ",", "endpoint", "=", "path", ",", "vi...
c05af5e7378c6f05f7d82ad3f0bca17204177db6
train
LocalLambdaInvokeService.validate_request
Validates the incoming request The following are invalid 1. The Request data is not json serializable 2. Query Parameters are sent to the endpoint 3. The Request Content-Type is not application/json 4. 'X-Amz-Log-Type' header is not 'None' 5. 'X-Amz-I...
samcli/local/lambda_service/local_lambda_invoke_service.py
def validate_request(): """ Validates the incoming request The following are invalid 1. The Request data is not json serializable 2. Query Parameters are sent to the endpoint 3. The Request Content-Type is not application/json 4. 'X-Amz-Log-Type' ...
def validate_request(): """ Validates the incoming request The following are invalid 1. The Request data is not json serializable 2. Query Parameters are sent to the endpoint 3. The Request Content-Type is not application/json 4. 'X-Amz-Log-Type' ...
[ "Validates", "the", "incoming", "request" ]
awslabs/aws-sam-cli
python
https://github.com/awslabs/aws-sam-cli/blob/c05af5e7378c6f05f7d82ad3f0bca17204177db6/samcli/local/lambda_service/local_lambda_invoke_service.py#L57-L107
[ "def", "validate_request", "(", ")", ":", "flask_request", "=", "request", "request_data", "=", "flask_request", ".", "get_data", "(", ")", "if", "not", "request_data", ":", "request_data", "=", "b'{}'", "request_data", "=", "request_data", ".", "decode", "(", ...
c05af5e7378c6f05f7d82ad3f0bca17204177db6
train
LocalLambdaInvokeService._construct_error_handling
Updates the Flask app with Error Handlers for different Error Codes
samcli/local/lambda_service/local_lambda_invoke_service.py
def _construct_error_handling(self): """ Updates the Flask app with Error Handlers for different Error Codes """ self._app.register_error_handler(500, LambdaErrorResponses.generic_service_exception) self._app.register_error_handler(404, LambdaErrorResponses.generic_path_not_foun...
def _construct_error_handling(self): """ Updates the Flask app with Error Handlers for different Error Codes """ self._app.register_error_handler(500, LambdaErrorResponses.generic_service_exception) self._app.register_error_handler(404, LambdaErrorResponses.generic_path_not_foun...
[ "Updates", "the", "Flask", "app", "with", "Error", "Handlers", "for", "different", "Error", "Codes" ]
awslabs/aws-sam-cli
python
https://github.com/awslabs/aws-sam-cli/blob/c05af5e7378c6f05f7d82ad3f0bca17204177db6/samcli/local/lambda_service/local_lambda_invoke_service.py#L109-L116
[ "def", "_construct_error_handling", "(", "self", ")", ":", "self", ".", "_app", ".", "register_error_handler", "(", "500", ",", "LambdaErrorResponses", ".", "generic_service_exception", ")", "self", ".", "_app", ".", "register_error_handler", "(", "404", ",", "Lam...
c05af5e7378c6f05f7d82ad3f0bca17204177db6
train
LocalLambdaInvokeService._invoke_request_handler
Request Handler for the Local Lambda Invoke path. This method is responsible for understanding the incoming request and invoking the Local Lambda Function Parameters ---------- function_name str Name of the function to invoke Returns ------- A Flask ...
samcli/local/lambda_service/local_lambda_invoke_service.py
def _invoke_request_handler(self, function_name): """ Request Handler for the Local Lambda Invoke path. This method is responsible for understanding the incoming request and invoking the Local Lambda Function Parameters ---------- function_name str Name of th...
def _invoke_request_handler(self, function_name): """ Request Handler for the Local Lambda Invoke path. This method is responsible for understanding the incoming request and invoking the Local Lambda Function Parameters ---------- function_name str Name of th...
[ "Request", "Handler", "for", "the", "Local", "Lambda", "Invoke", "path", ".", "This", "method", "is", "responsible", "for", "understanding", "the", "incoming", "request", "and", "invoking", "the", "Local", "Lambda", "Function" ]
awslabs/aws-sam-cli
python
https://github.com/awslabs/aws-sam-cli/blob/c05af5e7378c6f05f7d82ad3f0bca17204177db6/samcli/local/lambda_service/local_lambda_invoke_service.py#L118-L162
[ "def", "_invoke_request_handler", "(", "self", ",", "function_name", ")", ":", "flask_request", "=", "request", "request_data", "=", "flask_request", ".", "get_data", "(", ")", "if", "not", "request_data", ":", "request_data", "=", "b'{}'", "request_data", "=", ...
c05af5e7378c6f05f7d82ad3f0bca17204177db6
train
unzip
Unzip the given file into the given directory while preserving file permissions in the process. Parameters ---------- zip_file_path : str Path to the zip file output_dir : str Path to the directory where the it should be unzipped to permission : octal int Permission to set
samcli/local/lambdafn/zip.py
def unzip(zip_file_path, output_dir, permission=None): """ Unzip the given file into the given directory while preserving file permissions in the process. Parameters ---------- zip_file_path : str Path to the zip file output_dir : str Path to the directory where the it should b...
def unzip(zip_file_path, output_dir, permission=None): """ Unzip the given file into the given directory while preserving file permissions in the process. Parameters ---------- zip_file_path : str Path to the zip file output_dir : str Path to the directory where the it should b...
[ "Unzip", "the", "given", "file", "into", "the", "given", "directory", "while", "preserving", "file", "permissions", "in", "the", "process", "." ]
awslabs/aws-sam-cli
python
https://github.com/awslabs/aws-sam-cli/blob/c05af5e7378c6f05f7d82ad3f0bca17204177db6/samcli/local/lambdafn/zip.py#L23-L51
[ "def", "unzip", "(", "zip_file_path", ",", "output_dir", ",", "permission", "=", "None", ")", ":", "with", "zipfile", ".", "ZipFile", "(", "zip_file_path", ",", "'r'", ")", "as", "zip_ref", ":", "# For each item in the zip file, extract the file and set permissions if...
c05af5e7378c6f05f7d82ad3f0bca17204177db6
train
_set_permissions
Sets permissions on the extracted file by reading the ``external_attr`` property of given file info. Parameters ---------- zip_file_info : zipfile.ZipInfo Object containing information about a file within a zip archive extracted_path : str Path where the file has been extracted to
samcli/local/lambdafn/zip.py
def _set_permissions(zip_file_info, extracted_path): """ Sets permissions on the extracted file by reading the ``external_attr`` property of given file info. Parameters ---------- zip_file_info : zipfile.ZipInfo Object containing information about a file within a zip archive extracted_...
def _set_permissions(zip_file_info, extracted_path): """ Sets permissions on the extracted file by reading the ``external_attr`` property of given file info. Parameters ---------- zip_file_info : zipfile.ZipInfo Object containing information about a file within a zip archive extracted_...
[ "Sets", "permissions", "on", "the", "extracted", "file", "by", "reading", "the", "external_attr", "property", "of", "given", "file", "info", "." ]
awslabs/aws-sam-cli
python
https://github.com/awslabs/aws-sam-cli/blob/c05af5e7378c6f05f7d82ad3f0bca17204177db6/samcli/local/lambdafn/zip.py#L70-L91
[ "def", "_set_permissions", "(", "zip_file_info", ",", "extracted_path", ")", ":", "# Permission information is stored in first two bytes.", "permission", "=", "zip_file_info", ".", "external_attr", ">>", "16", "if", "not", "permission", ":", "# Zips created on certain Windows...
c05af5e7378c6f05f7d82ad3f0bca17204177db6
train
unzip_from_uri
Download the LayerVersion Zip to the Layer Pkg Cache Parameters ---------- uri str Uri to download from layer_zip_path str Path to where the content from the uri should be downloaded to unzip_output_dir str Path to unzip the zip to progressbar_label str Label to ...
samcli/local/lambdafn/zip.py
def unzip_from_uri(uri, layer_zip_path, unzip_output_dir, progressbar_label): """ Download the LayerVersion Zip to the Layer Pkg Cache Parameters ---------- uri str Uri to download from layer_zip_path str Path to where the content from the uri should be downloaded to unzip_o...
def unzip_from_uri(uri, layer_zip_path, unzip_output_dir, progressbar_label): """ Download the LayerVersion Zip to the Layer Pkg Cache Parameters ---------- uri str Uri to download from layer_zip_path str Path to where the content from the uri should be downloaded to unzip_o...
[ "Download", "the", "LayerVersion", "Zip", "to", "the", "Layer", "Pkg", "Cache" ]
awslabs/aws-sam-cli
python
https://github.com/awslabs/aws-sam-cli/blob/c05af5e7378c6f05f7d82ad3f0bca17204177db6/samcli/local/lambdafn/zip.py#L94-L130
[ "def", "unzip_from_uri", "(", "uri", ",", "layer_zip_path", ",", "unzip_output_dir", ",", "progressbar_label", ")", ":", "try", ":", "get_request", "=", "requests", ".", "get", "(", "uri", ",", "stream", "=", "True", ",", "verify", "=", "os", ".", "environ...
c05af5e7378c6f05f7d82ad3f0bca17204177db6
train
LocalApigwService.create
Creates a Flask Application that can be started.
samcli/local/apigw/local_apigw_service.py
def create(self): """ Creates a Flask Application that can be started. """ self._app = Flask(__name__, static_url_path="", # Mount static files at root '/' static_folder=self.static_dir # Serve static files from this directory ...
def create(self): """ Creates a Flask Application that can be started. """ self._app = Flask(__name__, static_url_path="", # Mount static files at root '/' static_folder=self.static_dir # Serve static files from this directory ...
[ "Creates", "a", "Flask", "Application", "that", "can", "be", "started", "." ]
awslabs/aws-sam-cli
python
https://github.com/awslabs/aws-sam-cli/blob/c05af5e7378c6f05f7d82ad3f0bca17204177db6/samcli/local/apigw/local_apigw_service.py#L68-L90
[ "def", "create", "(", "self", ")", ":", "self", ".", "_app", "=", "Flask", "(", "__name__", ",", "static_url_path", "=", "\"\"", ",", "# Mount static files at root '/'", "static_folder", "=", "self", ".", "static_dir", "# Serve static files from this directory", ")"...
c05af5e7378c6f05f7d82ad3f0bca17204177db6
train
LocalApigwService._generate_route_keys
Generates the key to the _dict_of_routes based on the list of methods and path supplied :param list(str) methods: List of HTTP Methods :param str path: Path off the base url :return: str of Path:Method
samcli/local/apigw/local_apigw_service.py
def _generate_route_keys(self, methods, path): """ Generates the key to the _dict_of_routes based on the list of methods and path supplied :param list(str) methods: List of HTTP Methods :param str path: Path off the base url :return: str of Path:Method """ ...
def _generate_route_keys(self, methods, path): """ Generates the key to the _dict_of_routes based on the list of methods and path supplied :param list(str) methods: List of HTTP Methods :param str path: Path off the base url :return: str of Path:Method """ ...
[ "Generates", "the", "key", "to", "the", "_dict_of_routes", "based", "on", "the", "list", "of", "methods", "and", "path", "supplied" ]
awslabs/aws-sam-cli
python
https://github.com/awslabs/aws-sam-cli/blob/c05af5e7378c6f05f7d82ad3f0bca17204177db6/samcli/local/apigw/local_apigw_service.py#L92-L102
[ "def", "_generate_route_keys", "(", "self", ",", "methods", ",", "path", ")", ":", "for", "method", "in", "methods", ":", "yield", "self", ".", "_route_key", "(", "method", ",", "path", ")" ]
c05af5e7378c6f05f7d82ad3f0bca17204177db6
train
LocalApigwService._construct_error_handling
Updates the Flask app with Error Handlers for different Error Codes
samcli/local/apigw/local_apigw_service.py
def _construct_error_handling(self): """ Updates the Flask app with Error Handlers for different Error Codes """ # Both path and method not present self._app.register_error_handler(404, ServiceErrorResponses.route_not_found) # Path is present, but method not allowed ...
def _construct_error_handling(self): """ Updates the Flask app with Error Handlers for different Error Codes """ # Both path and method not present self._app.register_error_handler(404, ServiceErrorResponses.route_not_found) # Path is present, but method not allowed ...
[ "Updates", "the", "Flask", "app", "with", "Error", "Handlers", "for", "different", "Error", "Codes" ]
awslabs/aws-sam-cli
python
https://github.com/awslabs/aws-sam-cli/blob/c05af5e7378c6f05f7d82ad3f0bca17204177db6/samcli/local/apigw/local_apigw_service.py#L108-L117
[ "def", "_construct_error_handling", "(", "self", ")", ":", "# Both path and method not present", "self", ".", "_app", ".", "register_error_handler", "(", "404", ",", "ServiceErrorResponses", ".", "route_not_found", ")", "# Path is present, but method not allowed", "self", "...
c05af5e7378c6f05f7d82ad3f0bca17204177db6
train
LocalApigwService._request_handler
We handle all requests to the host:port. The general flow of handling a request is as follows * Fetch request from the Flask Global state. This is where Flask places the request and is per thread so multiple requests are still handled correctly * Find the Lambda function to invoke by doing a ...
samcli/local/apigw/local_apigw_service.py
def _request_handler(self, **kwargs): """ We handle all requests to the host:port. The general flow of handling a request is as follows * Fetch request from the Flask Global state. This is where Flask places the request and is per thread so multiple requests are still handled correctl...
def _request_handler(self, **kwargs): """ We handle all requests to the host:port. The general flow of handling a request is as follows * Fetch request from the Flask Global state. This is where Flask places the request and is per thread so multiple requests are still handled correctl...
[ "We", "handle", "all", "requests", "to", "the", "host", ":", "port", ".", "The", "general", "flow", "of", "handling", "a", "request", "is", "as", "follows" ]
awslabs/aws-sam-cli
python
https://github.com/awslabs/aws-sam-cli/blob/c05af5e7378c6f05f7d82ad3f0bca17204177db6/samcli/local/apigw/local_apigw_service.py#L119-L172
[ "def", "_request_handler", "(", "self", ",", "*", "*", "kwargs", ")", ":", "route", "=", "self", ".", "_get_current_route", "(", "request", ")", "try", ":", "event", "=", "self", ".", "_construct_event", "(", "request", ",", "self", ".", "port", ",", "...
c05af5e7378c6f05f7d82ad3f0bca17204177db6
train
LocalApigwService._get_current_route
Get the route (Route) based on the current request :param request flask_request: Flask Request :return: Route matching the endpoint and method of the request
samcli/local/apigw/local_apigw_service.py
def _get_current_route(self, flask_request): """ Get the route (Route) based on the current request :param request flask_request: Flask Request :return: Route matching the endpoint and method of the request """ endpoint = flask_request.endpoint method = flask_req...
def _get_current_route(self, flask_request): """ Get the route (Route) based on the current request :param request flask_request: Flask Request :return: Route matching the endpoint and method of the request """ endpoint = flask_request.endpoint method = flask_req...
[ "Get", "the", "route", "(", "Route", ")", "based", "on", "the", "current", "request" ]
awslabs/aws-sam-cli
python
https://github.com/awslabs/aws-sam-cli/blob/c05af5e7378c6f05f7d82ad3f0bca17204177db6/samcli/local/apigw/local_apigw_service.py#L174-L193
[ "def", "_get_current_route", "(", "self", ",", "flask_request", ")", ":", "endpoint", "=", "flask_request", ".", "endpoint", "method", "=", "flask_request", ".", "method", "route_key", "=", "self", ".", "_route_key", "(", "method", ",", "endpoint", ")", "route...
c05af5e7378c6f05f7d82ad3f0bca17204177db6
train
LocalApigwService._parse_lambda_output
Parses the output from the Lambda Container :param str lambda_output: Output from Lambda Invoke :return: Tuple(int, dict, str, bool)
samcli/local/apigw/local_apigw_service.py
def _parse_lambda_output(lambda_output, binary_types, flask_request): """ Parses the output from the Lambda Container :param str lambda_output: Output from Lambda Invoke :return: Tuple(int, dict, str, bool) """ json_output = json.loads(lambda_output) if not isin...
def _parse_lambda_output(lambda_output, binary_types, flask_request): """ Parses the output from the Lambda Container :param str lambda_output: Output from Lambda Invoke :return: Tuple(int, dict, str, bool) """ json_output = json.loads(lambda_output) if not isin...
[ "Parses", "the", "output", "from", "the", "Lambda", "Container" ]
awslabs/aws-sam-cli
python
https://github.com/awslabs/aws-sam-cli/blob/c05af5e7378c6f05f7d82ad3f0bca17204177db6/samcli/local/apigw/local_apigw_service.py#L197-L231
[ "def", "_parse_lambda_output", "(", "lambda_output", ",", "binary_types", ",", "flask_request", ")", ":", "json_output", "=", "json", ".", "loads", "(", "lambda_output", ")", "if", "not", "isinstance", "(", "json_output", ",", "dict", ")", ":", "raise", "TypeE...
c05af5e7378c6f05f7d82ad3f0bca17204177db6
train
LocalApigwService._should_base64_decode_body
Whether or not the body should be decoded from Base64 to Binary Parameters ---------- binary_types list(basestring) Corresponds to self.binary_types (aka. what is parsed from SAM Template flask_request flask.request Flask request lamba_response_headers di...
samcli/local/apigw/local_apigw_service.py
def _should_base64_decode_body(binary_types, flask_request, lamba_response_headers, is_base_64_encoded): """ Whether or not the body should be decoded from Base64 to Binary Parameters ---------- binary_types list(basestring) Corresponds to self.binary_types (aka. wha...
def _should_base64_decode_body(binary_types, flask_request, lamba_response_headers, is_base_64_encoded): """ Whether or not the body should be decoded from Base64 to Binary Parameters ---------- binary_types list(basestring) Corresponds to self.binary_types (aka. wha...
[ "Whether", "or", "not", "the", "body", "should", "be", "decoded", "from", "Base64", "to", "Binary" ]
awslabs/aws-sam-cli
python
https://github.com/awslabs/aws-sam-cli/blob/c05af5e7378c6f05f7d82ad3f0bca17204177db6/samcli/local/apigw/local_apigw_service.py#L234-L257
[ "def", "_should_base64_decode_body", "(", "binary_types", ",", "flask_request", ",", "lamba_response_headers", ",", "is_base_64_encoded", ")", ":", "best_match_mimetype", "=", "flask_request", ".", "accept_mimetypes", ".", "best_match", "(", "[", "lamba_response_headers", ...
c05af5e7378c6f05f7d82ad3f0bca17204177db6
train
LocalApigwService._construct_event
Helper method that constructs the Event to be passed to Lambda :param request flask_request: Flask Request :return: String representing the event
samcli/local/apigw/local_apigw_service.py
def _construct_event(flask_request, port, binary_types): """ Helper method that constructs the Event to be passed to Lambda :param request flask_request: Flask Request :return: String representing the event """ identity = ContextIdentity(source_ip=flask_request.remote_a...
def _construct_event(flask_request, port, binary_types): """ Helper method that constructs the Event to be passed to Lambda :param request flask_request: Flask Request :return: String representing the event """ identity = ContextIdentity(source_ip=flask_request.remote_a...
[ "Helper", "method", "that", "constructs", "the", "Event", "to", "be", "passed", "to", "Lambda" ]
awslabs/aws-sam-cli
python
https://github.com/awslabs/aws-sam-cli/blob/c05af5e7378c6f05f7d82ad3f0bca17204177db6/samcli/local/apigw/local_apigw_service.py#L260-L314
[ "def", "_construct_event", "(", "flask_request", ",", "port", ",", "binary_types", ")", ":", "identity", "=", "ContextIdentity", "(", "source_ip", "=", "flask_request", ".", "remote_addr", ")", "endpoint", "=", "PathConverter", ".", "convert_path_to_api_gateway", "(...
c05af5e7378c6f05f7d82ad3f0bca17204177db6
train
LocalApigwService._query_string_params
Constructs an APIGW equivalent query string dictionary Parameters ---------- flask_request request Request from Flask Returns dict (str: str) ------- Empty dict if no query params where in the request otherwise returns a dictionary of key to value
samcli/local/apigw/local_apigw_service.py
def _query_string_params(flask_request): """ Constructs an APIGW equivalent query string dictionary Parameters ---------- flask_request request Request from Flask Returns dict (str: str) ------- Empty dict if no query params where in the ...
def _query_string_params(flask_request): """ Constructs an APIGW equivalent query string dictionary Parameters ---------- flask_request request Request from Flask Returns dict (str: str) ------- Empty dict if no query params where in the ...
[ "Constructs", "an", "APIGW", "equivalent", "query", "string", "dictionary" ]
awslabs/aws-sam-cli
python
https://github.com/awslabs/aws-sam-cli/blob/c05af5e7378c6f05f7d82ad3f0bca17204177db6/samcli/local/apigw/local_apigw_service.py#L317-L345
[ "def", "_query_string_params", "(", "flask_request", ")", ":", "query_string_dict", "=", "{", "}", "# Flask returns an ImmutableMultiDict so convert to a dictionary that becomes", "# a dict(str: list) then iterate over", "for", "query_string_key", ",", "query_string_list", "in", "f...
c05af5e7378c6f05f7d82ad3f0bca17204177db6
train
LocalLambdaRunner.invoke
Find the Lambda function with given name and invoke it. Pass the given event to the function and return response through the given streams. This function will block until either the function completes or times out. Parameters ---------- function_name str Name of the...
samcli/commands/local/lib/local_lambda.py
def invoke(self, function_name, event, stdout=None, stderr=None): """ Find the Lambda function with given name and invoke it. Pass the given event to the function and return response through the given streams. This function will block until either the function completes or times out. ...
def invoke(self, function_name, event, stdout=None, stderr=None): """ Find the Lambda function with given name and invoke it. Pass the given event to the function and return response through the given streams. This function will block until either the function completes or times out. ...
[ "Find", "the", "Lambda", "function", "with", "given", "name", "and", "invoke", "it", ".", "Pass", "the", "given", "event", "to", "the", "function", "and", "return", "response", "through", "the", "given", "streams", "." ]
awslabs/aws-sam-cli
python
https://github.com/awslabs/aws-sam-cli/blob/c05af5e7378c6f05f7d82ad3f0bca17204177db6/samcli/commands/local/lib/local_lambda.py#L49-L89
[ "def", "invoke", "(", "self", ",", "function_name", ",", "event", ",", "stdout", "=", "None", ",", "stderr", "=", "None", ")", ":", "# Generate the correct configuration based on given inputs", "function", "=", "self", ".", "provider", ".", "get", "(", "function...
c05af5e7378c6f05f7d82ad3f0bca17204177db6
train
LocalLambdaRunner._get_invoke_config
Returns invoke configuration to pass to Lambda Runtime to invoke the given function :param samcli.commands.local.lib.provider.Function function: Lambda function to generate the configuration for :return samcli.local.lambdafn.config.FunctionConfig: Function configuration to pass to Lambda runtime
samcli/commands/local/lib/local_lambda.py
def _get_invoke_config(self, function): """ Returns invoke configuration to pass to Lambda Runtime to invoke the given function :param samcli.commands.local.lib.provider.Function function: Lambda function to generate the configuration for :return samcli.local.lambdafn.config.FunctionCon...
def _get_invoke_config(self, function): """ Returns invoke configuration to pass to Lambda Runtime to invoke the given function :param samcli.commands.local.lib.provider.Function function: Lambda function to generate the configuration for :return samcli.local.lambdafn.config.FunctionCon...
[ "Returns", "invoke", "configuration", "to", "pass", "to", "Lambda", "Runtime", "to", "invoke", "the", "given", "function" ]
awslabs/aws-sam-cli
python
https://github.com/awslabs/aws-sam-cli/blob/c05af5e7378c6f05f7d82ad3f0bca17204177db6/samcli/commands/local/lib/local_lambda.py#L103-L131
[ "def", "_get_invoke_config", "(", "self", ",", "function", ")", ":", "env_vars", "=", "self", ".", "_make_env_vars", "(", "function", ")", "code_abs_path", "=", "resolve_code_path", "(", "self", ".", "cwd", ",", "function", ".", "codeuri", ")", "LOG", ".", ...
c05af5e7378c6f05f7d82ad3f0bca17204177db6
train
LocalLambdaRunner._make_env_vars
Returns the environment variables configuration for this function Parameters ---------- function : samcli.commands.local.lib.provider.Function Lambda function to generate the configuration for Returns ------- samcli.local.lambdafn.env_vars.EnvironmentVariabl...
samcli/commands/local/lib/local_lambda.py
def _make_env_vars(self, function): """Returns the environment variables configuration for this function Parameters ---------- function : samcli.commands.local.lib.provider.Function Lambda function to generate the configuration for Returns ------- sa...
def _make_env_vars(self, function): """Returns the environment variables configuration for this function Parameters ---------- function : samcli.commands.local.lib.provider.Function Lambda function to generate the configuration for Returns ------- sa...
[ "Returns", "the", "environment", "variables", "configuration", "for", "this", "function" ]
awslabs/aws-sam-cli
python
https://github.com/awslabs/aws-sam-cli/blob/c05af5e7378c6f05f7d82ad3f0bca17204177db6/samcli/commands/local/lib/local_lambda.py#L133-L193
[ "def", "_make_env_vars", "(", "self", ",", "function", ")", ":", "name", "=", "function", ".", "name", "variables", "=", "None", "if", "function", ".", "environment", "and", "isinstance", "(", "function", ".", "environment", ",", "dict", ")", "and", "\"Var...
c05af5e7378c6f05f7d82ad3f0bca17204177db6
train
LocalLambdaRunner.get_aws_creds
Returns AWS credentials obtained from the shell environment or given profile :return dict: A dictionary containing credentials. This dict has the structure {"region": "", "key": "", "secret": "", "sessiontoken": ""}. If credentials could not be resolved, this returns None
samcli/commands/local/lib/local_lambda.py
def get_aws_creds(self): """ Returns AWS credentials obtained from the shell environment or given profile :return dict: A dictionary containing credentials. This dict has the structure {"region": "", "key": "", "secret": "", "sessiontoken": ""}. If credentials could not be resolved...
def get_aws_creds(self): """ Returns AWS credentials obtained from the shell environment or given profile :return dict: A dictionary containing credentials. This dict has the structure {"region": "", "key": "", "secret": "", "sessiontoken": ""}. If credentials could not be resolved...
[ "Returns", "AWS", "credentials", "obtained", "from", "the", "shell", "environment", "or", "given", "profile" ]
awslabs/aws-sam-cli
python
https://github.com/awslabs/aws-sam-cli/blob/c05af5e7378c6f05f7d82ad3f0bca17204177db6/samcli/commands/local/lib/local_lambda.py#L195-L238
[ "def", "get_aws_creds", "(", "self", ")", ":", "result", "=", "{", "}", "# to pass command line arguments for region & profile to setup boto3 default session", "if", "boto3", ".", "DEFAULT_SESSION", ":", "session", "=", "boto3", ".", "DEFAULT_SESSION", "else", ":", "ses...
c05af5e7378c6f05f7d82ad3f0bca17204177db6
train
ContextIdentity.to_dict
Constructs an dictionary representation of the Identity Object to be used in serializing to JSON :return: dict representing the object
samcli/local/events/api_event.py
def to_dict(self): """ Constructs an dictionary representation of the Identity Object to be used in serializing to JSON :return: dict representing the object """ json_dict = {"apiKey": self.api_key, "userArn": self.user_arn, "cognitoAuth...
def to_dict(self): """ Constructs an dictionary representation of the Identity Object to be used in serializing to JSON :return: dict representing the object """ json_dict = {"apiKey": self.api_key, "userArn": self.user_arn, "cognitoAuth...
[ "Constructs", "an", "dictionary", "representation", "of", "the", "Identity", "Object", "to", "be", "used", "in", "serializing", "to", "JSON" ]
awslabs/aws-sam-cli
python
https://github.com/awslabs/aws-sam-cli/blob/c05af5e7378c6f05f7d82ad3f0bca17204177db6/samcli/local/events/api_event.py#L42-L60
[ "def", "to_dict", "(", "self", ")", ":", "json_dict", "=", "{", "\"apiKey\"", ":", "self", ".", "api_key", ",", "\"userArn\"", ":", "self", ".", "user_arn", ",", "\"cognitoAuthenticationType\"", ":", "self", ".", "cognito_authentication_type", ",", "\"caller\"",...
c05af5e7378c6f05f7d82ad3f0bca17204177db6
train
RequestContext.to_dict
Constructs an dictionary representation of the RequestContext Object to be used in serializing to JSON :return: dict representing the object
samcli/local/events/api_event.py
def to_dict(self): """ Constructs an dictionary representation of the RequestContext Object to be used in serializing to JSON :return: dict representing the object """ identity_dict = {} if self.identity: identity_dict = self.identity.to_dict() json_...
def to_dict(self): """ Constructs an dictionary representation of the RequestContext Object to be used in serializing to JSON :return: dict representing the object """ identity_dict = {} if self.identity: identity_dict = self.identity.to_dict() json_...
[ "Constructs", "an", "dictionary", "representation", "of", "the", "RequestContext", "Object", "to", "be", "used", "in", "serializing", "to", "JSON" ]
awslabs/aws-sam-cli
python
https://github.com/awslabs/aws-sam-cli/blob/c05af5e7378c6f05f7d82ad3f0bca17204177db6/samcli/local/events/api_event.py#L102-L124
[ "def", "to_dict", "(", "self", ")", ":", "identity_dict", "=", "{", "}", "if", "self", ".", "identity", ":", "identity_dict", "=", "self", ".", "identity", ".", "to_dict", "(", ")", "json_dict", "=", "{", "\"resourceId\"", ":", "self", ".", "resource_id"...
c05af5e7378c6f05f7d82ad3f0bca17204177db6
train
ApiGatewayLambdaEvent.to_dict
Constructs an dictionary representation of the ApiGatewayLambdaEvent Object to be used in serializing to JSON :return: dict representing the object
samcli/local/events/api_event.py
def to_dict(self): """ Constructs an dictionary representation of the ApiGatewayLambdaEvent Object to be used in serializing to JSON :return: dict representing the object """ request_context_dict = {} if self.request_context: request_context_dict = self.reque...
def to_dict(self): """ Constructs an dictionary representation of the ApiGatewayLambdaEvent Object to be used in serializing to JSON :return: dict representing the object """ request_context_dict = {} if self.request_context: request_context_dict = self.reque...
[ "Constructs", "an", "dictionary", "representation", "of", "the", "ApiGatewayLambdaEvent", "Object", "to", "be", "used", "in", "serializing", "to", "JSON" ]
awslabs/aws-sam-cli
python
https://github.com/awslabs/aws-sam-cli/blob/c05af5e7378c6f05f7d82ad3f0bca17204177db6/samcli/local/events/api_event.py#L179-L201
[ "def", "to_dict", "(", "self", ")", ":", "request_context_dict", "=", "{", "}", "if", "self", ".", "request_context", ":", "request_context_dict", "=", "self", ".", "request_context", ".", "to_dict", "(", ")", "json_dict", "=", "{", "\"httpMethod\"", ":", "s...
c05af5e7378c6f05f7d82ad3f0bca17204177db6
train
do_cli
Implementation of the ``cli`` method
samcli/commands/logs/command.py
def do_cli(function_name, stack_name, filter_pattern, tailing, start_time, end_time): """ Implementation of the ``cli`` method """ LOG.debug("'logs' command is called") with LogsCommandContext(function_name, stack_name=stack_name, filter_patt...
def do_cli(function_name, stack_name, filter_pattern, tailing, start_time, end_time): """ Implementation of the ``cli`` method """ LOG.debug("'logs' command is called") with LogsCommandContext(function_name, stack_name=stack_name, filter_patt...
[ "Implementation", "of", "the", "cli", "method" ]
awslabs/aws-sam-cli
python
https://github.com/awslabs/aws-sam-cli/blob/c05af5e7378c6f05f7d82ad3f0bca17204177db6/samcli/commands/logs/command.py#L76-L105
[ "def", "do_cli", "(", "function_name", ",", "stack_name", ",", "filter_pattern", ",", "tailing", ",", "start_time", ",", "end_time", ")", ":", "LOG", ".", "debug", "(", "\"'logs' command is called\"", ")", "with", "LogsCommandContext", "(", "function_name", ",", ...
c05af5e7378c6f05f7d82ad3f0bca17204177db6
train
ContainerManager.is_docker_reachable
Checks if Docker daemon is running. This is required for us to invoke the function locally Returns ------- bool True, if Docker is available, False otherwise
samcli/local/docker/manager.py
def is_docker_reachable(self): """ Checks if Docker daemon is running. This is required for us to invoke the function locally Returns ------- bool True, if Docker is available, False otherwise """ try: self.docker_client.ping() ...
def is_docker_reachable(self): """ Checks if Docker daemon is running. This is required for us to invoke the function locally Returns ------- bool True, if Docker is available, False otherwise """ try: self.docker_client.ping() ...
[ "Checks", "if", "Docker", "daemon", "is", "running", ".", "This", "is", "required", "for", "us", "to", "invoke", "the", "function", "locally" ]
awslabs/aws-sam-cli
python
https://github.com/awslabs/aws-sam-cli/blob/c05af5e7378c6f05f7d82ad3f0bca17204177db6/samcli/local/docker/manager.py#L40-L57
[ "def", "is_docker_reachable", "(", "self", ")", ":", "try", ":", "self", ".", "docker_client", ".", "ping", "(", ")", "return", "True", "# When Docker is not installed, a request.exceptions.ConnectionError is thrown.", "except", "(", "docker", ".", "errors", ".", "API...
c05af5e7378c6f05f7d82ad3f0bca17204177db6
train
ContainerManager.run
Create and run a Docker container based on the given configuration. :param samcli.local.docker.container.Container container: Container to create and run :param input_data: Optional. Input data sent to the container through container's stdin. :param bool warm: Indicates if an existing container...
samcli/local/docker/manager.py
def run(self, container, input_data=None, warm=False): """ Create and run a Docker container based on the given configuration. :param samcli.local.docker.container.Container container: Container to create and run :param input_data: Optional. Input data sent to the container through cont...
def run(self, container, input_data=None, warm=False): """ Create and run a Docker container based on the given configuration. :param samcli.local.docker.container.Container container: Container to create and run :param input_data: Optional. Input data sent to the container through cont...
[ "Create", "and", "run", "a", "Docker", "container", "based", "on", "the", "given", "configuration", "." ]
awslabs/aws-sam-cli
python
https://github.com/awslabs/aws-sam-cli/blob/c05af5e7378c6f05f7d82ad3f0bca17204177db6/samcli/local/docker/manager.py#L59-L98
[ "def", "run", "(", "self", ",", "container", ",", "input_data", "=", "None", ",", "warm", "=", "False", ")", ":", "if", "warm", ":", "raise", "ValueError", "(", "\"The facility to invoke warm container does not exist\"", ")", "image_name", "=", "container", ".",...
c05af5e7378c6f05f7d82ad3f0bca17204177db6
train
ContainerManager.pull_image
Ask Docker to pull the container image with given name. Parameters ---------- image_name str Name of the image stream samcli.lib.utils.stream_writer.StreamWriter Optional stream writer to output to. Defaults to stderr Raises ------ Docker...
samcli/local/docker/manager.py
def pull_image(self, image_name, stream=None): """ Ask Docker to pull the container image with given name. Parameters ---------- image_name str Name of the image stream samcli.lib.utils.stream_writer.StreamWriter Optional stream writer to output t...
def pull_image(self, image_name, stream=None): """ Ask Docker to pull the container image with given name. Parameters ---------- image_name str Name of the image stream samcli.lib.utils.stream_writer.StreamWriter Optional stream writer to output t...
[ "Ask", "Docker", "to", "pull", "the", "container", "image", "with", "given", "name", "." ]
awslabs/aws-sam-cli
python
https://github.com/awslabs/aws-sam-cli/blob/c05af5e7378c6f05f7d82ad3f0bca17204177db6/samcli/local/docker/manager.py#L108-L142
[ "def", "pull_image", "(", "self", ",", "image_name", ",", "stream", "=", "None", ")", ":", "stream_writer", "=", "stream", "or", "StreamWriter", "(", "sys", ".", "stderr", ")", "try", ":", "result_itr", "=", "self", ".", "docker_client", ".", "api", ".",...
c05af5e7378c6f05f7d82ad3f0bca17204177db6
train
ContainerManager.has_image
Is the container image with given name available? :param string image_name: Name of the image :return bool: True, if image is available. False, otherwise
samcli/local/docker/manager.py
def has_image(self, image_name): """ Is the container image with given name available? :param string image_name: Name of the image :return bool: True, if image is available. False, otherwise """ try: self.docker_client.images.get(image_name) retu...
def has_image(self, image_name): """ Is the container image with given name available? :param string image_name: Name of the image :return bool: True, if image is available. False, otherwise """ try: self.docker_client.images.get(image_name) retu...
[ "Is", "the", "container", "image", "with", "given", "name", "available?" ]
awslabs/aws-sam-cli
python
https://github.com/awslabs/aws-sam-cli/blob/c05af5e7378c6f05f7d82ad3f0bca17204177db6/samcli/local/docker/manager.py#L144-L156
[ "def", "has_image", "(", "self", ",", "image_name", ")", ":", "try", ":", "self", ".", "docker_client", ".", "images", ".", "get", "(", "image_name", ")", "return", "True", "except", "docker", ".", "errors", ".", "ImageNotFound", ":", "return", "False" ]
c05af5e7378c6f05f7d82ad3f0bca17204177db6
train
do_cli
Publish the application based on command line inputs.
samcli/commands/publish/command.py
def do_cli(ctx, template, semantic_version): """Publish the application based on command line inputs.""" try: template_data = get_template_data(template) except ValueError as ex: click.secho("Publish Failed", fg='red') raise UserException(str(ex)) # Override SemanticVersion in t...
def do_cli(ctx, template, semantic_version): """Publish the application based on command line inputs.""" try: template_data = get_template_data(template) except ValueError as ex: click.secho("Publish Failed", fg='red') raise UserException(str(ex)) # Override SemanticVersion in t...
[ "Publish", "the", "application", "based", "on", "command", "line", "inputs", "." ]
awslabs/aws-sam-cli
python
https://github.com/awslabs/aws-sam-cli/blob/c05af5e7378c6f05f7d82ad3f0bca17204177db6/samcli/commands/publish/command.py#L55-L83
[ "def", "do_cli", "(", "ctx", ",", "template", ",", "semantic_version", ")", ":", "try", ":", "template_data", "=", "get_template_data", "(", "template", ")", "except", "ValueError", "as", "ex", ":", "click", ".", "secho", "(", "\"Publish Failed\"", ",", "fg"...
c05af5e7378c6f05f7d82ad3f0bca17204177db6
train
_gen_success_message
Generate detailed success message for published applications. Parameters ---------- publish_output : dict Output from serverlessrepo publish_application Returns ------- str Detailed success message
samcli/commands/publish/command.py
def _gen_success_message(publish_output): """ Generate detailed success message for published applications. Parameters ---------- publish_output : dict Output from serverlessrepo publish_application Returns ------- str Detailed success message """ application_id...
def _gen_success_message(publish_output): """ Generate detailed success message for published applications. Parameters ---------- publish_output : dict Output from serverlessrepo publish_application Returns ------- str Detailed success message """ application_id...
[ "Generate", "detailed", "success", "message", "for", "published", "applications", "." ]
awslabs/aws-sam-cli
python
https://github.com/awslabs/aws-sam-cli/blob/c05af5e7378c6f05f7d82ad3f0bca17204177db6/samcli/commands/publish/command.py#L86-L106
[ "def", "_gen_success_message", "(", "publish_output", ")", ":", "application_id", "=", "publish_output", ".", "get", "(", "'application_id'", ")", "details", "=", "json", ".", "dumps", "(", "publish_output", ".", "get", "(", "'details'", ")", ",", "indent", "=...
c05af5e7378c6f05f7d82ad3f0bca17204177db6
train
_print_console_link
Print link for the application in AWS Serverless Application Repository console. Parameters ---------- region : str AWS region name application_id : str The Amazon Resource Name (ARN) of the application
samcli/commands/publish/command.py
def _print_console_link(region, application_id): """ Print link for the application in AWS Serverless Application Repository console. Parameters ---------- region : str AWS region name application_id : str The Amazon Resource Name (ARN) of the application """ if not reg...
def _print_console_link(region, application_id): """ Print link for the application in AWS Serverless Application Repository console. Parameters ---------- region : str AWS region name application_id : str The Amazon Resource Name (ARN) of the application """ if not reg...
[ "Print", "link", "for", "the", "application", "in", "AWS", "Serverless", "Application", "Repository", "console", "." ]
awslabs/aws-sam-cli
python
https://github.com/awslabs/aws-sam-cli/blob/c05af5e7378c6f05f7d82ad3f0bca17204177db6/samcli/commands/publish/command.py#L109-L126
[ "def", "_print_console_link", "(", "region", ",", "application_id", ")", ":", "if", "not", "region", ":", "region", "=", "boto3", ".", "Session", "(", ")", ".", "region_name", "console_link", "=", "SERVERLESSREPO_CONSOLE_URL", ".", "format", "(", "region", ","...
c05af5e7378c6f05f7d82ad3f0bca17204177db6
train
ServiceErrorResponses.lambda_failure_response
Helper function to create a Lambda Failure Response :return: A Flask Response
samcli/local/apigw/service_error_responses.py
def lambda_failure_response(*args): """ Helper function to create a Lambda Failure Response :return: A Flask Response """ response_data = jsonify(ServiceErrorResponses._LAMBDA_FAILURE) return make_response(response_data, ServiceErrorResponses.HTTP_STATUS_CODE_502)
def lambda_failure_response(*args): """ Helper function to create a Lambda Failure Response :return: A Flask Response """ response_data = jsonify(ServiceErrorResponses._LAMBDA_FAILURE) return make_response(response_data, ServiceErrorResponses.HTTP_STATUS_CODE_502)
[ "Helper", "function", "to", "create", "a", "Lambda", "Failure", "Response" ]
awslabs/aws-sam-cli
python
https://github.com/awslabs/aws-sam-cli/blob/c05af5e7378c6f05f7d82ad3f0bca17204177db6/samcli/local/apigw/service_error_responses.py#L16-L23
[ "def", "lambda_failure_response", "(", "*", "args", ")", ":", "response_data", "=", "jsonify", "(", "ServiceErrorResponses", ".", "_LAMBDA_FAILURE", ")", "return", "make_response", "(", "response_data", ",", "ServiceErrorResponses", ".", "HTTP_STATUS_CODE_502", ")" ]
c05af5e7378c6f05f7d82ad3f0bca17204177db6
train
ServiceErrorResponses.lambda_not_found_response
Constructs a Flask Response for when a Lambda function is not found for an endpoint :return: a Flask Response
samcli/local/apigw/service_error_responses.py
def lambda_not_found_response(*args): """ Constructs a Flask Response for when a Lambda function is not found for an endpoint :return: a Flask Response """ response_data = jsonify(ServiceErrorResponses._NO_LAMBDA_INTEGRATION) return make_response(response_data, ServiceEr...
def lambda_not_found_response(*args): """ Constructs a Flask Response for when a Lambda function is not found for an endpoint :return: a Flask Response """ response_data = jsonify(ServiceErrorResponses._NO_LAMBDA_INTEGRATION) return make_response(response_data, ServiceEr...
[ "Constructs", "a", "Flask", "Response", "for", "when", "a", "Lambda", "function", "is", "not", "found", "for", "an", "endpoint" ]
awslabs/aws-sam-cli
python
https://github.com/awslabs/aws-sam-cli/blob/c05af5e7378c6f05f7d82ad3f0bca17204177db6/samcli/local/apigw/service_error_responses.py#L26-L33
[ "def", "lambda_not_found_response", "(", "*", "args", ")", ":", "response_data", "=", "jsonify", "(", "ServiceErrorResponses", ".", "_NO_LAMBDA_INTEGRATION", ")", "return", "make_response", "(", "response_data", ",", "ServiceErrorResponses", ".", "HTTP_STATUS_CODE_502", ...
c05af5e7378c6f05f7d82ad3f0bca17204177db6
train
ServiceErrorResponses.route_not_found
Constructs a Flask Response for when a API Route (path+method) is not found. This is usually HTTP 404 but with API Gateway this is a HTTP 403 (https://forums.aws.amazon.com/thread.jspa?threadID=2166840) :return: a Flask Response
samcli/local/apigw/service_error_responses.py
def route_not_found(*args): """ Constructs a Flask Response for when a API Route (path+method) is not found. This is usually HTTP 404 but with API Gateway this is a HTTP 403 (https://forums.aws.amazon.com/thread.jspa?threadID=2166840) :return: a Flask Response """ respon...
def route_not_found(*args): """ Constructs a Flask Response for when a API Route (path+method) is not found. This is usually HTTP 404 but with API Gateway this is a HTTP 403 (https://forums.aws.amazon.com/thread.jspa?threadID=2166840) :return: a Flask Response """ respon...
[ "Constructs", "a", "Flask", "Response", "for", "when", "a", "API", "Route", "(", "path", "+", "method", ")", "is", "not", "found", ".", "This", "is", "usually", "HTTP", "404", "but", "with", "API", "Gateway", "this", "is", "a", "HTTP", "403", "(", "h...
awslabs/aws-sam-cli
python
https://github.com/awslabs/aws-sam-cli/blob/c05af5e7378c6f05f7d82ad3f0bca17204177db6/samcli/local/apigw/service_error_responses.py#L36-L44
[ "def", "route_not_found", "(", "*", "args", ")", ":", "response_data", "=", "jsonify", "(", "ServiceErrorResponses", ".", "_MISSING_AUTHENTICATION", ")", "return", "make_response", "(", "response_data", ",", "ServiceErrorResponses", ".", "HTTP_STATUS_CODE_403", ")" ]
c05af5e7378c6f05f7d82ad3f0bca17204177db6
train
progressbar
Creates a progressbar Parameters ---------- length int Length of the ProgressBar label str Label to give to the progressbar Returns ------- click.progressbar Progressbar
samcli/lib/utils/progressbar.py
def progressbar(length, label): """ Creates a progressbar Parameters ---------- length int Length of the ProgressBar label str Label to give to the progressbar Returns ------- click.progressbar Progressbar """ return click.progressbar(length=length,...
def progressbar(length, label): """ Creates a progressbar Parameters ---------- length int Length of the ProgressBar label str Label to give to the progressbar Returns ------- click.progressbar Progressbar """ return click.progressbar(length=length,...
[ "Creates", "a", "progressbar" ]
awslabs/aws-sam-cli
python
https://github.com/awslabs/aws-sam-cli/blob/c05af5e7378c6f05f7d82ad3f0bca17204177db6/samcli/lib/utils/progressbar.py#L8-L25
[ "def", "progressbar", "(", "length", ",", "label", ")", ":", "return", "click", ".", "progressbar", "(", "length", "=", "length", ",", "label", "=", "label", ",", "show_pos", "=", "True", ")" ]
c05af5e7378c6f05f7d82ad3f0bca17204177db6
train
CfnParameterOverridesType._unquote
r""" Removes wrapping double quotes and any '\ ' characters. They are usually added to preserve spaces when passing value thru shell. Examples -------- >>> _unquote('val\ ue') value >>> _unquote("hel\ lo") hello Parameters ---------- ...
samcli/cli/types.py
def _unquote(value): r""" Removes wrapping double quotes and any '\ ' characters. They are usually added to preserve spaces when passing value thru shell. Examples -------- >>> _unquote('val\ ue') value >>> _unquote("hel\ lo") hello Para...
def _unquote(value): r""" Removes wrapping double quotes and any '\ ' characters. They are usually added to preserve spaces when passing value thru shell. Examples -------- >>> _unquote('val\ ue') value >>> _unquote("hel\ lo") hello Para...
[ "r", "Removes", "wrapping", "double", "quotes", "and", "any", "\\", "characters", ".", "They", "are", "usually", "added", "to", "preserve", "spaces", "when", "passing", "value", "thru", "shell", "." ]
awslabs/aws-sam-cli
python
https://github.com/awslabs/aws-sam-cli/blob/c05af5e7378c6f05f7d82ad3f0bca17204177db6/samcli/cli/types.py#L42-L68
[ "def", "_unquote", "(", "value", ")", ":", "if", "value", "and", "(", "value", "[", "0", "]", "==", "value", "[", "-", "1", "]", "==", "'\"'", ")", ":", "# Remove quotes only if the string is wrapped in quotes", "value", "=", "value", ".", "strip", "(", ...
c05af5e7378c6f05f7d82ad3f0bca17204177db6
train
BaseLocalService.run
This starts up the (threaded) Local Server. Note: This is a **blocking call** Raises ------ RuntimeError if the service was not created
samcli/local/services/base_local_service.py
def run(self): """ This starts up the (threaded) Local Server. Note: This is a **blocking call** Raises ------ RuntimeError if the service was not created """ if not self._app: raise RuntimeError("The application must be created be...
def run(self): """ This starts up the (threaded) Local Server. Note: This is a **blocking call** Raises ------ RuntimeError if the service was not created """ if not self._app: raise RuntimeError("The application must be created be...
[ "This", "starts", "up", "the", "(", "threaded", ")", "Local", "Server", ".", "Note", ":", "This", "is", "a", "**", "blocking", "call", "**" ]
awslabs/aws-sam-cli
python
https://github.com/awslabs/aws-sam-cli/blob/c05af5e7378c6f05f7d82ad3f0bca17204177db6/samcli/local/services/base_local_service.py#L55-L81
[ "def", "run", "(", "self", ")", ":", "if", "not", "self", ".", "_app", ":", "raise", "RuntimeError", "(", "\"The application must be created before running\"", ")", "# Flask can operate as a single threaded server (which is default) and a multi-threaded server which is", "# more ...
c05af5e7378c6f05f7d82ad3f0bca17204177db6
train
BaseLocalService.service_response
Constructs a Flask Response from the body, headers, and status_code. :param str body: Response body as a string :param dict headers: headers for the response :param int status_code: status_code for response :return: Flask Response
samcli/local/services/base_local_service.py
def service_response(body, headers, status_code): """ Constructs a Flask Response from the body, headers, and status_code. :param str body: Response body as a string :param dict headers: headers for the response :param int status_code: status_code for response :return: F...
def service_response(body, headers, status_code): """ Constructs a Flask Response from the body, headers, and status_code. :param str body: Response body as a string :param dict headers: headers for the response :param int status_code: status_code for response :return: F...
[ "Constructs", "a", "Flask", "Response", "from", "the", "body", "headers", "and", "status_code", "." ]
awslabs/aws-sam-cli
python
https://github.com/awslabs/aws-sam-cli/blob/c05af5e7378c6f05f7d82ad3f0bca17204177db6/samcli/local/services/base_local_service.py#L84-L96
[ "def", "service_response", "(", "body", ",", "headers", ",", "status_code", ")", ":", "response", "=", "Response", "(", "body", ")", "response", ".", "headers", "=", "headers", "response", ".", "status_code", "=", "status_code", "return", "response" ]
c05af5e7378c6f05f7d82ad3f0bca17204177db6
train
LambdaOutputParser.get_lambda_output
This method will extract read the given stream and return the response from Lambda function separated out from any log statements it might have outputted. Logs end up in the stdout stream if the Lambda function wrote directly to stdout using System.out.println or equivalents. Parameters ...
samcli/local/services/base_local_service.py
def get_lambda_output(stdout_stream): """ This method will extract read the given stream and return the response from Lambda function separated out from any log statements it might have outputted. Logs end up in the stdout stream if the Lambda function wrote directly to stdout using Syst...
def get_lambda_output(stdout_stream): """ This method will extract read the given stream and return the response from Lambda function separated out from any log statements it might have outputted. Logs end up in the stdout stream if the Lambda function wrote directly to stdout using Syst...
[ "This", "method", "will", "extract", "read", "the", "given", "stream", "and", "return", "the", "response", "from", "Lambda", "function", "separated", "out", "from", "any", "log", "statements", "it", "might", "have", "outputted", ".", "Logs", "end", "up", "in...
awslabs/aws-sam-cli
python
https://github.com/awslabs/aws-sam-cli/blob/c05af5e7378c6f05f7d82ad3f0bca17204177db6/samcli/local/services/base_local_service.py#L102-L149
[ "def", "get_lambda_output", "(", "stdout_stream", ")", ":", "# We only want the last line of stdout, because it's possible that", "# the function may have written directly to stdout using", "# System.out.println or similar, before docker-lambda output the result", "stdout_data", "=", "stdout_s...
c05af5e7378c6f05f7d82ad3f0bca17204177db6
train
LambdaOutputParser.is_lambda_error_response
Check to see if the output from the container is in the form of an Error/Exception from the Lambda invoke Parameters ---------- lambda_response str The response the container returned Returns ------- bool True if the output matches the Error/Exce...
samcli/local/services/base_local_service.py
def is_lambda_error_response(lambda_response): """ Check to see if the output from the container is in the form of an Error/Exception from the Lambda invoke Parameters ---------- lambda_response str The response the container returned Returns -------...
def is_lambda_error_response(lambda_response): """ Check to see if the output from the container is in the form of an Error/Exception from the Lambda invoke Parameters ---------- lambda_response str The response the container returned Returns -------...
[ "Check", "to", "see", "if", "the", "output", "from", "the", "container", "is", "in", "the", "form", "of", "an", "Error", "/", "Exception", "from", "the", "Lambda", "invoke" ]
awslabs/aws-sam-cli
python
https://github.com/awslabs/aws-sam-cli/blob/c05af5e7378c6f05f7d82ad3f0bca17204177db6/samcli/local/services/base_local_service.py#L152-L184
[ "def", "is_lambda_error_response", "(", "lambda_response", ")", ":", "is_lambda_user_error_response", "=", "False", "try", ":", "lambda_response_dict", "=", "json", ".", "loads", "(", "lambda_response", ")", "# This is a best effort attempt to determine if the output (lambda_re...
c05af5e7378c6f05f7d82ad3f0bca17204177db6
train
ApplicationBuilder.build
Build the entire application Returns ------- dict Returns the path to where each resource was built as a map of resource's LogicalId to the path string
samcli/lib/build/app_builder.py
def build(self): """ Build the entire application Returns ------- dict Returns the path to where each resource was built as a map of resource's LogicalId to the path string """ result = {} for lambda_function in self._functions_to_build: ...
def build(self): """ Build the entire application Returns ------- dict Returns the path to where each resource was built as a map of resource's LogicalId to the path string """ result = {} for lambda_function in self._functions_to_build: ...
[ "Build", "the", "entire", "application" ]
awslabs/aws-sam-cli
python
https://github.com/awslabs/aws-sam-cli/blob/c05af5e7378c6f05f7d82ad3f0bca17204177db6/samcli/lib/build/app_builder.py#L91-L110
[ "def", "build", "(", "self", ")", ":", "result", "=", "{", "}", "for", "lambda_function", "in", "self", ".", "_functions_to_build", ":", "LOG", ".", "info", "(", "\"Building resource '%s'\"", ",", "lambda_function", ".", "name", ")", "result", "[", "lambda_f...
c05af5e7378c6f05f7d82ad3f0bca17204177db6
train
ApplicationBuilder.update_template
Given the path to built artifacts, update the template to point appropriate resource CodeUris to the artifacts folder Parameters ---------- template_dict original_template_path : str Path where the template file will be written to built_artifacts : dict ...
samcli/lib/build/app_builder.py
def update_template(self, template_dict, original_template_path, built_artifacts): """ Given the path to built artifacts, update the template to point appropriate resource CodeUris to the artifacts folder Parameters ---------- template_dict original_template_path...
def update_template(self, template_dict, original_template_path, built_artifacts): """ Given the path to built artifacts, update the template to point appropriate resource CodeUris to the artifacts folder Parameters ---------- template_dict original_template_path...
[ "Given", "the", "path", "to", "built", "artifacts", "update", "the", "template", "to", "point", "appropriate", "resource", "CodeUris", "to", "the", "artifacts", "folder" ]
awslabs/aws-sam-cli
python
https://github.com/awslabs/aws-sam-cli/blob/c05af5e7378c6f05f7d82ad3f0bca17204177db6/samcli/lib/build/app_builder.py#L112-L153
[ "def", "update_template", "(", "self", ",", "template_dict", ",", "original_template_path", ",", "built_artifacts", ")", ":", "original_dir", "=", "os", ".", "path", ".", "dirname", "(", "original_template_path", ")", "for", "logical_id", ",", "resource", "in", ...
c05af5e7378c6f05f7d82ad3f0bca17204177db6
train
ApplicationBuilder._build_function
Given the function information, this method will build the Lambda function. Depending on the configuration it will either build the function in process or by spinning up a Docker container. Parameters ---------- function_name : str Name or LogicalId of the function ...
samcli/lib/build/app_builder.py
def _build_function(self, function_name, codeuri, runtime): """ Given the function information, this method will build the Lambda function. Depending on the configuration it will either build the function in process or by spinning up a Docker container. Parameters ---------- ...
def _build_function(self, function_name, codeuri, runtime): """ Given the function information, this method will build the Lambda function. Depending on the configuration it will either build the function in process or by spinning up a Docker container. Parameters ---------- ...
[ "Given", "the", "function", "information", "this", "method", "will", "build", "the", "Lambda", "function", ".", "Depending", "on", "the", "configuration", "it", "will", "either", "build", "the", "function", "in", "process", "or", "by", "spinning", "up", "a", ...
awslabs/aws-sam-cli
python
https://github.com/awslabs/aws-sam-cli/blob/c05af5e7378c6f05f7d82ad3f0bca17204177db6/samcli/lib/build/app_builder.py#L155-L199
[ "def", "_build_function", "(", "self", ",", "function_name", ",", "codeuri", ",", "runtime", ")", ":", "# Create the arguments to pass to the builder", "# Code is always relative to the given base directory.", "code_dir", "=", "str", "(", "pathlib", ".", "Path", "(", "sel...
c05af5e7378c6f05f7d82ad3f0bca17204177db6
train
LambdaBuildContainer._get_container_dirs
Provides paths to directories within the container that is required by the builder Parameters ---------- source_dir : str Path to the function source code manifest_dir : str Path to the directory containing manifest Returns ------- dict ...
samcli/local/docker/lambda_build_container.py
def _get_container_dirs(source_dir, manifest_dir): """ Provides paths to directories within the container that is required by the builder Parameters ---------- source_dir : str Path to the function source code manifest_dir : str Path to the direc...
def _get_container_dirs(source_dir, manifest_dir): """ Provides paths to directories within the container that is required by the builder Parameters ---------- source_dir : str Path to the function source code manifest_dir : str Path to the direc...
[ "Provides", "paths", "to", "directories", "within", "the", "container", "that", "is", "required", "by", "the", "builder" ]
awslabs/aws-sam-cli
python
https://github.com/awslabs/aws-sam-cli/blob/c05af5e7378c6f05f7d82ad3f0bca17204177db6/samcli/local/docker/lambda_build_container.py#L150-L180
[ "def", "_get_container_dirs", "(", "source_dir", ",", "manifest_dir", ")", ":", "base", "=", "\"/tmp/samcli\"", "result", "=", "{", "\"source_dir\"", ":", "\"{}/source\"", ".", "format", "(", "base", ")", ",", "\"artifacts_dir\"", ":", "\"{}/artifacts\"", ".", "...
c05af5e7378c6f05f7d82ad3f0bca17204177db6
train
LambdaBuildContainer._convert_to_container_dirs
Use this method to convert a list of host paths to a list of equivalent paths within the container where the given host path is mounted. This is necessary when SAM CLI needs to pass path information to the Lambda Builder running within the container. If a host path is not mounted within the con...
samcli/local/docker/lambda_build_container.py
def _convert_to_container_dirs(host_paths_to_convert, host_to_container_path_mapping): """ Use this method to convert a list of host paths to a list of equivalent paths within the container where the given host path is mounted. This is necessary when SAM CLI needs to pass path information to ...
def _convert_to_container_dirs(host_paths_to_convert, host_to_container_path_mapping): """ Use this method to convert a list of host paths to a list of equivalent paths within the container where the given host path is mounted. This is necessary when SAM CLI needs to pass path information to ...
[ "Use", "this", "method", "to", "convert", "a", "list", "of", "host", "paths", "to", "a", "list", "of", "equivalent", "paths", "within", "the", "container", "where", "the", "given", "host", "path", "is", "mounted", ".", "This", "is", "necessary", "when", ...
awslabs/aws-sam-cli
python
https://github.com/awslabs/aws-sam-cli/blob/c05af5e7378c6f05f7d82ad3f0bca17204177db6/samcli/local/docker/lambda_build_container.py#L183-L228
[ "def", "_convert_to_container_dirs", "(", "host_paths_to_convert", ",", "host_to_container_path_mapping", ")", ":", "if", "not", "host_paths_to_convert", ":", "# Nothing to do", "return", "host_paths_to_convert", "# Make sure the key is absolute host path. Relative paths are tricky to ...
c05af5e7378c6f05f7d82ad3f0bca17204177db6
train
SamTranslatorWrapper.__translate
This method is unused and a Work In Progress
samcli/lib/samlib/wrapper.py
def __translate(self, parameter_values): """ This method is unused and a Work In Progress """ template_copy = self.template sam_parser = Parser() sam_translator = Translator(managed_policy_map=self.__managed_policy_map(), sam_parser=s...
def __translate(self, parameter_values): """ This method is unused and a Work In Progress """ template_copy = self.template sam_parser = Parser() sam_translator = Translator(managed_policy_map=self.__managed_policy_map(), sam_parser=s...
[ "This", "method", "is", "unused", "and", "a", "Work", "In", "Progress" ]
awslabs/aws-sam-cli
python
https://github.com/awslabs/aws-sam-cli/blob/c05af5e7378c6f05f7d82ad3f0bca17204177db6/samcli/lib/samlib/wrapper.py#L74-L88
[ "def", "__translate", "(", "self", ",", "parameter_values", ")", ":", "template_copy", "=", "self", ".", "template", "sam_parser", "=", "Parser", "(", ")", "sam_translator", "=", "Translator", "(", "managed_policy_map", "=", "self", ".", "__managed_policy_map", ...
c05af5e7378c6f05f7d82ad3f0bca17204177db6
train
SamTranslatorWrapper.__managed_policy_map
This method is unused and a Work In Progress
samcli/lib/samlib/wrapper.py
def __managed_policy_map(self): """ This method is unused and a Work In Progress """ try: iam_client = boto3.client('iam') return ManagedPolicyLoader(iam_client).load() except Exception as ex: if self._offline_fallback: # If of...
def __managed_policy_map(self): """ This method is unused and a Work In Progress """ try: iam_client = boto3.client('iam') return ManagedPolicyLoader(iam_client).load() except Exception as ex: if self._offline_fallback: # If of...
[ "This", "method", "is", "unused", "and", "a", "Work", "In", "Progress" ]
awslabs/aws-sam-cli
python
https://github.com/awslabs/aws-sam-cli/blob/c05af5e7378c6f05f7d82ad3f0bca17204177db6/samcli/lib/samlib/wrapper.py#L94-L110
[ "def", "__managed_policy_map", "(", "self", ")", ":", "try", ":", "iam_client", "=", "boto3", ".", "client", "(", "'iam'", ")", "return", "ManagedPolicyLoader", "(", "iam_client", ")", ".", "load", "(", ")", "except", "Exception", "as", "ex", ":", "if", ...
c05af5e7378c6f05f7d82ad3f0bca17204177db6
train
_SamParserReimplemented._validate
Validates the template and parameter values and raises exceptions if there's an issue :param dict sam_template: SAM template
samcli/lib/samlib/wrapper.py
def _validate(self, sam_template): """ Validates the template and parameter values and raises exceptions if there's an issue :param dict sam_template: SAM template """ if "Resources" not in sam_template or not isinstance(sam_template["Resources"], dict) \ or not sam_tem...
def _validate(self, sam_template): """ Validates the template and parameter values and raises exceptions if there's an issue :param dict sam_template: SAM template """ if "Resources" not in sam_template or not isinstance(sam_template["Resources"], dict) \ or not sam_tem...
[ "Validates", "the", "template", "and", "parameter", "values", "and", "raises", "exceptions", "if", "there", "s", "an", "issue" ]
awslabs/aws-sam-cli
python
https://github.com/awslabs/aws-sam-cli/blob/c05af5e7378c6f05f7d82ad3f0bca17204177db6/samcli/lib/samlib/wrapper.py#L136-L147
[ "def", "_validate", "(", "self", ",", "sam_template", ")", ":", "if", "\"Resources\"", "not", "in", "sam_template", "or", "not", "isinstance", "(", "sam_template", "[", "\"Resources\"", "]", ",", "dict", ")", "or", "not", "sam_template", "[", "\"Resources\"", ...
c05af5e7378c6f05f7d82ad3f0bca17204177db6
train
ServiceCommand.get_command
gets the subcommands under the service name Parameters ---------- ctx : Context the context object passed into the method cmd_name : str the service name Returns ------- EventTypeSubCommand: returns subcommand if successful, No...
samcli/commands/local/generate_event/event_generation.py
def get_command(self, ctx, cmd_name): """ gets the subcommands under the service name Parameters ---------- ctx : Context the context object passed into the method cmd_name : str the service name Returns ------- EventTypeSu...
def get_command(self, ctx, cmd_name): """ gets the subcommands under the service name Parameters ---------- ctx : Context the context object passed into the method cmd_name : str the service name Returns ------- EventTypeSu...
[ "gets", "the", "subcommands", "under", "the", "service", "name" ]
awslabs/aws-sam-cli
python
https://github.com/awslabs/aws-sam-cli/blob/c05af5e7378c6f05f7d82ad3f0bca17204177db6/samcli/commands/local/generate_event/event_generation.py#L45-L63
[ "def", "get_command", "(", "self", ",", "ctx", ",", "cmd_name", ")", ":", "if", "cmd_name", "not", "in", "self", ".", "all_cmds", ":", "return", "None", "return", "EventTypeSubCommand", "(", "self", ".", "events_lib", ",", "cmd_name", ",", "self", ".", "...
c05af5e7378c6f05f7d82ad3f0bca17204177db6
train
EventTypeSubCommand.get_command
gets the Click Commands underneath a service name Parameters ---------- ctx: Context context object passed in cmd_name: string the service name Returns ------- cmd: Click.Command the Click Commands that can be called from the C...
samcli/commands/local/generate_event/event_generation.py
def get_command(self, ctx, cmd_name): """ gets the Click Commands underneath a service name Parameters ---------- ctx: Context context object passed in cmd_name: string the service name Returns ------- cmd: Click.Command ...
def get_command(self, ctx, cmd_name): """ gets the Click Commands underneath a service name Parameters ---------- ctx: Context context object passed in cmd_name: string the service name Returns ------- cmd: Click.Command ...
[ "gets", "the", "Click", "Commands", "underneath", "a", "service", "name" ]
awslabs/aws-sam-cli
python
https://github.com/awslabs/aws-sam-cli/blob/c05af5e7378c6f05f7d82ad3f0bca17204177db6/samcli/commands/local/generate_event/event_generation.py#L119-L157
[ "def", "get_command", "(", "self", ",", "ctx", ",", "cmd_name", ")", ":", "if", "cmd_name", "not", "in", "self", ".", "subcmd_definition", ":", "return", "None", "parameters", "=", "[", "]", "for", "param_name", "in", "self", ".", "subcmd_definition", "[",...
c05af5e7378c6f05f7d82ad3f0bca17204177db6
train
EventTypeSubCommand.cmd_implementation
calls for value substitution in the event json and returns the customized json as a string Parameters ---------- events_lib top_level_cmd_name: string the name of the service subcmd_name: string the name of the event under the service args...
samcli/commands/local/generate_event/event_generation.py
def cmd_implementation(self, events_lib, top_level_cmd_name, subcmd_name, *args, **kwargs): """ calls for value substitution in the event json and returns the customized json as a string Parameters ---------- events_lib top_level_cmd_name: string the ...
def cmd_implementation(self, events_lib, top_level_cmd_name, subcmd_name, *args, **kwargs): """ calls for value substitution in the event json and returns the customized json as a string Parameters ---------- events_lib top_level_cmd_name: string the ...
[ "calls", "for", "value", "substitution", "in", "the", "event", "json", "and", "returns", "the", "customized", "json", "as", "a", "string" ]
awslabs/aws-sam-cli
python
https://github.com/awslabs/aws-sam-cli/blob/c05af5e7378c6f05f7d82ad3f0bca17204177db6/samcli/commands/local/generate_event/event_generation.py#L173-L196
[ "def", "cmd_implementation", "(", "self", ",", "events_lib", ",", "top_level_cmd_name", ",", "subcmd_name", ",", "*", "args", ",", "*", "*", "kwargs", ")", ":", "event", "=", "events_lib", ".", "generate_event", "(", "top_level_cmd_name", ",", "subcmd_name", "...
c05af5e7378c6f05f7d82ad3f0bca17204177db6
train
LimeBase.generate_lars_path
Generates the lars path for weighted data. Args: weighted_data: data that has been weighted by kernel weighted_label: labels, weighted by kernel Returns: (alphas, coefs), both are arrays corresponding to the regularization parameter and coefficients, res...
lime/lime_base.py
def generate_lars_path(weighted_data, weighted_labels): """Generates the lars path for weighted data. Args: weighted_data: data that has been weighted by kernel weighted_label: labels, weighted by kernel Returns: (alphas, coefs), both are arrays correspondin...
def generate_lars_path(weighted_data, weighted_labels): """Generates the lars path for weighted data. Args: weighted_data: data that has been weighted by kernel weighted_label: labels, weighted by kernel Returns: (alphas, coefs), both are arrays correspondin...
[ "Generates", "the", "lars", "path", "for", "weighted", "data", "." ]
marcotcr/lime
python
https://github.com/marcotcr/lime/blob/08133d47df00ed918e22005e0c98f6eefd5a1d71/lime/lime_base.py#L31-L47
[ "def", "generate_lars_path", "(", "weighted_data", ",", "weighted_labels", ")", ":", "x_vector", "=", "weighted_data", "alphas", ",", "_", ",", "coefs", "=", "lars_path", "(", "x_vector", ",", "weighted_labels", ",", "method", "=", "'lasso'", ",", "verbose", "...
08133d47df00ed918e22005e0c98f6eefd5a1d71
train
LimeBase.forward_selection
Iteratively adds features to the model
lime/lime_base.py
def forward_selection(self, data, labels, weights, num_features): """Iteratively adds features to the model""" clf = Ridge(alpha=0, fit_intercept=True, random_state=self.random_state) used_features = [] for _ in range(min(num_features, data.shape[1])): max_ = -100000000 ...
def forward_selection(self, data, labels, weights, num_features): """Iteratively adds features to the model""" clf = Ridge(alpha=0, fit_intercept=True, random_state=self.random_state) used_features = [] for _ in range(min(num_features, data.shape[1])): max_ = -100000000 ...
[ "Iteratively", "adds", "features", "to", "the", "model" ]
marcotcr/lime
python
https://github.com/marcotcr/lime/blob/08133d47df00ed918e22005e0c98f6eefd5a1d71/lime/lime_base.py#L49-L68
[ "def", "forward_selection", "(", "self", ",", "data", ",", "labels", ",", "weights", ",", "num_features", ")", ":", "clf", "=", "Ridge", "(", "alpha", "=", "0", ",", "fit_intercept", "=", "True", ",", "random_state", "=", "self", ".", "random_state", ")"...
08133d47df00ed918e22005e0c98f6eefd5a1d71
train
LimeBase.feature_selection
Selects features for the model. see explain_instance_with_data to understand the parameters.
lime/lime_base.py
def feature_selection(self, data, labels, weights, num_features, method): """Selects features for the model. see explain_instance_with_data to understand the parameters.""" if method == 'none': return np.array(range(data.shape[1])) elif method == 'forward_selection': ...
def feature_selection(self, data, labels, weights, num_features, method): """Selects features for the model. see explain_instance_with_data to understand the parameters.""" if method == 'none': return np.array(range(data.shape[1])) elif method == 'forward_selection': ...
[ "Selects", "features", "for", "the", "model", ".", "see", "explain_instance_with_data", "to", "understand", "the", "parameters", "." ]
marcotcr/lime
python
https://github.com/marcotcr/lime/blob/08133d47df00ed918e22005e0c98f6eefd5a1d71/lime/lime_base.py#L70-L106
[ "def", "feature_selection", "(", "self", ",", "data", ",", "labels", ",", "weights", ",", "num_features", ",", "method", ")", ":", "if", "method", "==", "'none'", ":", "return", "np", ".", "array", "(", "range", "(", "data", ".", "shape", "[", "1", "...
08133d47df00ed918e22005e0c98f6eefd5a1d71
train
LimeBase.explain_instance_with_data
Takes perturbed data, labels and distances, returns explanation. Args: neighborhood_data: perturbed data, 2d array. first element is assumed to be the original data point. neighborhood_labels: corresponding perturbed labels. should have as ...
lime/lime_base.py
def explain_instance_with_data(self, neighborhood_data, neighborhood_labels, distances, label, num_features, f...
def explain_instance_with_data(self, neighborhood_data, neighborhood_labels, distances, label, num_features, f...
[ "Takes", "perturbed", "data", "labels", "and", "distances", "returns", "explanation", "." ]
marcotcr/lime
python
https://github.com/marcotcr/lime/blob/08133d47df00ed918e22005e0c98f6eefd5a1d71/lime/lime_base.py#L108-L179
[ "def", "explain_instance_with_data", "(", "self", ",", "neighborhood_data", ",", "neighborhood_labels", ",", "distances", ",", "label", ",", "num_features", ",", "feature_selection", "=", "'auto'", ",", "model_regressor", "=", "None", ")", ":", "weights", "=", "se...
08133d47df00ed918e22005e0c98f6eefd5a1d71
train
id_generator
Helper function to generate random div ids. This is useful for embedding HTML into ipython notebooks.
lime/explanation.py
def id_generator(size=15, random_state=None): """Helper function to generate random div ids. This is useful for embedding HTML into ipython notebooks.""" chars = list(string.ascii_uppercase + string.digits) return ''.join(random_state.choice(chars, size, replace=True))
def id_generator(size=15, random_state=None): """Helper function to generate random div ids. This is useful for embedding HTML into ipython notebooks.""" chars = list(string.ascii_uppercase + string.digits) return ''.join(random_state.choice(chars, size, replace=True))
[ "Helper", "function", "to", "generate", "random", "div", "ids", ".", "This", "is", "useful", "for", "embedding", "HTML", "into", "ipython", "notebooks", "." ]
marcotcr/lime
python
https://github.com/marcotcr/lime/blob/08133d47df00ed918e22005e0c98f6eefd5a1d71/lime/explanation.py#L17-L21
[ "def", "id_generator", "(", "size", "=", "15", ",", "random_state", "=", "None", ")", ":", "chars", "=", "list", "(", "string", ".", "ascii_uppercase", "+", "string", ".", "digits", ")", "return", "''", ".", "join", "(", "random_state", ".", "choice", ...
08133d47df00ed918e22005e0c98f6eefd5a1d71
train
Explanation.available_labels
Returns the list of classification labels for which we have any explanations.
lime/explanation.py
def available_labels(self): """ Returns the list of classification labels for which we have any explanations. """ try: assert self.mode == "classification" except AssertionError: raise NotImplementedError('Not supported for regression explanations.') ...
def available_labels(self): """ Returns the list of classification labels for which we have any explanations. """ try: assert self.mode == "classification" except AssertionError: raise NotImplementedError('Not supported for regression explanations.') ...
[ "Returns", "the", "list", "of", "classification", "labels", "for", "which", "we", "have", "any", "explanations", "." ]
marcotcr/lime
python
https://github.com/marcotcr/lime/blob/08133d47df00ed918e22005e0c98f6eefd5a1d71/lime/explanation.py#L117-L127
[ "def", "available_labels", "(", "self", ")", ":", "try", ":", "assert", "self", ".", "mode", "==", "\"classification\"", "except", "AssertionError", ":", "raise", "NotImplementedError", "(", "'Not supported for regression explanations.'", ")", "else", ":", "ans", "=...
08133d47df00ed918e22005e0c98f6eefd5a1d71
train
Explanation.as_list
Returns the explanation as a list. Args: label: desired label. If you ask for a label for which an explanation wasn't computed, will throw an exception. Will be ignored for regression explanations. kwargs: keyword arguments, passed to domain_mapper ...
lime/explanation.py
def as_list(self, label=1, **kwargs): """Returns the explanation as a list. Args: label: desired label. If you ask for a label for which an explanation wasn't computed, will throw an exception. Will be ignored for regression explanations. kwargs: ...
def as_list(self, label=1, **kwargs): """Returns the explanation as a list. Args: label: desired label. If you ask for a label for which an explanation wasn't computed, will throw an exception. Will be ignored for regression explanations. kwargs: ...
[ "Returns", "the", "explanation", "as", "a", "list", "." ]
marcotcr/lime
python
https://github.com/marcotcr/lime/blob/08133d47df00ed918e22005e0c98f6eefd5a1d71/lime/explanation.py#L129-L145
[ "def", "as_list", "(", "self", ",", "label", "=", "1", ",", "*", "*", "kwargs", ")", ":", "label_to_use", "=", "label", "if", "self", ".", "mode", "==", "\"classification\"", "else", "self", ".", "dummy_label", "ans", "=", "self", ".", "domain_mapper", ...
08133d47df00ed918e22005e0c98f6eefd5a1d71
train
Explanation.as_pyplot_figure
Returns the explanation as a pyplot figure. Will throw an error if you don't have matplotlib installed Args: label: desired label. If you ask for a label for which an explanation wasn't computed, will throw an exception. Will be ignored for regression e...
lime/explanation.py
def as_pyplot_figure(self, label=1, **kwargs): """Returns the explanation as a pyplot figure. Will throw an error if you don't have matplotlib installed Args: label: desired label. If you ask for a label for which an explanation wasn't computed, will throw an exce...
def as_pyplot_figure(self, label=1, **kwargs): """Returns the explanation as a pyplot figure. Will throw an error if you don't have matplotlib installed Args: label: desired label. If you ask for a label for which an explanation wasn't computed, will throw an exce...
[ "Returns", "the", "explanation", "as", "a", "pyplot", "figure", "." ]
marcotcr/lime
python
https://github.com/marcotcr/lime/blob/08133d47df00ed918e22005e0c98f6eefd5a1d71/lime/explanation.py#L155-L184
[ "def", "as_pyplot_figure", "(", "self", ",", "label", "=", "1", ",", "*", "*", "kwargs", ")", ":", "import", "matplotlib", ".", "pyplot", "as", "plt", "exp", "=", "self", ".", "as_list", "(", "label", "=", "label", ",", "*", "*", "kwargs", ")", "fi...
08133d47df00ed918e22005e0c98f6eefd5a1d71
train
Explanation.show_in_notebook
Shows html explanation in ipython notebook. See as_html() for parameters. This will throw an error if you don't have IPython installed
lime/explanation.py
def show_in_notebook(self, labels=None, predict_proba=True, show_predicted_value=True, **kwargs): """Shows html explanation in ipython notebook. See as_html() for parameters. This will throw an e...
def show_in_notebook(self, labels=None, predict_proba=True, show_predicted_value=True, **kwargs): """Shows html explanation in ipython notebook. See as_html() for parameters. This will throw an e...
[ "Shows", "html", "explanation", "in", "ipython", "notebook", "." ]
marcotcr/lime
python
https://github.com/marcotcr/lime/blob/08133d47df00ed918e22005e0c98f6eefd5a1d71/lime/explanation.py#L186-L200
[ "def", "show_in_notebook", "(", "self", ",", "labels", "=", "None", ",", "predict_proba", "=", "True", ",", "show_predicted_value", "=", "True", ",", "*", "*", "kwargs", ")", ":", "from", "IPython", ".", "core", ".", "display", "import", "display", ",", ...
08133d47df00ed918e22005e0c98f6eefd5a1d71
train
Explanation.save_to_file
Saves html explanation to file. . Params: file_path: file to save explanations to See as_html() for additional parameters.
lime/explanation.py
def save_to_file(self, file_path, labels=None, predict_proba=True, show_predicted_value=True, **kwargs): """Saves html explanation to file. . Params: file_path: file to save explanations...
def save_to_file(self, file_path, labels=None, predict_proba=True, show_predicted_value=True, **kwargs): """Saves html explanation to file. . Params: file_path: file to save explanations...
[ "Saves", "html", "explanation", "to", "file", ".", "." ]
marcotcr/lime
python
https://github.com/marcotcr/lime/blob/08133d47df00ed918e22005e0c98f6eefd5a1d71/lime/explanation.py#L202-L221
[ "def", "save_to_file", "(", "self", ",", "file_path", ",", "labels", "=", "None", ",", "predict_proba", "=", "True", ",", "show_predicted_value", "=", "True", ",", "*", "*", "kwargs", ")", ":", "file_", "=", "open", "(", "file_path", ",", "'w'", ",", "...
08133d47df00ed918e22005e0c98f6eefd5a1d71
train
Explanation.as_html
Returns the explanation as an html page. Args: labels: desired labels to show explanations for (as barcharts). If you ask for a label for which an explanation wasn't computed, will throw an exception. If None, will show explanations for all available ...
lime/explanation.py
def as_html(self, labels=None, predict_proba=True, show_predicted_value=True, **kwargs): """Returns the explanation as an html page. Args: labels: desired labels to show explanations for (as barcharts). If you a...
def as_html(self, labels=None, predict_proba=True, show_predicted_value=True, **kwargs): """Returns the explanation as an html page. Args: labels: desired labels to show explanations for (as barcharts). If you a...
[ "Returns", "the", "explanation", "as", "an", "html", "page", "." ]
marcotcr/lime
python
https://github.com/marcotcr/lime/blob/08133d47df00ed918e22005e0c98f6eefd5a1d71/lime/explanation.py#L223-L328
[ "def", "as_html", "(", "self", ",", "labels", "=", "None", ",", "predict_proba", "=", "True", ",", "show_predicted_value", "=", "True", ",", "*", "*", "kwargs", ")", ":", "def", "jsonize", "(", "x", ")", ":", "return", "json", ".", "dumps", "(", "x",...
08133d47df00ed918e22005e0c98f6eefd5a1d71
train
BaseWrapper._check_params
Checks for mistakes in 'parameters' Args : parameters: dict, parameters to be checked Raises : ValueError: if any parameter is not a valid argument for the target function or the target function is not defined TypeError: if argument parameters is not...
lime/wrappers/scikit_image.py
def _check_params(self, parameters): """Checks for mistakes in 'parameters' Args : parameters: dict, parameters to be checked Raises : ValueError: if any parameter is not a valid argument for the target function or the target function is not defined ...
def _check_params(self, parameters): """Checks for mistakes in 'parameters' Args : parameters: dict, parameters to be checked Raises : ValueError: if any parameter is not a valid argument for the target function or the target function is not defined ...
[ "Checks", "for", "mistakes", "in", "parameters" ]
marcotcr/lime
python
https://github.com/marcotcr/lime/blob/08133d47df00ed918e22005e0c98f6eefd5a1d71/lime/wrappers/scikit_image.py#L26-L58
[ "def", "_check_params", "(", "self", ",", "parameters", ")", ":", "a_valid_fn", "=", "[", "]", "if", "self", ".", "target_fn", "is", "None", ":", "if", "callable", "(", "self", ")", ":", "a_valid_fn", ".", "append", "(", "self", ".", "__call__", ")", ...
08133d47df00ed918e22005e0c98f6eefd5a1d71
train
BaseWrapper.filter_params
Filters `target_params` and return those in `fn`'s arguments. Args: fn : arbitrary function override: dict, values to override target_params Returns: result : dict, dictionary containing variables in both target_params and fn's arguments.
lime/wrappers/scikit_image.py
def filter_params(self, fn, override=None): """Filters `target_params` and return those in `fn`'s arguments. Args: fn : arbitrary function override: dict, values to override target_params Returns: result : dict, dictionary containing variables in b...
def filter_params(self, fn, override=None): """Filters `target_params` and return those in `fn`'s arguments. Args: fn : arbitrary function override: dict, values to override target_params Returns: result : dict, dictionary containing variables in b...
[ "Filters", "target_params", "and", "return", "those", "in", "fn", "s", "arguments", ".", "Args", ":", "fn", ":", "arbitrary", "function", "override", ":", "dict", "values", "to", "override", "target_params", "Returns", ":", "result", ":", "dict", "dictionary",...
marcotcr/lime
python
https://github.com/marcotcr/lime/blob/08133d47df00ed918e22005e0c98f6eefd5a1d71/lime/wrappers/scikit_image.py#L72-L87
[ "def", "filter_params", "(", "self", ",", "fn", ",", "override", "=", "None", ")", ":", "override", "=", "override", "or", "{", "}", "result", "=", "{", "}", "for", "name", ",", "value", "in", "self", ".", "target_params", ".", "items", "(", ")", "...
08133d47df00ed918e22005e0c98f6eefd5a1d71
train
TextDomainMapper.map_exp_ids
Maps ids to words or word-position strings. Args: exp: list of tuples [(id, weight), (id,weight)] positions: if True, also return word positions Returns: list of tuples (word, weight), or (word_positions, weight) if examples: ('bad', 1) or ('bad_3-6-12',...
lime/lime_text.py
def map_exp_ids(self, exp, positions=False): """Maps ids to words or word-position strings. Args: exp: list of tuples [(id, weight), (id,weight)] positions: if True, also return word positions Returns: list of tuples (word, weight), or (word_positions, weigh...
def map_exp_ids(self, exp, positions=False): """Maps ids to words or word-position strings. Args: exp: list of tuples [(id, weight), (id,weight)] positions: if True, also return word positions Returns: list of tuples (word, weight), or (word_positions, weigh...
[ "Maps", "ids", "to", "words", "or", "word", "-", "position", "strings", "." ]
marcotcr/lime
python
https://github.com/marcotcr/lime/blob/08133d47df00ed918e22005e0c98f6eefd5a1d71/lime/lime_text.py#L31-L51
[ "def", "map_exp_ids", "(", "self", ",", "exp", ",", "positions", "=", "False", ")", ":", "if", "positions", ":", "exp", "=", "[", "(", "'%s_%s'", "%", "(", "self", ".", "indexed_string", ".", "word", "(", "x", "[", "0", "]", ")", ",", "'-'", ".",...
08133d47df00ed918e22005e0c98f6eefd5a1d71
train
TextDomainMapper.visualize_instance_html
Adds text with highlighted words to visualization. Args: exp: list of tuples [(id, weight), (id,weight)] label: label id (integer) div_name: name of div object to be used for rendering(in js) exp_object_name: name of js explanation object text: i...
lime/lime_text.py
def visualize_instance_html(self, exp, label, div_name, exp_object_name, text=True, opacity=True): """Adds text with highlighted words to visualization. Args: exp: list of tuples [(id, weight), (id,weight)] label: label id (integer) ...
def visualize_instance_html(self, exp, label, div_name, exp_object_name, text=True, opacity=True): """Adds text with highlighted words to visualization. Args: exp: list of tuples [(id, weight), (id,weight)] label: label id (integer) ...
[ "Adds", "text", "with", "highlighted", "words", "to", "visualization", "." ]
marcotcr/lime
python
https://github.com/marcotcr/lime/blob/08133d47df00ed918e22005e0c98f6eefd5a1d71/lime/lime_text.py#L53-L80
[ "def", "visualize_instance_html", "(", "self", ",", "exp", ",", "label", ",", "div_name", ",", "exp_object_name", ",", "text", "=", "True", ",", "opacity", "=", "True", ")", ":", "if", "not", "text", ":", "return", "u''", "text", "=", "(", "self", ".",...
08133d47df00ed918e22005e0c98f6eefd5a1d71
train
IndexedString.string_position
Returns a np array with indices to id_ (int) occurrences
lime/lime_text.py
def string_position(self, id_): """Returns a np array with indices to id_ (int) occurrences""" if self.bow: return self.string_start[self.positions[id_]] else: return self.string_start[[self.positions[id_]]]
def string_position(self, id_): """Returns a np array with indices to id_ (int) occurrences""" if self.bow: return self.string_start[self.positions[id_]] else: return self.string_start[[self.positions[id_]]]
[ "Returns", "a", "np", "array", "with", "indices", "to", "id_", "(", "int", ")", "occurrences" ]
marcotcr/lime
python
https://github.com/marcotcr/lime/blob/08133d47df00ed918e22005e0c98f6eefd5a1d71/lime/lime_text.py#L155-L160
[ "def", "string_position", "(", "self", ",", "id_", ")", ":", "if", "self", ".", "bow", ":", "return", "self", ".", "string_start", "[", "self", ".", "positions", "[", "id_", "]", "]", "else", ":", "return", "self", ".", "string_start", "[", "[", "sel...
08133d47df00ed918e22005e0c98f6eefd5a1d71
train
IndexedString.inverse_removing
Returns a string after removing the appropriate words. If self.bow is false, replaces word with UNKWORDZ instead of removing it. Args: words_to_remove: list of ids (ints) to remove Returns: original raw string with appropriate words removed.
lime/lime_text.py
def inverse_removing(self, words_to_remove): """Returns a string after removing the appropriate words. If self.bow is false, replaces word with UNKWORDZ instead of removing it. Args: words_to_remove: list of ids (ints) to remove Returns: original raw st...
def inverse_removing(self, words_to_remove): """Returns a string after removing the appropriate words. If self.bow is false, replaces word with UNKWORDZ instead of removing it. Args: words_to_remove: list of ids (ints) to remove Returns: original raw st...
[ "Returns", "a", "string", "after", "removing", "the", "appropriate", "words", "." ]
marcotcr/lime
python
https://github.com/marcotcr/lime/blob/08133d47df00ed918e22005e0c98f6eefd5a1d71/lime/lime_text.py#L162-L179
[ "def", "inverse_removing", "(", "self", ",", "words_to_remove", ")", ":", "mask", "=", "np", ".", "ones", "(", "self", ".", "as_np", ".", "shape", "[", "0", "]", ",", "dtype", "=", "'bool'", ")", "mask", "[", "self", ".", "__get_idxs", "(", "words_to...
08133d47df00ed918e22005e0c98f6eefd5a1d71
train
IndexedString._segment_with_tokens
Segment a string around the tokens created by a passed-in tokenizer
lime/lime_text.py
def _segment_with_tokens(text, tokens): """Segment a string around the tokens created by a passed-in tokenizer""" list_form = [] text_ptr = 0 for token in tokens: inter_token_string = [] while not text[text_ptr:].startswith(token): inter_token_stri...
def _segment_with_tokens(text, tokens): """Segment a string around the tokens created by a passed-in tokenizer""" list_form = [] text_ptr = 0 for token in tokens: inter_token_string = [] while not text[text_ptr:].startswith(token): inter_token_stri...
[ "Segment", "a", "string", "around", "the", "tokens", "created", "by", "a", "passed", "-", "in", "tokenizer" ]
marcotcr/lime
python
https://github.com/marcotcr/lime/blob/08133d47df00ed918e22005e0c98f6eefd5a1d71/lime/lime_text.py#L182-L199
[ "def", "_segment_with_tokens", "(", "text", ",", "tokens", ")", ":", "list_form", "=", "[", "]", "text_ptr", "=", "0", "for", "token", "in", "tokens", ":", "inter_token_string", "=", "[", "]", "while", "not", "text", "[", "text_ptr", ":", "]", ".", "st...
08133d47df00ed918e22005e0c98f6eefd5a1d71
train
IndexedString.__get_idxs
Returns indexes to appropriate words.
lime/lime_text.py
def __get_idxs(self, words): """Returns indexes to appropriate words.""" if self.bow: return list(itertools.chain.from_iterable( [self.positions[z] for z in words])) else: return self.positions[words]
def __get_idxs(self, words): """Returns indexes to appropriate words.""" if self.bow: return list(itertools.chain.from_iterable( [self.positions[z] for z in words])) else: return self.positions[words]
[ "Returns", "indexes", "to", "appropriate", "words", "." ]
marcotcr/lime
python
https://github.com/marcotcr/lime/blob/08133d47df00ed918e22005e0c98f6eefd5a1d71/lime/lime_text.py#L201-L207
[ "def", "__get_idxs", "(", "self", ",", "words", ")", ":", "if", "self", ".", "bow", ":", "return", "list", "(", "itertools", ".", "chain", ".", "from_iterable", "(", "[", "self", ".", "positions", "[", "z", "]", "for", "z", "in", "words", "]", ")",...
08133d47df00ed918e22005e0c98f6eefd5a1d71
train
LimeTextExplainer.explain_instance
Generates explanations for a prediction. First, we generate neighborhood data by randomly hiding features from the instance (see __data_labels_distance_mapping). We then learn locally weighted linear models on this neighborhood data to explain each of the classes in an interpretable way...
lime/lime_text.py
def explain_instance(self, text_instance, classifier_fn, labels=(1,), top_labels=None, num_features=10, num_samples=5000, distance_metric='cosine...
def explain_instance(self, text_instance, classifier_fn, labels=(1,), top_labels=None, num_features=10, num_samples=5000, distance_metric='cosine...
[ "Generates", "explanations", "for", "a", "prediction", "." ]
marcotcr/lime
python
https://github.com/marcotcr/lime/blob/08133d47df00ed918e22005e0c98f6eefd5a1d71/lime/lime_text.py#L356-L418
[ "def", "explain_instance", "(", "self", ",", "text_instance", ",", "classifier_fn", ",", "labels", "=", "(", "1", ",", ")", ",", "top_labels", "=", "None", ",", "num_features", "=", "10", ",", "num_samples", "=", "5000", ",", "distance_metric", "=", "'cosi...
08133d47df00ed918e22005e0c98f6eefd5a1d71
train
LimeTextExplainer.__data_labels_distances
Generates a neighborhood around a prediction. Generates neighborhood data by randomly removing words from the instance, and predicting with the classifier. Uses cosine distance to compute distances between original and perturbed instances. Args: indexed_string: document (Ind...
lime/lime_text.py
def __data_labels_distances(self, indexed_string, classifier_fn, num_samples, distance_metric='cosine'): """Generates a neighborhood around a prediction. Generates neighborhoo...
def __data_labels_distances(self, indexed_string, classifier_fn, num_samples, distance_metric='cosine'): """Generates a neighborhood around a prediction. Generates neighborhoo...
[ "Generates", "a", "neighborhood", "around", "a", "prediction", "." ]
marcotcr/lime
python
https://github.com/marcotcr/lime/blob/08133d47df00ed918e22005e0c98f6eefd5a1d71/lime/lime_text.py#L420-L469
[ "def", "__data_labels_distances", "(", "self", ",", "indexed_string", ",", "classifier_fn", ",", "num_samples", ",", "distance_metric", "=", "'cosine'", ")", ":", "def", "distance_fn", "(", "x", ")", ":", "return", "sklearn", ".", "metrics", ".", "pairwise", "...
08133d47df00ed918e22005e0c98f6eefd5a1d71
train
TableDomainMapper.map_exp_ids
Maps ids to feature names. Args: exp: list of tuples [(id, weight), (id,weight)] Returns: list of tuples (feature_name, weight)
lime/lime_tabular.py
def map_exp_ids(self, exp): """Maps ids to feature names. Args: exp: list of tuples [(id, weight), (id,weight)] Returns: list of tuples (feature_name, weight) """ names = self.exp_feature_names if self.discretized_feature_names is not None: ...
def map_exp_ids(self, exp): """Maps ids to feature names. Args: exp: list of tuples [(id, weight), (id,weight)] Returns: list of tuples (feature_name, weight) """ names = self.exp_feature_names if self.discretized_feature_names is not None: ...
[ "Maps", "ids", "to", "feature", "names", "." ]
marcotcr/lime
python
https://github.com/marcotcr/lime/blob/08133d47df00ed918e22005e0c98f6eefd5a1d71/lime/lime_tabular.py#L45-L57
[ "def", "map_exp_ids", "(", "self", ",", "exp", ")", ":", "names", "=", "self", ".", "exp_feature_names", "if", "self", ".", "discretized_feature_names", "is", "not", "None", ":", "names", "=", "self", ".", "discretized_feature_names", "return", "[", "(", "na...
08133d47df00ed918e22005e0c98f6eefd5a1d71
train
TableDomainMapper.visualize_instance_html
Shows the current example in a table format. Args: exp: list of tuples [(id, weight), (id,weight)] label: label id (integer) div_name: name of div object to be used for rendering(in js) exp_object_name: name of js explanation object show_table: i...
lime/lime_tabular.py
def visualize_instance_html(self, exp, label, div_name, exp_object_name, show_table=True, show_all=False): """Shows the ...
def visualize_instance_html(self, exp, label, div_name, exp_object_name, show_table=True, show_all=False): """Shows the ...
[ "Shows", "the", "current", "example", "in", "a", "table", "format", "." ]
marcotcr/lime
python
https://github.com/marcotcr/lime/blob/08133d47df00ed918e22005e0c98f6eefd5a1d71/lime/lime_tabular.py#L59-L89
[ "def", "visualize_instance_html", "(", "self", ",", "exp", ",", "label", ",", "div_name", ",", "exp_object_name", ",", "show_table", "=", "True", ",", "show_all", "=", "False", ")", ":", "if", "not", "show_table", ":", "return", "''", "weights", "=", "[", ...
08133d47df00ed918e22005e0c98f6eefd5a1d71
train
LimeTabularExplainer.validate_training_data_stats
Method to validate the structure of training data stats
lime/lime_tabular.py
def validate_training_data_stats(training_data_stats): """ Method to validate the structure of training data stats """ stat_keys = list(training_data_stats.keys()) valid_stat_keys = ["means", "mins", "maxs", "stds", "feature_values", "feature_frequencies"] missing_key...
def validate_training_data_stats(training_data_stats): """ Method to validate the structure of training data stats """ stat_keys = list(training_data_stats.keys()) valid_stat_keys = ["means", "mins", "maxs", "stds", "feature_values", "feature_frequencies"] missing_key...
[ "Method", "to", "validate", "the", "structure", "of", "training", "data", "stats" ]
marcotcr/lime
python
https://github.com/marcotcr/lime/blob/08133d47df00ed918e22005e0c98f6eefd5a1d71/lime/lime_tabular.py#L260-L268
[ "def", "validate_training_data_stats", "(", "training_data_stats", ")", ":", "stat_keys", "=", "list", "(", "training_data_stats", ".", "keys", "(", ")", ")", "valid_stat_keys", "=", "[", "\"means\"", ",", "\"mins\"", ",", "\"maxs\"", ",", "\"stds\"", ",", "\"fe...
08133d47df00ed918e22005e0c98f6eefd5a1d71
train
LimeTabularExplainer.explain_instance
Generates explanations for a prediction. First, we generate neighborhood data by randomly perturbing features from the instance (see __data_inverse). We then learn locally weighted linear models on this neighborhood data to explain each of the classes in an interpretable way (see lime_b...
lime/lime_tabular.py
def explain_instance(self, data_row, predict_fn, labels=(1,), top_labels=None, num_features=10, num_samples=5000, distance_metric='euclidean', ...
def explain_instance(self, data_row, predict_fn, labels=(1,), top_labels=None, num_features=10, num_samples=5000, distance_metric='euclidean', ...
[ "Generates", "explanations", "for", "a", "prediction", "." ]
marcotcr/lime
python
https://github.com/marcotcr/lime/blob/08133d47df00ed918e22005e0c98f6eefd5a1d71/lime/lime_tabular.py#L270-L425
[ "def", "explain_instance", "(", "self", ",", "data_row", ",", "predict_fn", ",", "labels", "=", "(", "1", ",", ")", ",", "top_labels", "=", "None", ",", "num_features", "=", "10", ",", "num_samples", "=", "5000", ",", "distance_metric", "=", "'euclidean'",...
08133d47df00ed918e22005e0c98f6eefd5a1d71
train
LimeTabularExplainer.__data_inverse
Generates a neighborhood around a prediction. For numerical features, perturb them by sampling from a Normal(0,1) and doing the inverse operation of mean-centering and scaling, according to the means and stds in the training data. For categorical features, perturb by sampling according ...
lime/lime_tabular.py
def __data_inverse(self, data_row, num_samples): """Generates a neighborhood around a prediction. For numerical features, perturb them by sampling from a Normal(0,1) and doing the inverse operation of mean-centering and scaling, according to ...
def __data_inverse(self, data_row, num_samples): """Generates a neighborhood around a prediction. For numerical features, perturb them by sampling from a Normal(0,1) and doing the inverse operation of mean-centering and scaling, according to ...
[ "Generates", "a", "neighborhood", "around", "a", "prediction", "." ]
marcotcr/lime
python
https://github.com/marcotcr/lime/blob/08133d47df00ed918e22005e0c98f6eefd5a1d71/lime/lime_tabular.py#L427-L481
[ "def", "__data_inverse", "(", "self", ",", "data_row", ",", "num_samples", ")", ":", "data", "=", "np", ".", "zeros", "(", "(", "num_samples", ",", "data_row", ".", "shape", "[", "0", "]", ")", ")", "categorical_features", "=", "range", "(", "data_row", ...
08133d47df00ed918e22005e0c98f6eefd5a1d71
train
RecurrentTabularExplainer._make_predict_proba
The predict_proba method will expect 3d arrays, but we are reshaping them to 2D so that LIME works correctly. This wraps the function you give in explain_instance to first reshape the data to have the shape the the keras-style network expects.
lime/lime_tabular.py
def _make_predict_proba(self, func): """ The predict_proba method will expect 3d arrays, but we are reshaping them to 2D so that LIME works correctly. This wraps the function you give in explain_instance to first reshape the data to have the shape the the keras-style network expe...
def _make_predict_proba(self, func): """ The predict_proba method will expect 3d arrays, but we are reshaping them to 2D so that LIME works correctly. This wraps the function you give in explain_instance to first reshape the data to have the shape the the keras-style network expe...
[ "The", "predict_proba", "method", "will", "expect", "3d", "arrays", "but", "we", "are", "reshaping", "them", "to", "2D", "so", "that", "LIME", "works", "correctly", ".", "This", "wraps", "the", "function", "you", "give", "in", "explain_instance", "to", "firs...
marcotcr/lime
python
https://github.com/marcotcr/lime/blob/08133d47df00ed918e22005e0c98f6eefd5a1d71/lime/lime_tabular.py#L571-L585
[ "def", "_make_predict_proba", "(", "self", ",", "func", ")", ":", "def", "predict_proba", "(", "X", ")", ":", "n_samples", "=", "X", ".", "shape", "[", "0", "]", "new_shape", "=", "(", "n_samples", ",", "self", ".", "n_features", ",", "self", ".", "n...
08133d47df00ed918e22005e0c98f6eefd5a1d71