code stringlengths 66 870k | docstring stringlengths 19 26.7k | func_name stringlengths 1 138 | language stringclasses 1
value | repo stringlengths 7 68 | path stringlengths 5 324 | url stringlengths 46 389 | license stringclasses 7
values |
|---|---|---|---|---|---|---|---|
def _get_dependencies_dir(self, function_full_path: str) -> Optional[str]:
"""
Returns dependency directory information for function
"""
function_build_definition = self._app_build_result.build_graph.get_function_build_definition_with_full_path(
function_full_path
)
... |
Returns dependency directory information for function
| _get_dependencies_dir | python | aws/aws-sam-cli | samcli/lib/bootstrap/nested_stack/nested_stack_manager.py | https://github.com/aws/aws-sam-cli/blob/master/samcli/lib/bootstrap/nested_stack/nested_stack_manager.py | Apache-2.0 |
def __init__(
self,
resources_to_build: ResourcesToBuildCollector,
build_dir: str,
base_dir: str,
cache_dir: str,
cached: bool = False,
is_building_specific_resource: bool = False,
manifest_path_override: Optional[str] = None,
container_manager: Op... |
Initialize the class
Parameters
----------
resources_to_build: Iterator
Iterator that can vend out resources available in the SAM template
build_dir : str
Path to the directory where we will be storing built artifacts
base_dir : str
P... | __init__ | python | aws/aws-sam-cli | samcli/lib/build/app_builder.py | https://github.com/aws/aws-sam-cli/blob/master/samcli/lib/build/app_builder.py | Apache-2.0 |
def build(self) -> ApplicationBuildResult:
"""
Build the entire application
Returns
-------
ApplicationBuildResult
Returns the build graph and the path to where each resource was built as a map of resource's LogicalId
to the path string
"""
... |
Build the entire application
Returns
-------
ApplicationBuildResult
Returns the build graph and the path to where each resource was built as a map of resource's LogicalId
to the path string
| build | python | aws/aws-sam-cli | samcli/lib/build/app_builder.py | https://github.com/aws/aws-sam-cli/blob/master/samcli/lib/build/app_builder.py | Apache-2.0 |
def _get_build_graph(
self, inline_env_vars: Optional[Dict] = None, env_vars_file: Optional[str] = None
) -> BuildGraph:
"""
Converts list of functions and layers into a build graph, where we can iterate on each unique build and trigger
build
:return: BuildGraph, which repres... |
Converts list of functions and layers into a build graph, where we can iterate on each unique build and trigger
build
:return: BuildGraph, which represents list of unique build definitions
| _get_build_graph | python | aws/aws-sam-cli | samcli/lib/build/app_builder.py | https://github.com/aws/aws-sam-cli/blob/master/samcli/lib/build/app_builder.py | Apache-2.0 |
def update_template(
stack: Stack,
built_artifacts: Dict[str, str],
stack_output_template_path_by_stack_path: Dict[str, str],
) -> Dict:
"""
Given the path to built artifacts, update the template to point appropriate resource CodeUris to the artifacts
folder
... |
Given the path to built artifacts, update the template to point appropriate resource CodeUris to the artifacts
folder
Parameters
----------
stack: Stack
The stack object representing the template
built_artifacts : dict
Map of LogicalId of a resou... | update_template | python | aws/aws-sam-cli | samcli/lib/build/app_builder.py | https://github.com/aws/aws-sam-cli/blob/master/samcli/lib/build/app_builder.py | Apache-2.0 |
def _build_lambda_image(self, function_name: str, metadata: Dict, architecture: str) -> str:
"""
Build an Lambda image
Parameters
----------
function_name str
Name of the function (logical id or function name)
metadata dict
Dictionary representing... |
Build an Lambda image
Parameters
----------
function_name str
Name of the function (logical id or function name)
metadata dict
Dictionary representing the Metadata attached to the Resource in the template
architecture : str
The archit... | _build_lambda_image | python | aws/aws-sam-cli | samcli/lib/build/app_builder.py | https://github.com/aws/aws-sam-cli/blob/master/samcli/lib/build/app_builder.py | Apache-2.0 |
def _stream_lambda_image_build_logs(
self, build_logs: List[Dict[str, str]], function_name: str, throw_on_error: bool = True
) -> None:
"""
Stream logs to the console from an Lambda image build.
Parameters
----------
build_logs generator
A generator for t... |
Stream logs to the console from an Lambda image build.
Parameters
----------
build_logs generator
A generator for the build output.
function_name str
Name of the function that is being built
| _stream_lambda_image_build_logs | python | aws/aws-sam-cli | samcli/lib/build/app_builder.py | https://github.com/aws/aws-sam-cli/blob/master/samcli/lib/build/app_builder.py | Apache-2.0 |
def _build_layer(
self,
layer_name: str,
codeuri: str,
specified_workflow: str,
compatible_runtimes: List[str],
architecture: str,
artifact_dir: str,
container_env_vars: Optional[Dict] = None,
dependencies_dir: Optional[str] = None,
downloa... |
Given the layer information, this method will build the Lambda layer. Depending on the configuration
it will either build the function in process or by spinning up a Docker container.
Parameters
----------
layer_name : str
Name or LogicalId of the function
c... | _build_layer | python | aws/aws-sam-cli | samcli/lib/build/app_builder.py | https://github.com/aws/aws-sam-cli/blob/master/samcli/lib/build/app_builder.py | Apache-2.0 |
def _get_build_options(
function_name: str,
language: str,
base_dir: str,
handler: Optional[str],
dependency_manager: Optional[str] = None,
metadata: Optional[dict] = None,
source_code_path: Optional[str] = None,
scratch_dir: Optional[str] = None,
) ->... |
Parameters
----------
function_name str
current function resource name
language str
language of the runtime
base_dir str
Path to a folder. Use this folder as the root to resolve relative source code paths against
handler str
... | _get_build_options | python | aws/aws-sam-cli | samcli/lib/build/app_builder.py | https://github.com/aws/aws-sam-cli/blob/master/samcli/lib/build/app_builder.py | Apache-2.0 |
def _get_working_directory_path(
base_dir: str, metadata: Optional[Dict], source_code_path: Optional[str], scratch_dir: Optional[str]
) -> Optional[str]:
"""
Get the working directory from the lambda resource metadata information, and check if it is not None, and it
is a child path ... |
Get the working directory from the lambda resource metadata information, and check if it is not None, and it
is a child path to the source directory path, then return the working directory as a child to the scratch
directory.
Parameters
----------
base_dir : str
... | _get_working_directory_path | python | aws/aws-sam-cli | samcli/lib/build/app_builder.py | https://github.com/aws/aws-sam-cli/blob/master/samcli/lib/build/app_builder.py | Apache-2.0 |
def _function_build_definition_to_toml_table(
function_build_definition: "FunctionBuildDefinition",
) -> tomlkit.api.Table:
"""
Converts given function_build_definition into toml table representation
Parameters
----------
function_build_definition: FunctionBuildDefinition
FunctionBuildD... |
Converts given function_build_definition into toml table representation
Parameters
----------
function_build_definition: FunctionBuildDefinition
FunctionBuildDefinition which will be converted into toml table
Returns
-------
tomlkit.api.Table
toml table of FunctionBuildDef... | _function_build_definition_to_toml_table | python | aws/aws-sam-cli | samcli/lib/build/build_graph.py | https://github.com/aws/aws-sam-cli/blob/master/samcli/lib/build/build_graph.py | Apache-2.0 |
def _toml_table_to_function_build_definition(uuid: str, toml_table: tomlkit.api.Table) -> "FunctionBuildDefinition":
"""
Converts given toml table into FunctionBuildDefinition instance
Parameters
----------
uuid: str
key of the function toml_table instance
toml_table: tomlkit.api.Table
... |
Converts given toml table into FunctionBuildDefinition instance
Parameters
----------
uuid: str
key of the function toml_table instance
toml_table: tomlkit.api.Table
function build definition as toml table
Returns
-------
FunctionBuildDefinition
FunctionBuildDe... | _toml_table_to_function_build_definition | python | aws/aws-sam-cli | samcli/lib/build/build_graph.py | https://github.com/aws/aws-sam-cli/blob/master/samcli/lib/build/build_graph.py | Apache-2.0 |
def _layer_build_definition_to_toml_table(layer_build_definition: "LayerBuildDefinition") -> tomlkit.api.Table:
"""
Converts given layer_build_definition into toml table representation
Parameters
----------
layer_build_definition: LayerBuildDefinition
LayerBuildDefinition which will be conv... |
Converts given layer_build_definition into toml table representation
Parameters
----------
layer_build_definition: LayerBuildDefinition
LayerBuildDefinition which will be converted into toml table
Returns
-------
tomlkit.api.Table
toml table of LayerBuildDefinition
| _layer_build_definition_to_toml_table | python | aws/aws-sam-cli | samcli/lib/build/build_graph.py | https://github.com/aws/aws-sam-cli/blob/master/samcli/lib/build/build_graph.py | Apache-2.0 |
def _toml_table_to_layer_build_definition(uuid: str, toml_table: tomlkit.api.Table) -> "LayerBuildDefinition":
"""
Converts given toml table into LayerBuildDefinition instance
Parameters
----------
uuid: str
key of the toml_table instance
toml_table: tomlkit.api.Table
layer bui... |
Converts given toml table into LayerBuildDefinition instance
Parameters
----------
uuid: str
key of the toml_table instance
toml_table: tomlkit.api.Table
layer build definition as toml table
Returns
-------
LayerBuildDefinition
LayerBuildDefinition of given to... | _toml_table_to_layer_build_definition | python | aws/aws-sam-cli | samcli/lib/build/build_graph.py | https://github.com/aws/aws-sam-cli/blob/master/samcli/lib/build/build_graph.py | Apache-2.0 |
def get_function_build_definition_with_full_path(
self, function_full_path: str
) -> Optional["FunctionBuildDefinition"]:
"""
Returns FunctionBuildDefinition instance of given function logical id.
Parameters
----------
function_full_path : str
Function fu... |
Returns FunctionBuildDefinition instance of given function logical id.
Parameters
----------
function_full_path : str
Function full path that will be searched in the function build definitions
Returns
-------
Optional[FunctionBuildDefinition]
... | get_function_build_definition_with_full_path | python | aws/aws-sam-cli | samcli/lib/build/build_graph.py | https://github.com/aws/aws-sam-cli/blob/master/samcli/lib/build/build_graph.py | Apache-2.0 |
def put_function_build_definition(
self, function_build_definition: "FunctionBuildDefinition", function: Function
) -> None:
"""
Puts the newly read function build definition into existing build graph.
If graph already contains a function build definition which is same as the newly p... |
Puts the newly read function build definition into existing build graph.
If graph already contains a function build definition which is same as the newly passed one, then it will add
the function to the existing one, discarding the new one
If graph doesn't contain such unique function ... | put_function_build_definition | python | aws/aws-sam-cli | samcli/lib/build/build_graph.py | https://github.com/aws/aws-sam-cli/blob/master/samcli/lib/build/build_graph.py | Apache-2.0 |
def put_layer_build_definition(self, layer_build_definition: "LayerBuildDefinition", layer: LayerVersion) -> None:
"""
Puts the newly read layer build definition into existing build graph.
If graph already contains a layer build definition which is same as the newly passed one, then it will add
... |
Puts the newly read layer build definition into existing build graph.
If graph already contains a layer build definition which is same as the newly passed one, then it will add
the layer to the existing one, discarding the new one
If graph doesn't contain such unique layer build defini... | put_layer_build_definition | python | aws/aws-sam-cli | samcli/lib/build/build_graph.py | https://github.com/aws/aws-sam-cli/blob/master/samcli/lib/build/build_graph.py | Apache-2.0 |
def clean_redundant_definitions_and_update(self, persist: bool) -> None:
"""
Removes build definitions which doesn't have any function in it, which means these build definitions
are no longer used, and they can be deleted
If persist parameter is given True, build graph is written to .aw... |
Removes build definitions which doesn't have any function in it, which means these build definitions
are no longer used, and they can be deleted
If persist parameter is given True, build graph is written to .aws-sam/build.toml file
| clean_redundant_definitions_and_update | python | aws/aws-sam-cli | samcli/lib/build/build_graph.py | https://github.com/aws/aws-sam-cli/blob/master/samcli/lib/build/build_graph.py | Apache-2.0 |
def update_definition_hash(self) -> None:
"""
Updates the build.toml file with the newest source_hash values of the partial build's definitions
This operation is atomic, that no other thread accesses build.toml
during the process of reading and modifying the hash value
"""
... |
Updates the build.toml file with the newest source_hash values of the partial build's definitions
This operation is atomic, that no other thread accesses build.toml
during the process of reading and modifying the hash value
| update_definition_hash | python | aws/aws-sam-cli | samcli/lib/build/build_graph.py | https://github.com/aws/aws-sam-cli/blob/master/samcli/lib/build/build_graph.py | Apache-2.0 |
def _compare_hash_changes(
input_list: Sequence["AbstractBuildDefinition"], compared_list: Sequence["AbstractBuildDefinition"]
) -> Dict[str, BuildHashingInformation]:
"""
Helper to compare the function and layer definition changes in hash value
Returns a dictionary that has uuid as... |
Helper to compare the function and layer definition changes in hash value
Returns a dictionary that has uuid as key, updated hash value as value
| _compare_hash_changes | python | aws/aws-sam-cli | samcli/lib/build/build_graph.py | https://github.com/aws/aws-sam-cli/blob/master/samcli/lib/build/build_graph.py | Apache-2.0 |
def _write_source_hash(
self, function_content: Dict[str, BuildHashingInformation], layer_content: Dict[str, BuildHashingInformation]
) -> None:
"""
Helper to write source_hash values to build.toml file
"""
if not self._filepath.exists():
open(self._filepath, "a+"... |
Helper to write source_hash values to build.toml file
| _write_source_hash | python | aws/aws-sam-cli | samcli/lib/build/build_graph.py | https://github.com/aws/aws-sam-cli/blob/master/samcli/lib/build/build_graph.py | Apache-2.0 |
def _read(self) -> None:
"""
Reads build.toml file into array of build definition
Each build definition will have empty function list, which will be populated from the current template.yaml file
"""
LOG.debug("Instantiating build definitions")
self._function_build_definit... |
Reads build.toml file into array of build definition
Each build definition will have empty function list, which will be populated from the current template.yaml file
| _read | python | aws/aws-sam-cli | samcli/lib/build/build_graph.py | https://github.com/aws/aws-sam-cli/blob/master/samcli/lib/build/build_graph.py | Apache-2.0 |
def _write(self) -> None:
"""
Writes build definition details into build.toml file, which would be used by the next build.
build.toml file will contain the same information as build graph,
function details will only be preserved as function names
layer details will only be preser... |
Writes build definition details into build.toml file, which would be used by the next build.
build.toml file will contain the same information as build graph,
function details will only be preserved as function names
layer details will only be preserved as layer names
| _write | python | aws/aws-sam-cli | samcli/lib/build/build_graph.py | https://github.com/aws/aws-sam-cli/blob/master/samcli/lib/build/build_graph.py | Apache-2.0 |
def __eq__(self, other: Any) -> bool:
"""
Checks equality of the layer build definition
Parameters
----------
other: Any
other layer build definition to compare
Returns
-------
bool
True if both layer build definitions has same fo... |
Checks equality of the layer build definition
Parameters
----------
other: Any
other layer build definition to compare
Returns
-------
bool
True if both layer build definitions has same following properties, False otherwise
| __eq__ | python | aws/aws-sam-cli | samcli/lib/build/build_graph.py | https://github.com/aws/aws-sam-cli/blob/master/samcli/lib/build/build_graph.py | Apache-2.0 |
def get_build_dir(self, artifact_root_dir: str) -> str:
"""
Return the directory path relative to root build directory
"""
self._validate_functions()
build_dir = self.functions[0].get_build_dir(artifact_root_dir)
if is_experimental_enabled(ExperimentalFlag.BuildPerformanc... |
Return the directory path relative to root build directory
| get_build_dir | python | aws/aws-sam-cli | samcli/lib/build/build_graph.py | https://github.com/aws/aws-sam-cli/blob/master/samcli/lib/build/build_graph.py | Apache-2.0 |
def __eq__(self, other: Any) -> bool:
"""
Checks equality of the function build definition
Parameters
----------
other: Any
other function build definition to compare
Returns
-------
bool
True if both function build definitions ha... |
Checks equality of the function build definition
Parameters
----------
other: Any
other function build definition to compare
Returns
-------
bool
True if both function build definitions has same following properties, False otherwise
... | __eq__ | python | aws/aws-sam-cli | samcli/lib/build/build_graph.py | https://github.com/aws/aws-sam-cli/blob/master/samcli/lib/build/build_graph.py | Apache-2.0 |
def clean_redundant_folders(base_dir: str, uuids: Set[str]) -> None:
"""
Compares existing folders inside base_dir and removes the ones which is not in the uuids set.
Parameters
----------
base_dir : str
Base directory that it will be operating
uuids : Set[str]
Expected folder n... |
Compares existing folders inside base_dir and removes the ones which is not in the uuids set.
Parameters
----------
base_dir : str
Base directory that it will be operating
uuids : Set[str]
Expected folder names. If any folder name in the base_dir is not present in this Set, it will... | clean_redundant_folders | python | aws/aws-sam-cli | samcli/lib/build/build_strategy.py | https://github.com/aws/aws-sam-cli/blob/master/samcli/lib/build/build_strategy.py | Apache-2.0 |
def build(self) -> Dict[str, str]:
"""
Builds all functions and layers in the given build graph
"""
result = {}
with self:
result.update(self._build_layers(self._build_graph))
result.update(self._build_functions(self._build_graph))
return result |
Builds all functions and layers in the given build graph
| build | python | aws/aws-sam-cli | samcli/lib/build/build_strategy.py | https://github.com/aws/aws-sam-cli/blob/master/samcli/lib/build/build_strategy.py | Apache-2.0 |
def _build_functions(self, build_graph: BuildGraph) -> Dict[str, str]:
"""
Iterates through build graph and runs each unique build and copies outcome to the corresponding function folder
"""
function_build_results = {}
for build_definition in build_graph.get_function_build_defini... |
Iterates through build graph and runs each unique build and copies outcome to the corresponding function folder
| _build_functions | python | aws/aws-sam-cli | samcli/lib/build/build_strategy.py | https://github.com/aws/aws-sam-cli/blob/master/samcli/lib/build/build_strategy.py | Apache-2.0 |
def build_single_function_definition(self, build_definition: FunctionBuildDefinition) -> Dict[str, str]:
"""
Builds single function definition and returns dictionary which contains function name as key,
build location as value
""" |
Builds single function definition and returns dictionary which contains function name as key,
build location as value
| build_single_function_definition | python | aws/aws-sam-cli | samcli/lib/build/build_strategy.py | https://github.com/aws/aws-sam-cli/blob/master/samcli/lib/build/build_strategy.py | Apache-2.0 |
def _build_layers(self, build_graph: BuildGraph) -> Dict[str, str]:
"""
Iterates through build graph and runs each unique build and copies outcome to the corresponding layer folder
"""
layer_build_results = {}
for layer_definition in build_graph.get_layer_build_definitions():
... |
Iterates through build graph and runs each unique build and copies outcome to the corresponding layer folder
| _build_layers | python | aws/aws-sam-cli | samcli/lib/build/build_strategy.py | https://github.com/aws/aws-sam-cli/blob/master/samcli/lib/build/build_strategy.py | Apache-2.0 |
def build_single_layer_definition(self, layer_definition: LayerBuildDefinition) -> Dict[str, str]:
"""
Builds single layer definition and returns dictionary which contains layer name as key,
build location as value
""" |
Builds single layer definition and returns dictionary which contains layer name as key,
build location as value
| build_single_layer_definition | python | aws/aws-sam-cli | samcli/lib/build/build_strategy.py | https://github.com/aws/aws-sam-cli/blob/master/samcli/lib/build/build_strategy.py | Apache-2.0 |
def build_single_function_definition(self, build_definition: FunctionBuildDefinition) -> Dict[str, str]:
"""
Build the unique definition and then copy the artifact to the corresponding function folder
"""
function_build_results = {}
LOG.info(
"Building codeuri: %s run... |
Build the unique definition and then copy the artifact to the corresponding function folder
| build_single_function_definition | python | aws/aws-sam-cli | samcli/lib/build/build_strategy.py | https://github.com/aws/aws-sam-cli/blob/master/samcli/lib/build/build_strategy.py | Apache-2.0 |
def build_single_layer_definition(self, layer_definition: LayerBuildDefinition) -> Dict[str, str]:
"""
Build the unique definition and then copy the artifact to the corresponding layer folder
"""
layer = layer_definition.layer
LOG.info("Building layer '%s'", layer.full_path)
... |
Build the unique definition and then copy the artifact to the corresponding layer folder
| build_single_layer_definition | python | aws/aws-sam-cli | samcli/lib/build/build_strategy.py | https://github.com/aws/aws-sam-cli/blob/master/samcli/lib/build/build_strategy.py | Apache-2.0 |
def build_single_function_definition(self, build_definition: FunctionBuildDefinition) -> Dict[str, str]:
"""
Builds single function definition with caching
"""
if build_definition.packagetype == IMAGE:
return self._delegate_build_strategy.build_single_function_definition(buil... |
Builds single function definition with caching
| build_single_function_definition | python | aws/aws-sam-cli | samcli/lib/build/build_strategy.py | https://github.com/aws/aws-sam-cli/blob/master/samcli/lib/build/build_strategy.py | Apache-2.0 |
def build_single_layer_definition(self, layer_definition: LayerBuildDefinition) -> Dict[str, str]:
"""
Builds single layer definition with caching
"""
code_dir = str(pathlib.Path(self._base_dir, cast(str, layer_definition.codeuri)).resolve())
source_hash = dir_checksum(code_dir,... |
Builds single layer definition with caching
| build_single_layer_definition | python | aws/aws-sam-cli | samcli/lib/build/build_strategy.py | https://github.com/aws/aws-sam-cli/blob/master/samcli/lib/build/build_strategy.py | Apache-2.0 |
def _run_builds_async(
build_method: Callable[[FunctionOrLayerBuildDefinition], Dict[str, str]],
build_definitions: Tuple[FunctionOrLayerBuildDefinition, ...],
) -> Dict[str, str]:
"""Builds given list of build definitions in async and return the result"""
if not build_definitions:
... | Builds given list of build definitions in async and return the result | _run_builds_async | python | aws/aws-sam-cli | samcli/lib/build/build_strategy.py | https://github.com/aws/aws-sam-cli/blob/master/samcli/lib/build/build_strategy.py | Apache-2.0 |
def _check_whether_manifest_is_changed(
self,
build_definition: AbstractBuildDefinition,
codeuri: Optional[str],
runtime: Optional[str],
) -> None:
"""
Checks whether the manifest file have been changed by comparing its hash with previously stored one and updates
... |
Checks whether the manifest file have been changed by comparing its hash with previously stored one and updates
download_dependencies property of build definition to True, if it is changed
| _check_whether_manifest_is_changed | python | aws/aws-sam-cli | samcli/lib/build/build_strategy.py | https://github.com/aws/aws-sam-cli/blob/master/samcli/lib/build/build_strategy.py | Apache-2.0 |
def _clean_redundant_dependencies(self) -> None:
"""
Update build definitions with possible new manifest hash information and clean the redundant dependencies folder
"""
uuids = {bd.uuid for bd in self._build_graph.get_function_build_definitions()}
uuids.update({ld.uuid for ld in... |
Update build definitions with possible new manifest hash information and clean the redundant dependencies folder
| _clean_redundant_dependencies | python | aws/aws-sam-cli | samcli/lib/build/build_strategy.py | https://github.com/aws/aws-sam-cli/blob/master/samcli/lib/build/build_strategy.py | Apache-2.0 |
def __exit__(self, exc_type: Any, exc_val: Any, exc_tb: Any) -> None:
"""
After build is complete, this method cleans up redundant folders in cached directory as well as in dependencies
directory. This also updates hashes of the functions and layers, if only single function or layer is been buil... |
After build is complete, this method cleans up redundant folders in cached directory as well as in dependencies
directory. This also updates hashes of the functions and layers, if only single function or layer is been built.
If SAM CLI switched to use only IncrementalBuildStrategy, contents of... | __exit__ | python | aws/aws-sam-cli | samcli/lib/build/build_strategy.py | https://github.com/aws/aws-sam-cli/blob/master/samcli/lib/build/build_strategy.py | Apache-2.0 |
def esbuild_configured(self) -> bool:
"""
Checks if esbuild is configured on any resource in a given stack
:return: True if there is a function instance using esbuild as the build method
"""
function_provider = SamFunctionProvider(
[self._stack], use_raw_codeuri=True,... |
Checks if esbuild is configured on any resource in a given stack
:return: True if there is a function instance using esbuild as the build method
| esbuild_configured | python | aws/aws-sam-cli | samcli/lib/build/bundler.py | https://github.com/aws/aws-sam-cli/blob/master/samcli/lib/build/bundler.py | Apache-2.0 |
def set_sourcemap_metadata_from_env(self) -> Stack:
"""
Checks if sourcemaps are set in lambda environment and updates build metadata accordingly.
:return: Modified stack
"""
modified_stack = deepcopy(self._stack)
using_source_maps = False
stack_resources = modif... |
Checks if sourcemaps are set in lambda environment and updates build metadata accordingly.
:return: Modified stack
| set_sourcemap_metadata_from_env | python | aws/aws-sam-cli | samcli/lib/build/bundler.py | https://github.com/aws/aws-sam-cli/blob/master/samcli/lib/build/bundler.py | Apache-2.0 |
def _set_sourcemap_env_from_metadata(self, template: Dict) -> Dict:
"""
Appends ``NODE_OPTIONS: --enable-source-maps``, if Sourcemap is set to true
and sets Sourcemap to true if ``NODE_OPTIONS: --enable-source-maps`` is provided.
:return: Dict containing deep-copied, updated template
... |
Appends ``NODE_OPTIONS: --enable-source-maps``, if Sourcemap is set to true
and sets Sourcemap to true if ``NODE_OPTIONS: --enable-source-maps`` is provided.
:return: Dict containing deep-copied, updated template
| _set_sourcemap_env_from_metadata | python | aws/aws-sam-cli | samcli/lib/build/bundler.py | https://github.com/aws/aws-sam-cli/blob/master/samcli/lib/build/bundler.py | Apache-2.0 |
def _should_update_handler(self, handler: str, name: str) -> bool:
"""
Function to check if the handler exists in the build dir where we expect it to.
If it does, we won't change the path to prevent introducing breaking changes.
:param handler: handler string as defined in the template.... |
Function to check if the handler exists in the build dir where we expect it to.
If it does, we won't change the path to prevent introducing breaking changes.
:param handler: handler string as defined in the template.
:param name: function name corresponding to function build directory
... | _should_update_handler | python | aws/aws-sam-cli | samcli/lib/build/bundler.py | https://github.com/aws/aws-sam-cli/blob/master/samcli/lib/build/bundler.py | Apache-2.0 |
def _get_path_and_filename_from_handler(handler: str) -> Optional[str]:
"""
Takes a string representation of the handler defined in the
template, returns the file name and location of the handler.
:param handler: string representation of handler property
:return: string path to ... |
Takes a string representation of the handler defined in the
template, returns the file name and location of the handler.
:param handler: string representation of handler property
:return: string path to built handler file
| _get_path_and_filename_from_handler | python | aws/aws-sam-cli | samcli/lib/build/bundler.py | https://github.com/aws/aws-sam-cli/blob/master/samcli/lib/build/bundler.py | Apache-2.0 |
def _update_function_handler(self, template: Dict) -> Dict:
"""
Updates the function handler to point to the actual handler,
not the pre-built handler location.
E.g. pre-build could be codeuri/src/handler/app.lambdaHandler
esbuild would bundle that into .aws-sam/FunctionName/app... |
Updates the function handler to point to the actual handler,
not the pre-built handler location.
E.g. pre-build could be codeuri/src/handler/app.lambdaHandler
esbuild would bundle that into .aws-sam/FunctionName/app.js
:param template: deepcopy of template dict
:return... | _update_function_handler | python | aws/aws-sam-cli | samcli/lib/build/bundler.py | https://github.com/aws/aws-sam-cli/blob/master/samcli/lib/build/bundler.py | Apache-2.0 |
def _is_node_option_set(resource: Dict) -> bool:
"""
Checks if the template has NODE_OPTIONS --enable-source-maps set
Parameters
----------
resource : Dict
The resource dictionary to lookup if --enable-source-maps is set
Returns
-------
bool
... |
Checks if the template has NODE_OPTIONS --enable-source-maps set
Parameters
----------
resource : Dict
The resource dictionary to lookup if --enable-source-maps is set
Returns
-------
bool
True if --enable-source-maps is set, otherwise f... | _is_node_option_set | python | aws/aws-sam-cli | samcli/lib/build/bundler.py | https://github.com/aws/aws-sam-cli/blob/master/samcli/lib/build/bundler.py | Apache-2.0 |
def _warn_invalid_node_options() -> None:
"""
Log warning for invalid node options
"""
LOG.info(
"\nNODE_OPTIONS is not a string! As a result, the NODE_OPTIONS environment variable will "
"not be set correctly, please make sure it is a string. "
"Visit... |
Log warning for invalid node options
| _warn_invalid_node_options | python | aws/aws-sam-cli | samcli/lib/build/bundler.py | https://github.com/aws/aws-sam-cli/blob/master/samcli/lib/build/bundler.py | Apache-2.0 |
def _warn_using_source_maps() -> None:
"""
Log warning telling user that node options will be set
:return:
"""
LOG.info(
"\nYou are using source maps, note that this comes with a performance hit!"
" Set Sourcemap to false and remove"
" NODE_OPT... |
Log warning telling user that node options will be set
:return:
| _warn_using_source_maps | python | aws/aws-sam-cli | samcli/lib/build/bundler.py | https://github.com/aws/aws-sam-cli/blob/master/samcli/lib/build/bundler.py | Apache-2.0 |
def __init__(
self,
code_uri: str,
base_dir: str,
runtime: str,
manifest_path_override: Optional[str] = None,
hash_generator: Any = None,
):
"""
Parameters
----------
code_uri : str
Relative path specified in the function/la... |
Parameters
----------
code_uri : str
Relative path specified in the function/layer resource
base_dir : str
Absolute path which the function/layer dir is located
runtime : str
Runtime of the function/layer
manifest_path_override : Optio... | __init__ | python | aws/aws-sam-cli | samcli/lib/build/dependency_hash_generator.py | https://github.com/aws/aws-sam-cli/blob/master/samcli/lib/build/dependency_hash_generator.py | Apache-2.0 |
def _calculate_dependency_hash(self) -> Optional[str]:
"""Calculate the manifest file hash
Returns
-------
Optional[str]
Returns manifest hash. If manifest does not exist or not supported, None will be returned.
"""
if self._manifest_path_override:
... | Calculate the manifest file hash
Returns
-------
Optional[str]
Returns manifest hash. If manifest does not exist or not supported, None will be returned.
| _calculate_dependency_hash | python | aws/aws-sam-cli | samcli/lib/build/dependency_hash_generator.py | https://github.com/aws/aws-sam-cli/blob/master/samcli/lib/build/dependency_hash_generator.py | Apache-2.0 |
def hash(self) -> Optional[str]:
"""
Returns
-------
Optional[str]
Hash for dependencies in the manifest.
If the manifest does not exist or not supported, this value will be None.
"""
if not self._calculated:
self._hash = self._calculat... |
Returns
-------
Optional[str]
Hash for dependencies in the manifest.
If the manifest does not exist or not supported, this value will be None.
| hash | python | aws/aws-sam-cli | samcli/lib/build/dependency_hash_generator.py | https://github.com/aws/aws-sam-cli/blob/master/samcli/lib/build/dependency_hash_generator.py | Apache-2.0 |
def warn_on_invalid_architecture(layer_definition: LayerBuildDefinition) -> None:
"""
Validate the BuildArchitecture of a LambdaLayer.
Prints corresponding LOG warning if something is invalid.
"""
layer_architecture = layer_definition.architecture
layer_id = layer_definition.layer.layer_id
... |
Validate the BuildArchitecture of a LambdaLayer.
Prints corresponding LOG warning if something is invalid.
| warn_on_invalid_architecture | python | aws/aws-sam-cli | samcli/lib/build/utils.py | https://github.com/aws/aws-sam-cli/blob/master/samcli/lib/build/utils.py | Apache-2.0 |
def _make_env_vars(
resource: Union[Function, LayerVersion], file_env_vars: Dict, inline_env_vars: Optional[Dict]
) -> Dict:
"""Returns the environment variables configuration for this function
Priority order (high to low):
1. Function specific env vars from command line
2. Function specific env va... | Returns the environment variables configuration for this function
Priority order (high to low):
1. Function specific env vars from command line
2. Function specific env vars from json file
3. Global env vars from command line
4. Global env vars from json file
Parameters
----------
reso... | _make_env_vars | python | aws/aws-sam-cli | samcli/lib/build/utils.py | https://github.com/aws/aws-sam-cli/blob/master/samcli/lib/build/utils.py | Apache-2.0 |
def get_selector(
selector_list: List[Dict[str, WorkFlowSelector]],
identifiers: List[Optional[str]],
specified_workflow: Optional[str] = None,
) -> Optional[WorkFlowSelector]:
"""
Determine the correct workflow selector from a list of selectors,
series of identifiers and user specified workflow... |
Determine the correct workflow selector from a list of selectors,
series of identifiers and user specified workflow if defined.
Parameters
----------
selector_list list
List of dictionaries, where the value of all dictionaries are workflow selectors.
identifiers list
List of id... | get_selector | python | aws/aws-sam-cli | samcli/lib/build/workflow_config.py | https://github.com/aws/aws-sam-cli/blob/master/samcli/lib/build/workflow_config.py | Apache-2.0 |
def get_workflow_config(
runtime: Optional[str], code_dir: str, project_dir: str, specified_workflow: Optional[str] = None
) -> CONFIG:
"""
Get a workflow config that corresponds to the runtime provided. This method examines contents of the project
and code directories to determine the most appropriate ... |
Get a workflow config that corresponds to the runtime provided. This method examines contents of the project
and code directories to determine the most appropriate workflow for the given runtime. Currently the decision is
based on the presence of a supported manifest file. For runtimes that have more than ... | get_workflow_config | python | aws/aws-sam-cli | samcli/lib/build/workflow_config.py | https://github.com/aws/aws-sam-cli/blob/master/samcli/lib/build/workflow_config.py | Apache-2.0 |
def supports_specified_workflow(specified_workflow: Optional[str]) -> bool:
"""
Given a specified workflow, returns whether it is supported in container builds,
can be used to overwrite runtime and get docker image or not
Parameters
----------
specified_workflow
Workflow specified in th... |
Given a specified workflow, returns whether it is supported in container builds,
can be used to overwrite runtime and get docker image or not
Parameters
----------
specified_workflow
Workflow specified in the template
Returns
-------
bool
True, if this workflow is supp... | supports_specified_workflow | python | aws/aws-sam-cli | samcli/lib/build/workflow_config.py | https://github.com/aws/aws-sam-cli/blob/master/samcli/lib/build/workflow_config.py | Apache-2.0 |
def get_config(self, code_dir: str, project_dir: str) -> CONFIG:
"""
Finds a configuration by looking for a manifest in the given directories.
Returns
-------
samcli.lib.build.workflow_config.CONFIG
A supported configuration if one is found
Raises
--... |
Finds a configuration by looking for a manifest in the given directories.
Returns
-------
samcli.lib.build.workflow_config.CONFIG
A supported configuration if one is found
Raises
------
ValueError
If none of the supported manifests files... | get_config | python | aws/aws-sam-cli | samcli/lib/build/workflow_config.py | https://github.com/aws/aws-sam-cli/blob/master/samcli/lib/build/workflow_config.py | Apache-2.0 |
def image_repository_validation(support_resolve_image_repos=True):
"""
Wrapper Validation function that will run last after the all cli parmaters have been loaded
to check for conditions surrounding `--image-repository`, `--image-repositories`, and `--resolve-image-repos`. The
reason they are done last ... |
Wrapper Validation function that will run last after the all cli parmaters have been loaded
to check for conditions surrounding `--image-repository`, `--image-repositories`, and `--resolve-image-repos`. The
reason they are done last instead of in callback functions, is because the options depend
on eac... | image_repository_validation | python | aws/aws-sam-cli | samcli/lib/cli_validation/image_repository_validation.py | https://github.com/aws/aws-sam-cli/blob/master/samcli/lib/cli_validation/image_repository_validation.py | Apache-2.0 |
def decorator(func):
"""
Actual decorator implementation for the validation functionality
:param func: Click command function
:return: Click command function after validation
"""
def wrapped(*args, **kwargs):
ctx = click.get_current_context()
gui... |
Actual decorator implementation for the validation functionality
:param func: Click command function
:return: Click command function after validation
| decorator | python | aws/aws-sam-cli | samcli/lib/cli_validation/image_repository_validation.py | https://github.com/aws/aws-sam-cli/blob/master/samcli/lib/cli_validation/image_repository_validation.py | Apache-2.0 |
def _is_all_image_funcs_provided(template_file, image_repositories, parameters_overrides):
"""
Validate that the customer provides ECR repository for every available Lambda function with image package type
"""
image_repositories = image_repositories if image_repositories else {}
global_parameter_ove... |
Validate that the customer provides ECR repository for every available Lambda function with image package type
| _is_all_image_funcs_provided | python | aws/aws-sam-cli | samcli/lib/cli_validation/image_repository_validation.py | https://github.com/aws/aws-sam-cli/blob/master/samcli/lib/cli_validation/image_repository_validation.py | Apache-2.0 |
def event_and_event_file_options_validation(func):
"""
This function validates the cases when both --event and --event-file are provided and
logs if "-" is provided for --event-file and event is read from stdin.
Parameters
----------
func :
Command that would be executed, in this case i... |
This function validates the cases when both --event and --event-file are provided and
logs if "-" is provided for --event-file and event is read from stdin.
Parameters
----------
func :
Command that would be executed, in this case it is 'sam remote invoke'
Returns
-------
... | event_and_event_file_options_validation | python | aws/aws-sam-cli | samcli/lib/cli_validation/remote_invoke_options_validations.py | https://github.com/aws/aws-sam-cli/blob/master/samcli/lib/cli_validation/remote_invoke_options_validations.py | Apache-2.0 |
def stack_name_or_resource_id_atleast_one_option_validation(func):
"""
This function validates that atleast one of --stack-name option or resource_id argument should is be provided
Parameters
----------
func :
Command that would be executed, in this case it is 'sam remote invoke'
Retur... |
This function validates that atleast one of --stack-name option or resource_id argument should is be provided
Parameters
----------
func :
Command that would be executed, in this case it is 'sam remote invoke'
Returns
-------
A wrapper function which will first validate option... | stack_name_or_resource_id_atleast_one_option_validation | python | aws/aws-sam-cli | samcli/lib/cli_validation/remote_invoke_options_validations.py | https://github.com/aws/aws-sam-cli/blob/master/samcli/lib/cli_validation/remote_invoke_options_validations.py | Apache-2.0 |
def read(filepath: Path) -> Any:
"""
Read a TOML file at the given path.
Parameters
----------
filepath: Path
The Path object that points to the file to be read.
Returns
-------
Any
A dictionary-like tomlkit.TOMLDocument object, w... |
Read a TOML file at the given path.
Parameters
----------
filepath: Path
The Path object that points to the file to be read.
Returns
-------
Any
A dictionary-like tomlkit.TOMLDocument object, which represents the contents of the TOML fil... | read | python | aws/aws-sam-cli | samcli/lib/config/file_manager.py | https://github.com/aws/aws-sam-cli/blob/master/samcli/lib/config/file_manager.py | Apache-2.0 |
def write(document: dict, filepath: Path):
"""
Write the contents of a dictionary or tomlkit.TOMLDocument to a TOML file at the provided location.
Parameters
----------
document: dict
The object to write.
filepath: Path
The final location for the ... |
Write the contents of a dictionary or tomlkit.TOMLDocument to a TOML file at the provided location.
Parameters
----------
document: dict
The object to write.
filepath: Path
The final location for the TOML file to be written.
| write | python | aws/aws-sam-cli | samcli/lib/config/file_manager.py | https://github.com/aws/aws-sam-cli/blob/master/samcli/lib/config/file_manager.py | Apache-2.0 |
def put_comment(document: dict, comment: str) -> Any:
"""
Put a comment in a document object.
Parameters
----------
document: Any
The tomlkit.TOMLDocument object to write
comment: str
The comment to include in the document.
Returns
... |
Put a comment in a document object.
Parameters
----------
document: Any
The tomlkit.TOMLDocument object to write
comment: str
The comment to include in the document.
Returns
-------
Any
The new TOMLDocument, with the ... | put_comment | python | aws/aws-sam-cli | samcli/lib/config/file_manager.py | https://github.com/aws/aws-sam-cli/blob/master/samcli/lib/config/file_manager.py | Apache-2.0 |
def read(filepath: Path) -> Any:
"""
Read a YAML file at the given path.
Parameters
----------
filepath: Path
The Path object that points to the file to be read.
Returns
-------
Any
A dictionary-like yaml object, which represents ... |
Read a YAML file at the given path.
Parameters
----------
filepath: Path
The Path object that points to the file to be read.
Returns
-------
Any
A dictionary-like yaml object, which represents the contents of the YAML file at the
... | read | python | aws/aws-sam-cli | samcli/lib/config/file_manager.py | https://github.com/aws/aws-sam-cli/blob/master/samcli/lib/config/file_manager.py | Apache-2.0 |
def write(document: dict, filepath: Path):
"""
Write the contents of a dictionary to a YAML file at the provided location.
Parameters
----------
document: dict
The object to write.
filepath: Path
The final location for the YAML file to be written.... |
Write the contents of a dictionary to a YAML file at the provided location.
Parameters
----------
document: dict
The object to write.
filepath: Path
The final location for the YAML file to be written.
| write | python | aws/aws-sam-cli | samcli/lib/config/file_manager.py | https://github.com/aws/aws-sam-cli/blob/master/samcli/lib/config/file_manager.py | Apache-2.0 |
def put_comment(document: Any, comment: str) -> Any:
"""
Put a comment in a document object.
Parameters
----------
document: Any
The yaml object to write
comment: str
The comment to include in the document.
Returns
-------
... |
Put a comment in a document object.
Parameters
----------
document: Any
The yaml object to write
comment: str
The comment to include in the document.
Returns
-------
Any
The new yaml document, with the comment added t... | put_comment | python | aws/aws-sam-cli | samcli/lib/config/file_manager.py | https://github.com/aws/aws-sam-cli/blob/master/samcli/lib/config/file_manager.py | Apache-2.0 |
def _to_yaml(document: dict) -> Any:
"""
Ensure a dictionary-like object is a YAML document.
Parameters
----------
document: dict
A dictionary-like object to parse.
Returns
-------
Any
A dictionary-like YAML object, as derived fro... |
Ensure a dictionary-like object is a YAML document.
Parameters
----------
document: dict
A dictionary-like object to parse.
Returns
-------
Any
A dictionary-like YAML object, as derived from `yaml.load()`.
| _to_yaml | python | aws/aws-sam-cli | samcli/lib/config/file_manager.py | https://github.com/aws/aws-sam-cli/blob/master/samcli/lib/config/file_manager.py | Apache-2.0 |
def read(filepath: Path) -> Any:
"""
Read a JSON file at a given path.
Parameters
----------
filepath: Path
The Path object that points to the file to be read.
Returns
-------
Any
A dictionary representation of the contents of the... |
Read a JSON file at a given path.
Parameters
----------
filepath: Path
The Path object that points to the file to be read.
Returns
-------
Any
A dictionary representation of the contents of the JSON document.
| read | python | aws/aws-sam-cli | samcli/lib/config/file_manager.py | https://github.com/aws/aws-sam-cli/blob/master/samcli/lib/config/file_manager.py | Apache-2.0 |
def write(document: dict, filepath: Path):
"""
Write a dictionary or dictionary-like object to a JSON file.
Parameters
----------
document: dict
The JSON object to write.
filepath: Path
The final location for the document to be written.
""... |
Write a dictionary or dictionary-like object to a JSON file.
Parameters
----------
document: dict
The JSON object to write.
filepath: Path
The final location for the document to be written.
| write | python | aws/aws-sam-cli | samcli/lib/config/file_manager.py | https://github.com/aws/aws-sam-cli/blob/master/samcli/lib/config/file_manager.py | Apache-2.0 |
def __init__(self, config_dir, filename=None):
"""
Initialize the class
Parameters
----------
config_dir : string
Directory where the configuration file needs to be stored
filename : string
Optional. Name of the configuration file. It is recommend... |
Initialize the class
Parameters
----------
config_dir : string
Directory where the configuration file needs to be stored
filename : string
Optional. Name of the configuration file. It is recommended to stick with default so in the future we
c... | __init__ | python | aws/aws-sam-cli | samcli/lib/config/samconfig.py | https://github.com/aws/aws-sam-cli/blob/master/samcli/lib/config/samconfig.py | Apache-2.0 |
def get_all(self, cmd_names, section, env=DEFAULT_ENV):
"""
Gets a value from the configuration file for the given environment, command and section
Parameters
----------
cmd_names : list(str)
List of representing the entire command. Ex: ["local", "generate-event", "s... |
Gets a value from the configuration file for the given environment, command and section
Parameters
----------
cmd_names : list(str)
List of representing the entire command. Ex: ["local", "generate-event", "s3", "put"]
section : str
Specific section withi... | get_all | python | aws/aws-sam-cli | samcli/lib/config/samconfig.py | https://github.com/aws/aws-sam-cli/blob/master/samcli/lib/config/samconfig.py | Apache-2.0 |
def put(self, cmd_names, section, key, value, env=DEFAULT_ENV):
"""
Writes the `key=value` under the given section. You have to call the `flush()` method after `put()` in
order to write the values back to the config file. Otherwise they will be just saved in-memory, available
for future ... |
Writes the `key=value` under the given section. You have to call the `flush()` method after `put()` in
order to write the values back to the config file. Otherwise they will be just saved in-memory, available
for future access, but never saved back to the file.
Parameters
-----... | put | python | aws/aws-sam-cli | samcli/lib/config/samconfig.py | https://github.com/aws/aws-sam-cli/blob/master/samcli/lib/config/samconfig.py | Apache-2.0 |
def sanity_check(self):
"""
Sanity check the contents of samconfig
"""
try:
self._read()
except SamConfigFileReadException:
return False
else:
return True |
Sanity check the contents of samconfig
| sanity_check | python | aws/aws-sam-cli | samcli/lib/config/samconfig.py | https://github.com/aws/aws-sam-cli/blob/master/samcli/lib/config/samconfig.py | Apache-2.0 |
def config_dir(template_file_path=None):
"""
SAM Config file is always relative to the SAM Template. If it the template is not
given, then it is relative to cwd()
"""
if template_file_path:
return os.path.dirname(template_file_path)
return os.getcwd() |
SAM Config file is always relative to the SAM Template. If it the template is not
given, then it is relative to cwd()
| config_dir | python | aws/aws-sam-cli | samcli/lib/config/samconfig.py | https://github.com/aws/aws-sam-cli/blob/master/samcli/lib/config/samconfig.py | Apache-2.0 |
def _deduplicate_global_parameters(self, cmd_name_key, section, key, env=DEFAULT_ENV):
"""
In case the global parameters contains the same key-value pair with command parameters,
we only keep the entry in global parameters
Parameters
----------
cmd_name_key : str
... |
In case the global parameters contains the same key-value pair with command parameters,
we only keep the entry in global parameters
Parameters
----------
cmd_name_key : str
key of command name
section : str
Specific section within the command to... | _deduplicate_global_parameters | python | aws/aws-sam-cli | samcli/lib/config/samconfig.py | https://github.com/aws/aws-sam-cli/blob/master/samcli/lib/config/samconfig.py | Apache-2.0 |
def get_default_file(config_dir: str) -> str:
"""Return a defaultly-named config file, if it exists, otherwise the current default.
Parameters
----------
config_dir: str
The name of the directory where the config file is/will be stored.
Returns
-------
... | Return a defaultly-named config file, if it exists, otherwise the current default.
Parameters
----------
config_dir: str
The name of the directory where the config file is/will be stored.
Returns
-------
str
The name of the config file found, if ... | get_default_file | python | aws/aws-sam-cli | samcli/lib/config/samconfig.py | https://github.com/aws/aws-sam-cli/blob/master/samcli/lib/config/samconfig.py | Apache-2.0 |
def advance_to_next_question(self, current_answer: Optional[Any] = None) -> Optional[Question]:
"""
Based on the answer of the current question, what is the next question to ask.
Parameters
----------
current_answer: str
User's answer of the current question. This ca... |
Based on the answer of the current question, what is the next question to ask.
Parameters
----------
current_answer: str
User's answer of the current question. This can be None of this is the first question or an optional
question and the user didn't provide an ... | advance_to_next_question | python | aws/aws-sam-cli | samcli/lib/cookiecutter/interactive_flow.py | https://github.com/aws/aws-sam-cli/blob/master/samcli/lib/cookiecutter/interactive_flow.py | Apache-2.0 |
def run(
self,
context: Dict,
) -> Dict:
"""
starts the flow, collects user's answers to the question and return a new copy of the passed context
with the answers appended to the copy
Parameters
----------
context: Dict
The cookiecutter co... |
starts the flow, collects user's answers to the question and return a new copy of the passed context
with the answers appended to the copy
Parameters
----------
context: Dict
The cookiecutter context before prompting this flow's questions
The context can... | run | python | aws/aws-sam-cli | samcli/lib/cookiecutter/interactive_flow.py | https://github.com/aws/aws-sam-cli/blob/master/samcli/lib/cookiecutter/interactive_flow.py | Apache-2.0 |
def create_flow(flow_definition_path: str, extra_context: Optional[Dict] = None) -> InteractiveFlow:
"""
This method parses the given json/yaml file to create an InteractiveFLow. It expects the file to define
a list of questions. It parses the questions and add it to the flow in the same order t... |
This method parses the given json/yaml file to create an InteractiveFLow. It expects the file to define
a list of questions. It parses the questions and add it to the flow in the same order they are defined
in the file, i.e. the default next-question of a given question will be the next one def... | create_flow | python | aws/aws-sam-cli | samcli/lib/cookiecutter/interactive_flow_creator.py | https://github.com/aws/aws-sam-cli/blob/master/samcli/lib/cookiecutter/interactive_flow_creator.py | Apache-2.0 |
def _parse_questions_definition(file_path: str, extra_context: Optional[Dict] = None) -> Dict:
"""
Read the questions definition file, do variable substitution, parse it as JSON/YAML
Parameters
----------
file_path : string
Path to the questions definition to read
... |
Read the questions definition file, do variable substitution, parse it as JSON/YAML
Parameters
----------
file_path : string
Path to the questions definition to read
extra_context : Dict
if the file contains variable($variableName) this parameter provide... | _parse_questions_definition | python | aws/aws-sam-cli | samcli/lib/cookiecutter/interactive_flow_creator.py | https://github.com/aws/aws-sam-cli/blob/master/samcli/lib/cookiecutter/interactive_flow_creator.py | Apache-2.0 |
def run(self, context: Dict) -> Dict:
"""
the processing logic of this processor
Parameters
----------
context: Dict
The cookiecutter context to process
Returns: A processed copy of the cookiecutter context
""" |
the processing logic of this processor
Parameters
----------
context: Dict
The cookiecutter context to process
Returns: A processed copy of the cookiecutter context
| run | python | aws/aws-sam-cli | samcli/lib/cookiecutter/processor.py | https://github.com/aws/aws-sam-cli/blob/master/samcli/lib/cookiecutter/processor.py | Apache-2.0 |
def ask(self, context: Optional[Dict] = None) -> Any:
"""
prompt the user this question
Parameters
----------
context
The cookiecutter context dictionary containing previous questions' answers and default values
Returns
-------
The user provi... |
prompt the user this question
Parameters
----------
context
The cookiecutter context dictionary containing previous questions' answers and default values
Returns
-------
The user provided answer.
| ask | python | aws/aws-sam-cli | samcli/lib/cookiecutter/question.py | https://github.com/aws/aws-sam-cli/blob/master/samcli/lib/cookiecutter/question.py | Apache-2.0 |
def _resolve_key_path(self, key_path: List, context: Dict) -> List[str]:
"""
key_path element is a list of str and Dict.
When the element is a dict, in the form of { "valueOf": question_key },
it means it refers to the answer to another questions.
_resolve_key_path() will replace... |
key_path element is a list of str and Dict.
When the element is a dict, in the form of { "valueOf": question_key },
it means it refers to the answer to another questions.
_resolve_key_path() will replace such dict with the actual question answer
Parameters
----------
... | _resolve_key_path | python | aws/aws-sam-cli | samcli/lib/cookiecutter/question.py | https://github.com/aws/aws-sam-cli/blob/master/samcli/lib/cookiecutter/question.py | Apache-2.0 |
def _resolve_value_from_expression(self, expression: Any, context: Optional[Dict] = None) -> Optional[Any]:
"""
a question may have a value provided directly as string or number value
or indirectly from cookiecutter context using a key path
Parameters
----------
context
... |
a question may have a value provided directly as string or number value
or indirectly from cookiecutter context using a key path
Parameters
----------
context
Cookiecutter context used to resolve values.
Raises
------
KeyError
Wh... | _resolve_value_from_expression | python | aws/aws-sam-cli | samcli/lib/cookiecutter/question.py | https://github.com/aws/aws-sam-cli/blob/master/samcli/lib/cookiecutter/question.py | Apache-2.0 |
def __init__(
self,
location: str,
interactive_flows: Optional[List[InteractiveFlow]] = None,
preprocessors: Optional[List[Processor]] = None,
postprocessors: Optional[List[Processor]] = None,
plugins: Optional[List[Plugin]] = None,
metadata: Optional[Dict] = None... |
Initialize the class
Parameters
----------
location: str
Template location (git, mercurial, http(s), path)
interactive_flows: Optional[List[InteractiveFlow]]
An optional series of interactive questions to be asked to the user where the answers are used t... | __init__ | python | aws/aws-sam-cli | samcli/lib/cookiecutter/template.py | https://github.com/aws/aws-sam-cli/blob/master/samcli/lib/cookiecutter/template.py | Apache-2.0 |
def run_interactive_flows(self, context: Optional[Dict] = None) -> Dict:
"""
prompt the user a series of questions' flows and gather the answers to create the cookiecutter context.
The questions are identified by keys. If multiple questions, whether within the same flow or across
differe... |
prompt the user a series of questions' flows and gather the answers to create the cookiecutter context.
The questions are identified by keys. If multiple questions, whether within the same flow or across
different flows, have the same key, the last question will override the others and we will ... | run_interactive_flows | python | aws/aws-sam-cli | samcli/lib/cookiecutter/template.py | https://github.com/aws/aws-sam-cli/blob/master/samcli/lib/cookiecutter/template.py | Apache-2.0 |
def generate_project(self, context: Dict, output_dir: str) -> None:
"""
Generates a project based on this cookiecutter template and the given context. The context is first
processed and manipulated by series of preprocessors(if any) then the project is generated and finally
the series of... |
Generates a project based on this cookiecutter template and the given context. The context is first
processed and manipulated by series of preprocessors(if any) then the project is generated and finally
the series of postprocessors(if any) are executed.
Parameters
----------
... | generate_project | python | aws/aws-sam-cli | samcli/lib/cookiecutter/template.py | https://github.com/aws/aws-sam-cli/blob/master/samcli/lib/cookiecutter/template.py | Apache-2.0 |
def can_delete_stack(self, stack_name: str) -> bool:
"""
Checks if a CloudFormation stack with given name exists
Parameters
----------
stack_name: str
Name or ID of the stack
Returns
-------
bool
True if stack exists. False otherw... |
Checks if a CloudFormation stack with given name exists
Parameters
----------
stack_name: str
Name or ID of the stack
Returns
-------
bool
True if stack exists. False otherwise
Raises
------
StackFetchError
... | can_delete_stack | python | aws/aws-sam-cli | samcli/lib/delete/cfn_utils.py | https://github.com/aws/aws-sam-cli/blob/master/samcli/lib/delete/cfn_utils.py | Apache-2.0 |
def get_stack_template(self, stack_name: str, stage: str) -> str:
"""
Return the Cloudformation template of the given stack_name
Parameters
----------
stack_name: str
Name or ID of the stack
stage: str
The Stage of the template Original or Proces... |
Return the Cloudformation template of the given stack_name
Parameters
----------
stack_name: str
Name or ID of the stack
stage: str
The Stage of the template Original or Processed
Returns
-------
str
Template body of... | get_stack_template | python | aws/aws-sam-cli | samcli/lib/delete/cfn_utils.py | https://github.com/aws/aws-sam-cli/blob/master/samcli/lib/delete/cfn_utils.py | Apache-2.0 |
def delete_stack(self, stack_name: str, retain_resources: Optional[List] = None):
"""
Delete the Cloudformation stack with the given stack_name
Parameters
----------
stack_name:
str Name or ID of the stack
retain_resources: Optional[List]
List of ... |
Delete the Cloudformation stack with the given stack_name
Parameters
----------
stack_name:
str Name or ID of the stack
retain_resources: Optional[List]
List of repositories to retain if the stack has DELETE_FAILED status.
Raises
------
... | delete_stack | python | aws/aws-sam-cli | samcli/lib/delete/cfn_utils.py | https://github.com/aws/aws-sam-cli/blob/master/samcli/lib/delete/cfn_utils.py | Apache-2.0 |
def wait_for_delete(self, stack_name: str):
"""
Waits until the delete stack completes
Parameter
---------
stack_name: str
The name of the stack to watch when deleting
Raises
------
CfDeleteFailedStatusError
Raised when the stack ... |
Waits until the delete stack completes
Parameter
---------
stack_name: str
The name of the stack to watch when deleting
Raises
------
CfDeleteFailedStatusError
Raised when the stack fails to delete
DeleteFailedError
R... | wait_for_delete | python | aws/aws-sam-cli | samcli/lib/delete/cfn_utils.py | https://github.com/aws/aws-sam-cli/blob/master/samcli/lib/delete/cfn_utils.py | Apache-2.0 |
def _get_change_set_name(self, stack_name: str) -> str:
"""
Returns the name of the change set for a stack
Parameters
----------
stack_name: str
The name of the stack to find a change set
Returns
-------
str
The name of a change s... |
Returns the name of the change set for a stack
Parameters
----------
stack_name: str
The name of the stack to find a change set
Returns
-------
str
The name of a change set
Raises
------
FetchChangeSetError
... | _get_change_set_name | python | aws/aws-sam-cli | samcli/lib/delete/cfn_utils.py | https://github.com/aws/aws-sam-cli/blob/master/samcli/lib/delete/cfn_utils.py | Apache-2.0 |
def has_stack(self, stack_name):
"""
Checks if a CloudFormation stack with given name exists
:param stack_name: Name or ID of the stack
:return: True if stack exists. False otherwise
"""
try:
resp = self._client.describe_stacks(StackName=stack_name)
... |
Checks if a CloudFormation stack with given name exists
:param stack_name: Name or ID of the stack
:return: True if stack exists. False otherwise
| has_stack | python | aws/aws-sam-cli | samcli/lib/deploy/deployer.py | https://github.com/aws/aws-sam-cli/blob/master/samcli/lib/deploy/deployer.py | Apache-2.0 |
def create_changeset(
self, stack_name, cfn_template, parameter_values, capabilities, role_arn, notification_arns, s3_uploader, tags
):
"""
Call Cloudformation to create a changeset and wait for it to complete
:param stack_name: Name or ID of stack
:param cfn_template: Cloud... |
Call Cloudformation to create a changeset and wait for it to complete
:param stack_name: Name or ID of stack
:param cfn_template: CloudFormation template string
:param parameter_values: Template parameters object
:param capabilities: Array of capabilities passed to CloudFormati... | create_changeset | python | aws/aws-sam-cli | samcli/lib/deploy/deployer.py | https://github.com/aws/aws-sam-cli/blob/master/samcli/lib/deploy/deployer.py | Apache-2.0 |
def describe_changeset(self, change_set_id, stack_name, **kwargs):
"""
Call Cloudformation to describe a changeset
:param change_set_id: ID of the changeset
:param stack_name: Name of the CloudFormation stack
:param kwargs: Other arguments to pass to pprint_columns()
:re... |
Call Cloudformation to describe a changeset
:param change_set_id: ID of the changeset
:param stack_name: Name of the CloudFormation stack
:param kwargs: Other arguments to pass to pprint_columns()
:return: dictionary of changes described in the changeset.
| describe_changeset | python | aws/aws-sam-cli | samcli/lib/deploy/deployer.py | https://github.com/aws/aws-sam-cli/blob/master/samcli/lib/deploy/deployer.py | Apache-2.0 |
def wait_for_changeset(self, changeset_id, stack_name):
"""
Waits until the changeset creation completes
:param changeset_id: ID or name of the changeset
:param stack_name: Stack name
"""
sys.stdout.write("\n\nWaiting for changeset to be created..\n\n")
sys.std... |
Waits until the changeset creation completes
:param changeset_id: ID or name of the changeset
:param stack_name: Stack name
| wait_for_changeset | python | aws/aws-sam-cli | samcli/lib/deploy/deployer.py | https://github.com/aws/aws-sam-cli/blob/master/samcli/lib/deploy/deployer.py | Apache-2.0 |
def execute_changeset(self, changeset_id, stack_name, disable_rollback):
"""
Calls CloudFormation to execute changeset
:param changeset_id: ID of the changeset
:param stack_name: Name or ID of the stack
:param disable_rollback: Preserve the state of previously provisioned resour... |
Calls CloudFormation to execute changeset
:param changeset_id: ID of the changeset
:param stack_name: Name or ID of the stack
:param disable_rollback: Preserve the state of previously provisioned resources when an operation fails.
| execute_changeset | python | aws/aws-sam-cli | samcli/lib/deploy/deployer.py | https://github.com/aws/aws-sam-cli/blob/master/samcli/lib/deploy/deployer.py | Apache-2.0 |
Subsets and Splits
Django Code with Docstrings
Filters Python code examples from Django repository that contain Django-related code, helping identify relevant code snippets for understanding Django framework usage patterns.
SQL Console for Shuu12121/python-treesitter-filtered-datasetsV2
Retrieves specific code examples from the Flask repository but doesn't provide meaningful analysis or patterns beyond basic data retrieval.
HTTPX Repo Code and Docstrings
Retrieves specific code examples from the httpx repository, which is useful for understanding how particular libraries are used but doesn't provide broader analytical insights about the dataset.
Requests Repo Docstrings & Code
Retrieves code examples with their docstrings and file paths from the requests repository, providing basic filtering but limited analytical value beyond finding specific code samples.
Quart Repo Docstrings & Code
Retrieves code examples with their docstrings from the Quart repository, providing basic code samples but offering limited analytical value for understanding broader patterns or relationships in the dataset.