id
int32
0
252k
repo
stringlengths
7
55
path
stringlengths
4
127
func_name
stringlengths
1
88
original_string
stringlengths
75
19.8k
language
stringclasses
1 value
code
stringlengths
75
19.8k
code_tokens
list
docstring
stringlengths
3
17.3k
docstring_tokens
list
sha
stringlengths
40
40
url
stringlengths
87
242
30,000
awslabs/aws-sam-cli
samcli/commands/local/lib/local_lambda.py
LocalLambdaRunner._make_env_vars
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...
python
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", ")", ":", "name", "=", "function", ".", "name", "variables", "=", "None", "if", "function", ".", "environment", "and", "isinstance", "(", "function", ".", "environment", ",", "dict", ")", "and", "\"Var...
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...
[ "Returns", "the", "environment", "variables", "configuration", "for", "this", "function" ]
c05af5e7378c6f05f7d82ad3f0bca17204177db6
https://github.com/awslabs/aws-sam-cli/blob/c05af5e7378c6f05f7d82ad3f0bca17204177db6/samcli/commands/local/lib/local_lambda.py#L133-L193
30,001
awslabs/aws-sam-cli
samcli/commands/local/lib/local_lambda.py
LocalLambdaRunner.get_aws_creds
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...
python
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", ")", ":", "result", "=", "{", "}", "# to pass command line arguments for region & profile to setup boto3 default session", "if", "boto3", ".", "DEFAULT_SESSION", ":", "session", "=", "boto3", ".", "DEFAULT_SESSION", "else", ":", "ses...
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
[ "Returns", "AWS", "credentials", "obtained", "from", "the", "shell", "environment", "or", "given", "profile" ]
c05af5e7378c6f05f7d82ad3f0bca17204177db6
https://github.com/awslabs/aws-sam-cli/blob/c05af5e7378c6f05f7d82ad3f0bca17204177db6/samcli/commands/local/lib/local_lambda.py#L195-L238
30,002
awslabs/aws-sam-cli
samcli/local/events/api_event.py
ContextIdentity.to_dict
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...
python
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", ")", ":", "json_dict", "=", "{", "\"apiKey\"", ":", "self", ".", "api_key", ",", "\"userArn\"", ":", "self", ".", "user_arn", ",", "\"cognitoAuthenticationType\"", ":", "self", ".", "cognito_authentication_type", ",", "\"caller\"",...
Constructs an dictionary representation of the Identity Object to be used in serializing to JSON :return: dict representing the object
[ "Constructs", "an", "dictionary", "representation", "of", "the", "Identity", "Object", "to", "be", "used", "in", "serializing", "to", "JSON" ]
c05af5e7378c6f05f7d82ad3f0bca17204177db6
https://github.com/awslabs/aws-sam-cli/blob/c05af5e7378c6f05f7d82ad3f0bca17204177db6/samcli/local/events/api_event.py#L42-L60
30,003
awslabs/aws-sam-cli
samcli/local/events/api_event.py
RequestContext.to_dict
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_...
python
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", ")", ":", "identity_dict", "=", "{", "}", "if", "self", ".", "identity", ":", "identity_dict", "=", "self", ".", "identity", ".", "to_dict", "(", ")", "json_dict", "=", "{", "\"resourceId\"", ":", "self", ".", "resource_id"...
Constructs an dictionary representation of the RequestContext Object to be used in serializing to JSON :return: dict representing the object
[ "Constructs", "an", "dictionary", "representation", "of", "the", "RequestContext", "Object", "to", "be", "used", "in", "serializing", "to", "JSON" ]
c05af5e7378c6f05f7d82ad3f0bca17204177db6
https://github.com/awslabs/aws-sam-cli/blob/c05af5e7378c6f05f7d82ad3f0bca17204177db6/samcli/local/events/api_event.py#L102-L124
30,004
awslabs/aws-sam-cli
samcli/local/events/api_event.py
ApiGatewayLambdaEvent.to_dict
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...
python
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", ")", ":", "request_context_dict", "=", "{", "}", "if", "self", ".", "request_context", ":", "request_context_dict", "=", "self", ".", "request_context", ".", "to_dict", "(", ")", "json_dict", "=", "{", "\"httpMethod\"", ":", "s...
Constructs an dictionary representation of the ApiGatewayLambdaEvent Object to be used in serializing to JSON :return: dict representing the object
[ "Constructs", "an", "dictionary", "representation", "of", "the", "ApiGatewayLambdaEvent", "Object", "to", "be", "used", "in", "serializing", "to", "JSON" ]
c05af5e7378c6f05f7d82ad3f0bca17204177db6
https://github.com/awslabs/aws-sam-cli/blob/c05af5e7378c6f05f7d82ad3f0bca17204177db6/samcli/local/events/api_event.py#L179-L201
30,005
awslabs/aws-sam-cli
samcli/local/docker/manager.py
ContainerManager.is_docker_reachable
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() ...
python
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", ")", ":", "try", ":", "self", ".", "docker_client", ".", "ping", "(", ")", "return", "True", "# When Docker is not installed, a request.exceptions.ConnectionError is thrown.", "except", "(", "docker", ".", "errors", ".", "API...
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
[ "Checks", "if", "Docker", "daemon", "is", "running", ".", "This", "is", "required", "for", "us", "to", "invoke", "the", "function", "locally" ]
c05af5e7378c6f05f7d82ad3f0bca17204177db6
https://github.com/awslabs/aws-sam-cli/blob/c05af5e7378c6f05f7d82ad3f0bca17204177db6/samcli/local/docker/manager.py#L40-L57
30,006
awslabs/aws-sam-cli
samcli/local/docker/manager.py
ContainerManager.run
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...
python
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", ")", ":", "if", "warm", ":", "raise", "ValueError", "(", "\"The facility to invoke warm container does not exist\"", ")", "image_name", "=", "container", ".",...
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...
[ "Create", "and", "run", "a", "Docker", "container", "based", "on", "the", "given", "configuration", "." ]
c05af5e7378c6f05f7d82ad3f0bca17204177db6
https://github.com/awslabs/aws-sam-cli/blob/c05af5e7378c6f05f7d82ad3f0bca17204177db6/samcli/local/docker/manager.py#L59-L98
30,007
awslabs/aws-sam-cli
samcli/local/docker/manager.py
ContainerManager.pull_image
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...
python
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", ")", ":", "stream_writer", "=", "stream", "or", "StreamWriter", "(", "sys", ".", "stderr", ")", "try", ":", "result_itr", "=", "self", ".", "docker_client", ".", "api", ".",...
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...
[ "Ask", "Docker", "to", "pull", "the", "container", "image", "with", "given", "name", "." ]
c05af5e7378c6f05f7d82ad3f0bca17204177db6
https://github.com/awslabs/aws-sam-cli/blob/c05af5e7378c6f05f7d82ad3f0bca17204177db6/samcli/local/docker/manager.py#L108-L142
30,008
awslabs/aws-sam-cli
samcli/local/docker/manager.py
ContainerManager.has_image
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...
python
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", ")", ":", "try", ":", "self", ".", "docker_client", ".", "images", ".", "get", "(", "image_name", ")", "return", "True", "except", "docker", ".", "errors", ".", "ImageNotFound", ":", "return", "False" ]
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
[ "Is", "the", "container", "image", "with", "given", "name", "available?" ]
c05af5e7378c6f05f7d82ad3f0bca17204177db6
https://github.com/awslabs/aws-sam-cli/blob/c05af5e7378c6f05f7d82ad3f0bca17204177db6/samcli/local/docker/manager.py#L144-L156
30,009
awslabs/aws-sam-cli
samcli/commands/publish/command.py
do_cli
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...
python
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", ")", ":", "try", ":", "template_data", "=", "get_template_data", "(", "template", ")", "except", "ValueError", "as", "ex", ":", "click", ".", "secho", "(", "\"Publish Failed\"", ",", "fg"...
Publish the application based on command line inputs.
[ "Publish", "the", "application", "based", "on", "command", "line", "inputs", "." ]
c05af5e7378c6f05f7d82ad3f0bca17204177db6
https://github.com/awslabs/aws-sam-cli/blob/c05af5e7378c6f05f7d82ad3f0bca17204177db6/samcli/commands/publish/command.py#L55-L83
30,010
awslabs/aws-sam-cli
samcli/commands/publish/command.py
_gen_success_message
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...
python
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", ")", ":", "application_id", "=", "publish_output", ".", "get", "(", "'application_id'", ")", "details", "=", "json", ".", "dumps", "(", "publish_output", ".", "get", "(", "'details'", ")", ",", "indent", "=...
Generate detailed success message for published applications. Parameters ---------- publish_output : dict Output from serverlessrepo publish_application Returns ------- str Detailed success message
[ "Generate", "detailed", "success", "message", "for", "published", "applications", "." ]
c05af5e7378c6f05f7d82ad3f0bca17204177db6
https://github.com/awslabs/aws-sam-cli/blob/c05af5e7378c6f05f7d82ad3f0bca17204177db6/samcli/commands/publish/command.py#L86-L106
30,011
awslabs/aws-sam-cli
samcli/commands/publish/command.py
_print_console_link
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...
python
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", ")", ":", "if", "not", "region", ":", "region", "=", "boto3", ".", "Session", "(", ")", ".", "region_name", "console_link", "=", "SERVERLESSREPO_CONSOLE_URL", ".", "format", "(", "region", ","...
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
[ "Print", "link", "for", "the", "application", "in", "AWS", "Serverless", "Application", "Repository", "console", "." ]
c05af5e7378c6f05f7d82ad3f0bca17204177db6
https://github.com/awslabs/aws-sam-cli/blob/c05af5e7378c6f05f7d82ad3f0bca17204177db6/samcli/commands/publish/command.py#L109-L126
30,012
awslabs/aws-sam-cli
samcli/local/apigw/service_error_responses.py
ServiceErrorResponses.lambda_failure_response
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)
python
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", ")", ":", "response_data", "=", "jsonify", "(", "ServiceErrorResponses", ".", "_LAMBDA_FAILURE", ")", "return", "make_response", "(", "response_data", ",", "ServiceErrorResponses", ".", "HTTP_STATUS_CODE_502", ")" ]
Helper function to create a Lambda Failure Response :return: A Flask Response
[ "Helper", "function", "to", "create", "a", "Lambda", "Failure", "Response" ]
c05af5e7378c6f05f7d82ad3f0bca17204177db6
https://github.com/awslabs/aws-sam-cli/blob/c05af5e7378c6f05f7d82ad3f0bca17204177db6/samcli/local/apigw/service_error_responses.py#L16-L23
30,013
awslabs/aws-sam-cli
samcli/local/apigw/service_error_responses.py
ServiceErrorResponses.lambda_not_found_response
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...
python
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", ")", ":", "response_data", "=", "jsonify", "(", "ServiceErrorResponses", ".", "_NO_LAMBDA_INTEGRATION", ")", "return", "make_response", "(", "response_data", ",", "ServiceErrorResponses", ".", "HTTP_STATUS_CODE_502", ...
Constructs a Flask Response for when a Lambda function is not found for an endpoint :return: a Flask Response
[ "Constructs", "a", "Flask", "Response", "for", "when", "a", "Lambda", "function", "is", "not", "found", "for", "an", "endpoint" ]
c05af5e7378c6f05f7d82ad3f0bca17204177db6
https://github.com/awslabs/aws-sam-cli/blob/c05af5e7378c6f05f7d82ad3f0bca17204177db6/samcli/local/apigw/service_error_responses.py#L26-L33
30,014
awslabs/aws-sam-cli
samcli/lib/utils/progressbar.py
progressbar
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,...
python
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", ")", ":", "return", "click", ".", "progressbar", "(", "length", "=", "length", ",", "label", "=", "label", ",", "show_pos", "=", "True", ")" ]
Creates a progressbar Parameters ---------- length int Length of the ProgressBar label str Label to give to the progressbar Returns ------- click.progressbar Progressbar
[ "Creates", "a", "progressbar" ]
c05af5e7378c6f05f7d82ad3f0bca17204177db6
https://github.com/awslabs/aws-sam-cli/blob/c05af5e7378c6f05f7d82ad3f0bca17204177db6/samcli/lib/utils/progressbar.py#L8-L25
30,015
awslabs/aws-sam-cli
samcli/cli/types.py
CfnParameterOverridesType._unquote
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...
python
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", ")", ":", "if", "value", "and", "(", "value", "[", "0", "]", "==", "value", "[", "-", "1", "]", "==", "'\"'", ")", ":", "# Remove quotes only if the string is wrapped in quotes", "value", "=", "value", ".", "strip", "(", ...
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 ---------- ...
[ "r", "Removes", "wrapping", "double", "quotes", "and", "any", "\\", "characters", ".", "They", "are", "usually", "added", "to", "preserve", "spaces", "when", "passing", "value", "thru", "shell", "." ]
c05af5e7378c6f05f7d82ad3f0bca17204177db6
https://github.com/awslabs/aws-sam-cli/blob/c05af5e7378c6f05f7d82ad3f0bca17204177db6/samcli/cli/types.py#L42-L68
30,016
awslabs/aws-sam-cli
samcli/local/services/base_local_service.py
BaseLocalService.service_response
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...
python
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", ")", ":", "response", "=", "Response", "(", "body", ")", "response", ".", "headers", "=", "headers", "response", ".", "status_code", "=", "status_code", "return", "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
[ "Constructs", "a", "Flask", "Response", "from", "the", "body", "headers", "and", "status_code", "." ]
c05af5e7378c6f05f7d82ad3f0bca17204177db6
https://github.com/awslabs/aws-sam-cli/blob/c05af5e7378c6f05f7d82ad3f0bca17204177db6/samcli/local/services/base_local_service.py#L84-L96
30,017
awslabs/aws-sam-cli
samcli/local/services/base_local_service.py
LambdaOutputParser.get_lambda_output
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...
python
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", ")", ":", "# 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...
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 ...
[ "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...
c05af5e7378c6f05f7d82ad3f0bca17204177db6
https://github.com/awslabs/aws-sam-cli/blob/c05af5e7378c6f05f7d82ad3f0bca17204177db6/samcli/local/services/base_local_service.py#L102-L149
30,018
awslabs/aws-sam-cli
samcli/lib/build/app_builder.py
ApplicationBuilder.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: ...
python
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", ")", ":", "result", "=", "{", "}", "for", "lambda_function", "in", "self", ".", "_functions_to_build", ":", "LOG", ".", "info", "(", "\"Building resource '%s'\"", ",", "lambda_function", ".", "name", ")", "result", "[", "lambda_f...
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
[ "Build", "the", "entire", "application" ]
c05af5e7378c6f05f7d82ad3f0bca17204177db6
https://github.com/awslabs/aws-sam-cli/blob/c05af5e7378c6f05f7d82ad3f0bca17204177db6/samcli/lib/build/app_builder.py#L91-L110
30,019
awslabs/aws-sam-cli
samcli/lib/build/app_builder.py
ApplicationBuilder.update_template
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...
python
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", ")", ":", "original_dir", "=", "os", ".", "path", ".", "dirname", "(", "original_template_path", ")", "for", "logical_id", ",", "resource", "in", ...
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 ...
[ "Given", "the", "path", "to", "built", "artifacts", "update", "the", "template", "to", "point", "appropriate", "resource", "CodeUris", "to", "the", "artifacts", "folder" ]
c05af5e7378c6f05f7d82ad3f0bca17204177db6
https://github.com/awslabs/aws-sam-cli/blob/c05af5e7378c6f05f7d82ad3f0bca17204177db6/samcli/lib/build/app_builder.py#L112-L153
30,020
awslabs/aws-sam-cli
samcli/lib/build/app_builder.py
ApplicationBuilder._build_function
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 ---------- ...
python
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", ")", ":", "# Create the arguments to pass to the builder", "# Code is always relative to the given base directory.", "code_dir", "=", "str", "(", "pathlib", ".", "Path", "(", "sel...
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 ...
[ "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", ...
c05af5e7378c6f05f7d82ad3f0bca17204177db6
https://github.com/awslabs/aws-sam-cli/blob/c05af5e7378c6f05f7d82ad3f0bca17204177db6/samcli/lib/build/app_builder.py#L155-L199
30,021
awslabs/aws-sam-cli
samcli/local/docker/lambda_build_container.py
LambdaBuildContainer._get_container_dirs
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...
python
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", ")", ":", "base", "=", "\"/tmp/samcli\"", "result", "=", "{", "\"source_dir\"", ":", "\"{}/source\"", ".", "format", "(", "base", ")", ",", "\"artifacts_dir\"", ":", "\"{}/artifacts\"", ".", "...
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 ...
[ "Provides", "paths", "to", "directories", "within", "the", "container", "that", "is", "required", "by", "the", "builder" ]
c05af5e7378c6f05f7d82ad3f0bca17204177db6
https://github.com/awslabs/aws-sam-cli/blob/c05af5e7378c6f05f7d82ad3f0bca17204177db6/samcli/local/docker/lambda_build_container.py#L150-L180
30,022
awslabs/aws-sam-cli
samcli/local/docker/lambda_build_container.py
LambdaBuildContainer._convert_to_container_dirs
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 ...
python
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", ")", ":", "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 ...
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...
[ "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", ...
c05af5e7378c6f05f7d82ad3f0bca17204177db6
https://github.com/awslabs/aws-sam-cli/blob/c05af5e7378c6f05f7d82ad3f0bca17204177db6/samcli/local/docker/lambda_build_container.py#L183-L228
30,023
awslabs/aws-sam-cli
samcli/commands/local/generate_event/event_generation.py
ServiceCommand.get_command
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...
python
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", ")", ":", "if", "cmd_name", "not", "in", "self", ".", "all_cmds", ":", "return", "None", "return", "EventTypeSubCommand", "(", "self", ".", "events_lib", ",", "cmd_name", ",", "self", ".", "...
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...
[ "gets", "the", "subcommands", "under", "the", "service", "name" ]
c05af5e7378c6f05f7d82ad3f0bca17204177db6
https://github.com/awslabs/aws-sam-cli/blob/c05af5e7378c6f05f7d82ad3f0bca17204177db6/samcli/commands/local/generate_event/event_generation.py#L45-L63
30,024
awslabs/aws-sam-cli
samcli/commands/local/generate_event/event_generation.py
EventTypeSubCommand.get_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 ...
python
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", ")", ":", "if", "cmd_name", "not", "in", "self", ".", "subcmd_definition", ":", "return", "None", "parameters", "=", "[", "]", "for", "param_name", "in", "self", ".", "subcmd_definition", "[",...
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...
[ "gets", "the", "Click", "Commands", "underneath", "a", "service", "name" ]
c05af5e7378c6f05f7d82ad3f0bca17204177db6
https://github.com/awslabs/aws-sam-cli/blob/c05af5e7378c6f05f7d82ad3f0bca17204177db6/samcli/commands/local/generate_event/event_generation.py#L119-L157
30,025
awslabs/aws-sam-cli
samcli/commands/local/generate_event/event_generation.py
EventTypeSubCommand.cmd_implementation
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 ...
python
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", ")", ":", "event", "=", "events_lib", ".", "generate_event", "(", "top_level_cmd_name", ",", "subcmd_name", "...
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...
[ "calls", "for", "value", "substitution", "in", "the", "event", "json", "and", "returns", "the", "customized", "json", "as", "a", "string" ]
c05af5e7378c6f05f7d82ad3f0bca17204177db6
https://github.com/awslabs/aws-sam-cli/blob/c05af5e7378c6f05f7d82ad3f0bca17204177db6/samcli/commands/local/generate_event/event_generation.py#L173-L196
30,026
marcotcr/lime
lime/lime_base.py
LimeBase.generate_lars_path
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...
python
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", ")", ":", "x_vector", "=", "weighted_data", "alphas", ",", "_", ",", "coefs", "=", "lars_path", "(", "x_vector", ",", "weighted_labels", ",", "method", "=", "'lasso'", ",", "verbose", "...
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...
[ "Generates", "the", "lars", "path", "for", "weighted", "data", "." ]
08133d47df00ed918e22005e0c98f6eefd5a1d71
https://github.com/marcotcr/lime/blob/08133d47df00ed918e22005e0c98f6eefd5a1d71/lime/lime_base.py#L31-L47
30,027
marcotcr/lime
lime/lime_base.py
LimeBase.forward_selection
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 ...
python
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", ")", ":", "clf", "=", "Ridge", "(", "alpha", "=", "0", ",", "fit_intercept", "=", "True", ",", "random_state", "=", "self", ".", "random_state", ")"...
Iteratively adds features to the model
[ "Iteratively", "adds", "features", "to", "the", "model" ]
08133d47df00ed918e22005e0c98f6eefd5a1d71
https://github.com/marcotcr/lime/blob/08133d47df00ed918e22005e0c98f6eefd5a1d71/lime/lime_base.py#L49-L68
30,028
marcotcr/lime
lime/lime_base.py
LimeBase.feature_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': ...
python
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", ")", ":", "if", "method", "==", "'none'", ":", "return", "np", ".", "array", "(", "range", "(", "data", ".", "shape", "[", "1", "...
Selects features for the model. see explain_instance_with_data to understand the parameters.
[ "Selects", "features", "for", "the", "model", ".", "see", "explain_instance_with_data", "to", "understand", "the", "parameters", "." ]
08133d47df00ed918e22005e0c98f6eefd5a1d71
https://github.com/marcotcr/lime/blob/08133d47df00ed918e22005e0c98f6eefd5a1d71/lime/lime_base.py#L70-L106
30,029
marcotcr/lime
lime/lime_base.py
LimeBase.explain_instance_with_data
def explain_instance_with_data(self, neighborhood_data, neighborhood_labels, distances, label, num_features, f...
python
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", ",", "feature_selection", "=", "'auto'", ",", "model_regressor", "=", "None", ")", ":", "weights", "=", "se...
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 ...
[ "Takes", "perturbed", "data", "labels", "and", "distances", "returns", "explanation", "." ]
08133d47df00ed918e22005e0c98f6eefd5a1d71
https://github.com/marcotcr/lime/blob/08133d47df00ed918e22005e0c98f6eefd5a1d71/lime/lime_base.py#L108-L179
30,030
marcotcr/lime
lime/explanation.py
id_generator
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))
python
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", ")", ":", "chars", "=", "list", "(", "string", ".", "ascii_uppercase", "+", "string", ".", "digits", ")", "return", "''", ".", "join", "(", "random_state", ".", "choice", ...
Helper function to generate random div ids. This is useful for embedding HTML into ipython notebooks.
[ "Helper", "function", "to", "generate", "random", "div", "ids", ".", "This", "is", "useful", "for", "embedding", "HTML", "into", "ipython", "notebooks", "." ]
08133d47df00ed918e22005e0c98f6eefd5a1d71
https://github.com/marcotcr/lime/blob/08133d47df00ed918e22005e0c98f6eefd5a1d71/lime/explanation.py#L17-L21
30,031
marcotcr/lime
lime/explanation.py
Explanation.available_labels
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.') ...
python
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", ")", ":", "try", ":", "assert", "self", ".", "mode", "==", "\"classification\"", "except", "AssertionError", ":", "raise", "NotImplementedError", "(", "'Not supported for regression explanations.'", ")", "else", ":", "ans", "=...
Returns the list of classification labels for which we have any explanations.
[ "Returns", "the", "list", "of", "classification", "labels", "for", "which", "we", "have", "any", "explanations", "." ]
08133d47df00ed918e22005e0c98f6eefd5a1d71
https://github.com/marcotcr/lime/blob/08133d47df00ed918e22005e0c98f6eefd5a1d71/lime/explanation.py#L117-L127
30,032
marcotcr/lime
lime/explanation.py
Explanation.as_list
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: ...
python
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", ")", ":", "label_to_use", "=", "label", "if", "self", ".", "mode", "==", "\"classification\"", "else", "self", ".", "dummy_label", "ans", "=", "self", ".", "domain_mapper", ...
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 ...
[ "Returns", "the", "explanation", "as", "a", "list", "." ]
08133d47df00ed918e22005e0c98f6eefd5a1d71
https://github.com/marcotcr/lime/blob/08133d47df00ed918e22005e0c98f6eefd5a1d71/lime/explanation.py#L129-L145
30,033
marcotcr/lime
lime/explanation.py
Explanation.as_pyplot_figure
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...
python
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", ")", ":", "import", "matplotlib", ".", "pyplot", "as", "plt", "exp", "=", "self", ".", "as_list", "(", "label", "=", "label", ",", "*", "*", "kwargs", ")", "fi...
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...
[ "Returns", "the", "explanation", "as", "a", "pyplot", "figure", "." ]
08133d47df00ed918e22005e0c98f6eefd5a1d71
https://github.com/marcotcr/lime/blob/08133d47df00ed918e22005e0c98f6eefd5a1d71/lime/explanation.py#L155-L184
30,034
marcotcr/lime
lime/explanation.py
Explanation.show_in_notebook
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...
python
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", ")", ":", "from", "IPython", ".", "core", ".", "display", "import", "display", ",", ...
Shows html explanation in ipython notebook. See as_html() for parameters. This will throw an error if you don't have IPython installed
[ "Shows", "html", "explanation", "in", "ipython", "notebook", "." ]
08133d47df00ed918e22005e0c98f6eefd5a1d71
https://github.com/marcotcr/lime/blob/08133d47df00ed918e22005e0c98f6eefd5a1d71/lime/explanation.py#L186-L200
30,035
marcotcr/lime
lime/explanation.py
Explanation.save_to_file
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...
python
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", ")", ":", "file_", "=", "open", "(", "file_path", ",", "'w'", ",", "...
Saves html explanation to file. . Params: file_path: file to save explanations to See as_html() for additional parameters.
[ "Saves", "html", "explanation", "to", "file", ".", "." ]
08133d47df00ed918e22005e0c98f6eefd5a1d71
https://github.com/marcotcr/lime/blob/08133d47df00ed918e22005e0c98f6eefd5a1d71/lime/explanation.py#L202-L221
30,036
marcotcr/lime
lime/wrappers/scikit_image.py
BaseWrapper._check_params
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 ...
python
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", ")", ":", "a_valid_fn", "=", "[", "]", "if", "self", ".", "target_fn", "is", "None", ":", "if", "callable", "(", "self", ")", ":", "a_valid_fn", ".", "append", "(", "self", ".", "__call__", ")", ...
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...
[ "Checks", "for", "mistakes", "in", "parameters" ]
08133d47df00ed918e22005e0c98f6eefd5a1d71
https://github.com/marcotcr/lime/blob/08133d47df00ed918e22005e0c98f6eefd5a1d71/lime/wrappers/scikit_image.py#L26-L58
30,037
marcotcr/lime
lime/lime_text.py
TextDomainMapper.map_exp_ids
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...
python
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", ")", ":", "if", "positions", ":", "exp", "=", "[", "(", "'%s_%s'", "%", "(", "self", ".", "indexed_string", ".", "word", "(", "x", "[", "0", "]", ")", ",", "'-'", ".",...
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',...
[ "Maps", "ids", "to", "words", "or", "word", "-", "position", "strings", "." ]
08133d47df00ed918e22005e0c98f6eefd5a1d71
https://github.com/marcotcr/lime/blob/08133d47df00ed918e22005e0c98f6eefd5a1d71/lime/lime_text.py#L31-L51
30,038
marcotcr/lime
lime/lime_text.py
IndexedString.inverse_removing
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...
python
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", ")", ":", "mask", "=", "np", ".", "ones", "(", "self", ".", "as_np", ".", "shape", "[", "0", "]", ",", "dtype", "=", "'bool'", ")", "mask", "[", "self", ".", "__get_idxs", "(", "words_to...
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.
[ "Returns", "a", "string", "after", "removing", "the", "appropriate", "words", "." ]
08133d47df00ed918e22005e0c98f6eefd5a1d71
https://github.com/marcotcr/lime/blob/08133d47df00ed918e22005e0c98f6eefd5a1d71/lime/lime_text.py#L162-L179
30,039
marcotcr/lime
lime/lime_text.py
IndexedString._segment_with_tokens
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...
python
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", ")", ":", "list_form", "=", "[", "]", "text_ptr", "=", "0", "for", "token", "in", "tokens", ":", "inter_token_string", "=", "[", "]", "while", "not", "text", "[", "text_ptr", ":", "]", ".", "st...
Segment a string around the tokens created by a passed-in tokenizer
[ "Segment", "a", "string", "around", "the", "tokens", "created", "by", "a", "passed", "-", "in", "tokenizer" ]
08133d47df00ed918e22005e0c98f6eefd5a1d71
https://github.com/marcotcr/lime/blob/08133d47df00ed918e22005e0c98f6eefd5a1d71/lime/lime_text.py#L182-L199
30,040
marcotcr/lime
lime/lime_text.py
IndexedString.__get_idxs
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]
python
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", ")", ":", "if", "self", ".", "bow", ":", "return", "list", "(", "itertools", ".", "chain", ".", "from_iterable", "(", "[", "self", ".", "positions", "[", "z", "]", "for", "z", "in", "words", "]", ")",...
Returns indexes to appropriate words.
[ "Returns", "indexes", "to", "appropriate", "words", "." ]
08133d47df00ed918e22005e0c98f6eefd5a1d71
https://github.com/marcotcr/lime/blob/08133d47df00ed918e22005e0c98f6eefd5a1d71/lime/lime_text.py#L201-L207
30,041
marcotcr/lime
lime/lime_tabular.py
TableDomainMapper.map_exp_ids
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: ...
python
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", ")", ":", "names", "=", "self", ".", "exp_feature_names", "if", "self", ".", "discretized_feature_names", "is", "not", "None", ":", "names", "=", "self", ".", "discretized_feature_names", "return", "[", "(", "na...
Maps ids to feature names. Args: exp: list of tuples [(id, weight), (id,weight)] Returns: list of tuples (feature_name, weight)
[ "Maps", "ids", "to", "feature", "names", "." ]
08133d47df00ed918e22005e0c98f6eefd5a1d71
https://github.com/marcotcr/lime/blob/08133d47df00ed918e22005e0c98f6eefd5a1d71/lime/lime_tabular.py#L45-L57
30,042
marcotcr/lime
lime/lime_tabular.py
TableDomainMapper.visualize_instance_html
def visualize_instance_html(self, exp, label, div_name, exp_object_name, show_table=True, show_all=False): """Shows the ...
python
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", ")", ":", "if", "not", "show_table", ":", "return", "''", "weights", "=", "[", ...
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...
[ "Shows", "the", "current", "example", "in", "a", "table", "format", "." ]
08133d47df00ed918e22005e0c98f6eefd5a1d71
https://github.com/marcotcr/lime/blob/08133d47df00ed918e22005e0c98f6eefd5a1d71/lime/lime_tabular.py#L59-L89
30,043
marcotcr/lime
lime/lime_tabular.py
LimeTabularExplainer.validate_training_data_stats
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...
python
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", ")", ":", "stat_keys", "=", "list", "(", "training_data_stats", ".", "keys", "(", ")", ")", "valid_stat_keys", "=", "[", "\"means\"", ",", "\"mins\"", ",", "\"maxs\"", ",", "\"stds\"", ",", "\"fe...
Method to validate the structure of training data stats
[ "Method", "to", "validate", "the", "structure", "of", "training", "data", "stats" ]
08133d47df00ed918e22005e0c98f6eefd5a1d71
https://github.com/marcotcr/lime/blob/08133d47df00ed918e22005e0c98f6eefd5a1d71/lime/lime_tabular.py#L260-L268
30,044
marcotcr/lime
lime/lime_tabular.py
RecurrentTabularExplainer._make_predict_proba
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...
python
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", ")", ":", "def", "predict_proba", "(", "X", ")", ":", "n_samples", "=", "X", ".", "shape", "[", "0", "]", "new_shape", "=", "(", "n_samples", ",", "self", ".", "n_features", ",", "self", ".", "n...
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.
[ "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...
08133d47df00ed918e22005e0c98f6eefd5a1d71
https://github.com/marcotcr/lime/blob/08133d47df00ed918e22005e0c98f6eefd5a1d71/lime/lime_tabular.py#L571-L585
30,045
marcotcr/lime
lime/lime_image.py
ImageExplanation.get_image_and_mask
def get_image_and_mask(self, label, positive_only=True, hide_rest=False, num_features=5, min_weight=0.): """Init function. Args: label: label to explain positive_only: if True, only take superpixels that contribute to the prediction of ...
python
def get_image_and_mask(self, label, positive_only=True, hide_rest=False, num_features=5, min_weight=0.): """Init function. Args: label: label to explain positive_only: if True, only take superpixels that contribute to the prediction of ...
[ "def", "get_image_and_mask", "(", "self", ",", "label", ",", "positive_only", "=", "True", ",", "hide_rest", "=", "False", ",", "num_features", "=", "5", ",", "min_weight", "=", "0.", ")", ":", "if", "label", "not", "in", "self", ".", "local_exp", ":", ...
Init function. Args: label: label to explain positive_only: if True, only take superpixels that contribute to the prediction of the label. Otherwise, use the top num_features superpixels, which can be positive or negative towards the label...
[ "Init", "function", "." ]
08133d47df00ed918e22005e0c98f6eefd5a1d71
https://github.com/marcotcr/lime/blob/08133d47df00ed918e22005e0c98f6eefd5a1d71/lime/lime_image.py#L31-L80
30,046
marcotcr/lime
lime/lime_image.py
LimeImageExplainer.data_labels
def data_labels(self, image, fudged_image, segments, classifier_fn, num_samples, batch_size=10): """Generates images and predictions in the neighborhood of this image. Args: ...
python
def data_labels(self, image, fudged_image, segments, classifier_fn, num_samples, batch_size=10): """Generates images and predictions in the neighborhood of this image. Args: ...
[ "def", "data_labels", "(", "self", ",", "image", ",", "fudged_image", ",", "segments", ",", "classifier_fn", ",", "num_samples", ",", "batch_size", "=", "10", ")", ":", "n_features", "=", "np", ".", "unique", "(", "segments", ")", ".", "shape", "[", "0",...
Generates images and predictions in the neighborhood of this image. Args: image: 3d numpy array, the image fudged_image: 3d numpy array, image to replace original image when superpixel is turned off segments: segmentation of the image classifier_f...
[ "Generates", "images", "and", "predictions", "in", "the", "neighborhood", "of", "this", "image", "." ]
08133d47df00ed918e22005e0c98f6eefd5a1d71
https://github.com/marcotcr/lime/blob/08133d47df00ed918e22005e0c98f6eefd5a1d71/lime/lime_image.py#L216-L261
30,047
marcotcr/lime
lime/utils/generic_utils.py
has_arg
def has_arg(fn, arg_name): """Checks if a callable accepts a given keyword argument. Args: fn: callable to inspect arg_name: string, keyword argument name to check Returns: bool, whether `fn` accepts a `arg_name` keyword argument. """ if sys.version_info < (3,): if ...
python
def has_arg(fn, arg_name): """Checks if a callable accepts a given keyword argument. Args: fn: callable to inspect arg_name: string, keyword argument name to check Returns: bool, whether `fn` accepts a `arg_name` keyword argument. """ if sys.version_info < (3,): if ...
[ "def", "has_arg", "(", "fn", ",", "arg_name", ")", ":", "if", "sys", ".", "version_info", "<", "(", "3", ",", ")", ":", "if", "isinstance", "(", "fn", ",", "types", ".", "FunctionType", ")", "or", "isinstance", "(", "fn", ",", "types", ".", "Method...
Checks if a callable accepts a given keyword argument. Args: fn: callable to inspect arg_name: string, keyword argument name to check Returns: bool, whether `fn` accepts a `arg_name` keyword argument.
[ "Checks", "if", "a", "callable", "accepts", "a", "given", "keyword", "argument", "." ]
08133d47df00ed918e22005e0c98f6eefd5a1d71
https://github.com/marcotcr/lime/blob/08133d47df00ed918e22005e0c98f6eefd5a1d71/lime/utils/generic_utils.py#L6-L39
30,048
iterative/dvc
dvc/cache.py
Cache._get_remote
def _get_remote(self, config, name): """ The config file is stored in a way that allows you to have a cache for each remote. This is needed when specifying external outputs (as they require you to have an external cache location). Imagine a config file like the followin...
python
def _get_remote(self, config, name): """ The config file is stored in a way that allows you to have a cache for each remote. This is needed when specifying external outputs (as they require you to have an external cache location). Imagine a config file like the followin...
[ "def", "_get_remote", "(", "self", ",", "config", ",", "name", ")", ":", "from", "dvc", ".", "remote", "import", "Remote", "remote", "=", "config", ".", "get", "(", "name", ")", "if", "not", "remote", ":", "return", "None", "settings", "=", "self", "...
The config file is stored in a way that allows you to have a cache for each remote. This is needed when specifying external outputs (as they require you to have an external cache location). Imagine a config file like the following: ['remote "dvc-storage"'] ...
[ "The", "config", "file", "is", "stored", "in", "a", "way", "that", "allows", "you", "to", "have", "a", "cache", "for", "each", "remote", "." ]
8bb21261e34c9632453e09090de7ebe50e38d341
https://github.com/iterative/dvc/blob/8bb21261e34c9632453e09090de7ebe50e38d341/dvc/cache.py#L52-L91
30,049
iterative/dvc
dvc/dagascii.py
draw
def draw(vertexes, edges): """Build a DAG and draw it in ASCII. Args: vertexes (list): list of graph vertexes. edges (list): list of graph edges. """ # pylint: disable=too-many-locals # NOTE: coordinates might me negative, so we need to shift # everything to the positive plane b...
python
def draw(vertexes, edges): """Build a DAG and draw it in ASCII. Args: vertexes (list): list of graph vertexes. edges (list): list of graph edges. """ # pylint: disable=too-many-locals # NOTE: coordinates might me negative, so we need to shift # everything to the positive plane b...
[ "def", "draw", "(", "vertexes", ",", "edges", ")", ":", "# pylint: disable=too-many-locals", "# NOTE: coordinates might me negative, so we need to shift", "# everything to the positive plane before we actually draw it.", "Xs", "=", "[", "]", "# pylint: disable=invalid-name", "Ys", ...
Build a DAG and draw it in ASCII. Args: vertexes (list): list of graph vertexes. edges (list): list of graph edges.
[ "Build", "a", "DAG", "and", "draw", "it", "in", "ASCII", "." ]
8bb21261e34c9632453e09090de7ebe50e38d341
https://github.com/iterative/dvc/blob/8bb21261e34c9632453e09090de7ebe50e38d341/dvc/dagascii.py#L297-L370
30,050
iterative/dvc
dvc/dagascii.py
AsciiCanvas.draw
def draw(self): """Draws ASCII canvas on the screen.""" if sys.stdout.isatty(): # pragma: no cover from asciimatics.screen import Screen Screen.wrapper(self._do_draw) else: for line in self.canvas: print("".join(line))
python
def draw(self): """Draws ASCII canvas on the screen.""" if sys.stdout.isatty(): # pragma: no cover from asciimatics.screen import Screen Screen.wrapper(self._do_draw) else: for line in self.canvas: print("".join(line))
[ "def", "draw", "(", "self", ")", ":", "if", "sys", ".", "stdout", ".", "isatty", "(", ")", ":", "# pragma: no cover", "from", "asciimatics", ".", "screen", "import", "Screen", "Screen", ".", "wrapper", "(", "self", ".", "_do_draw", ")", "else", ":", "f...
Draws ASCII canvas on the screen.
[ "Draws", "ASCII", "canvas", "on", "the", "screen", "." ]
8bb21261e34c9632453e09090de7ebe50e38d341
https://github.com/iterative/dvc/blob/8bb21261e34c9632453e09090de7ebe50e38d341/dvc/dagascii.py#L59-L67
30,051
iterative/dvc
dvc/dagascii.py
AsciiCanvas.point
def point(self, x, y, char): """Create a point on ASCII canvas. Args: x (int): x coordinate. Should be >= 0 and < number of columns in the canvas. y (int): y coordinate. Should be >= 0 an < number of lines in the canvas. char (str): ch...
python
def point(self, x, y, char): """Create a point on ASCII canvas. Args: x (int): x coordinate. Should be >= 0 and < number of columns in the canvas. y (int): y coordinate. Should be >= 0 an < number of lines in the canvas. char (str): ch...
[ "def", "point", "(", "self", ",", "x", ",", "y", ",", "char", ")", ":", "assert", "len", "(", "char", ")", "==", "1", "assert", "x", ">=", "0", "assert", "x", "<", "self", ".", "cols", "assert", "y", ">=", "0", "assert", "y", "<", "self", "."...
Create a point on ASCII canvas. Args: x (int): x coordinate. Should be >= 0 and < number of columns in the canvas. y (int): y coordinate. Should be >= 0 an < number of lines in the canvas. char (str): character to place in the specified point ...
[ "Create", "a", "point", "on", "ASCII", "canvas", "." ]
8bb21261e34c9632453e09090de7ebe50e38d341
https://github.com/iterative/dvc/blob/8bb21261e34c9632453e09090de7ebe50e38d341/dvc/dagascii.py#L155-L172
30,052
iterative/dvc
dvc/dagascii.py
AsciiCanvas.line
def line(self, x0, y0, x1, y1, char): """Create a line on ASCII canvas. Args: x0 (int): x coordinate where the line should start. y0 (int): y coordinate where the line should start. x1 (int): x coordinate where the line should end. y1 (int): y coordinate ...
python
def line(self, x0, y0, x1, y1, char): """Create a line on ASCII canvas. Args: x0 (int): x coordinate where the line should start. y0 (int): y coordinate where the line should start. x1 (int): x coordinate where the line should end. y1 (int): y coordinate ...
[ "def", "line", "(", "self", ",", "x0", ",", "y0", ",", "x1", ",", "y1", ",", "char", ")", ":", "# pylint: disable=too-many-arguments, too-many-branches", "if", "x0", ">", "x1", ":", "x1", ",", "x0", "=", "x0", ",", "x1", "y1", ",", "y0", "=", "y0", ...
Create a line on ASCII canvas. Args: x0 (int): x coordinate where the line should start. y0 (int): y coordinate where the line should start. x1 (int): x coordinate where the line should end. y1 (int): y coordinate where the line should end. char (str)...
[ "Create", "a", "line", "on", "ASCII", "canvas", "." ]
8bb21261e34c9632453e09090de7ebe50e38d341
https://github.com/iterative/dvc/blob/8bb21261e34c9632453e09090de7ebe50e38d341/dvc/dagascii.py#L174-L214
30,053
iterative/dvc
dvc/dagascii.py
AsciiCanvas.text
def text(self, x, y, text): """Print a text on ASCII canvas. Args: x (int): x coordinate where the text should start. y (int): y coordinate where the text should start. text (str): string that should be printed. """ for i, char in enumerate(text): ...
python
def text(self, x, y, text): """Print a text on ASCII canvas. Args: x (int): x coordinate where the text should start. y (int): y coordinate where the text should start. text (str): string that should be printed. """ for i, char in enumerate(text): ...
[ "def", "text", "(", "self", ",", "x", ",", "y", ",", "text", ")", ":", "for", "i", ",", "char", "in", "enumerate", "(", "text", ")", ":", "self", ".", "point", "(", "x", "+", "i", ",", "y", ",", "char", ")" ]
Print a text on ASCII canvas. Args: x (int): x coordinate where the text should start. y (int): y coordinate where the text should start. text (str): string that should be printed.
[ "Print", "a", "text", "on", "ASCII", "canvas", "." ]
8bb21261e34c9632453e09090de7ebe50e38d341
https://github.com/iterative/dvc/blob/8bb21261e34c9632453e09090de7ebe50e38d341/dvc/dagascii.py#L216-L225
30,054
iterative/dvc
dvc/dagascii.py
AsciiCanvas.box
def box(self, x0, y0, width, height): """Create a box on ASCII canvas. Args: x0 (int): x coordinate of the box corner. y0 (int): y coordinate of the box corner. width (int): box width. height (int): box height. """ assert width > 1 ...
python
def box(self, x0, y0, width, height): """Create a box on ASCII canvas. Args: x0 (int): x coordinate of the box corner. y0 (int): y coordinate of the box corner. width (int): box width. height (int): box height. """ assert width > 1 ...
[ "def", "box", "(", "self", ",", "x0", ",", "y0", ",", "width", ",", "height", ")", ":", "assert", "width", ">", "1", "assert", "height", ">", "1", "width", "-=", "1", "height", "-=", "1", "for", "x", "in", "range", "(", "x0", ",", "x0", "+", ...
Create a box on ASCII canvas. Args: x0 (int): x coordinate of the box corner. y0 (int): y coordinate of the box corner. width (int): box width. height (int): box height.
[ "Create", "a", "box", "on", "ASCII", "canvas", "." ]
8bb21261e34c9632453e09090de7ebe50e38d341
https://github.com/iterative/dvc/blob/8bb21261e34c9632453e09090de7ebe50e38d341/dvc/dagascii.py#L227-L253
30,055
iterative/dvc
dvc/progress.py
Progress.refresh
def refresh(self, line=None): """Refreshes progress bar.""" # Just go away if it is locked. Will update next time if not self._lock.acquire(False): return if line is None: line = self._line if sys.stdout.isatty() and line is not None: self._w...
python
def refresh(self, line=None): """Refreshes progress bar.""" # Just go away if it is locked. Will update next time if not self._lock.acquire(False): return if line is None: line = self._line if sys.stdout.isatty() and line is not None: self._w...
[ "def", "refresh", "(", "self", ",", "line", "=", "None", ")", ":", "# Just go away if it is locked. Will update next time", "if", "not", "self", ".", "_lock", ".", "acquire", "(", "False", ")", ":", "return", "if", "line", "is", "None", ":", "line", "=", "...
Refreshes progress bar.
[ "Refreshes", "progress", "bar", "." ]
8bb21261e34c9632453e09090de7ebe50e38d341
https://github.com/iterative/dvc/blob/8bb21261e34c9632453e09090de7ebe50e38d341/dvc/progress.py#L49-L62
30,056
iterative/dvc
dvc/progress.py
Progress.update_target
def update_target(self, name, current, total): """Updates progress bar for a specified target.""" self.refresh(self._bar(name, current, total))
python
def update_target(self, name, current, total): """Updates progress bar for a specified target.""" self.refresh(self._bar(name, current, total))
[ "def", "update_target", "(", "self", ",", "name", ",", "current", ",", "total", ")", ":", "self", ".", "refresh", "(", "self", ".", "_bar", "(", "name", ",", "current", ",", "total", ")", ")" ]
Updates progress bar for a specified target.
[ "Updates", "progress", "bar", "for", "a", "specified", "target", "." ]
8bb21261e34c9632453e09090de7ebe50e38d341
https://github.com/iterative/dvc/blob/8bb21261e34c9632453e09090de7ebe50e38d341/dvc/progress.py#L64-L66
30,057
iterative/dvc
dvc/progress.py
Progress.finish_target
def finish_target(self, name): """Finishes progress bar for a specified target.""" # We have to write a msg about finished target with self._lock: pbar = self._bar(name, 100, 100) if sys.stdout.isatty(): self.clearln() self._print(pbar) ...
python
def finish_target(self, name): """Finishes progress bar for a specified target.""" # We have to write a msg about finished target with self._lock: pbar = self._bar(name, 100, 100) if sys.stdout.isatty(): self.clearln() self._print(pbar) ...
[ "def", "finish_target", "(", "self", ",", "name", ")", ":", "# We have to write a msg about finished target", "with", "self", ".", "_lock", ":", "pbar", "=", "self", ".", "_bar", "(", "name", ",", "100", ",", "100", ")", "if", "sys", ".", "stdout", ".", ...
Finishes progress bar for a specified target.
[ "Finishes", "progress", "bar", "for", "a", "specified", "target", "." ]
8bb21261e34c9632453e09090de7ebe50e38d341
https://github.com/iterative/dvc/blob/8bb21261e34c9632453e09090de7ebe50e38d341/dvc/progress.py#L68-L80
30,058
iterative/dvc
dvc/repo/diff.py
diff
def diff(self, a_ref, target=None, b_ref=None): """Gerenates diff message string output Args: target(str) - file/directory to check diff of a_ref(str) - first tag (optional) b_ref(str) - second git tag Returns: string: string of output message with diff info """ res...
python
def diff(self, a_ref, target=None, b_ref=None): """Gerenates diff message string output Args: target(str) - file/directory to check diff of a_ref(str) - first tag (optional) b_ref(str) - second git tag Returns: string: string of output message with diff info """ res...
[ "def", "diff", "(", "self", ",", "a_ref", ",", "target", "=", "None", ",", "b_ref", "=", "None", ")", ":", "result", "=", "{", "}", "diff_dct", "=", "self", ".", "scm", ".", "get_diff_trees", "(", "a_ref", ",", "b_ref", "=", "b_ref", ")", "result",...
Gerenates diff message string output Args: target(str) - file/directory to check diff of a_ref(str) - first tag (optional) b_ref(str) - second git tag Returns: string: string of output message with diff info
[ "Gerenates", "diff", "message", "string", "output" ]
8bb21261e34c9632453e09090de7ebe50e38d341
https://github.com/iterative/dvc/blob/8bb21261e34c9632453e09090de7ebe50e38d341/dvc/repo/diff.py#L223-L252
30,059
iterative/dvc
dvc/repo/reproduce.py
_reproduce_stages
def _reproduce_stages( G, stages, node, force, dry, interactive, ignore_build_cache, no_commit, downstream, ): r"""Derive the evaluation of the given node for the given graph. When you _reproduce a stage_, you want to _evaluate the descendants_ to know if it make sense t...
python
def _reproduce_stages( G, stages, node, force, dry, interactive, ignore_build_cache, no_commit, downstream, ): r"""Derive the evaluation of the given node for the given graph. When you _reproduce a stage_, you want to _evaluate the descendants_ to know if it make sense t...
[ "def", "_reproduce_stages", "(", "G", ",", "stages", ",", "node", ",", "force", ",", "dry", ",", "interactive", ",", "ignore_build_cache", ",", "no_commit", ",", "downstream", ",", ")", ":", "import", "networkx", "as", "nx", "if", "downstream", ":", "# NOT...
r"""Derive the evaluation of the given node for the given graph. When you _reproduce a stage_, you want to _evaluate the descendants_ to know if it make sense to _recompute_ it. A post-ordered search will give us an order list of the nodes we want. For example, let's say that we have the following pip...
[ "r", "Derive", "the", "evaluation", "of", "the", "given", "node", "for", "the", "given", "graph", "." ]
8bb21261e34c9632453e09090de7ebe50e38d341
https://github.com/iterative/dvc/blob/8bb21261e34c9632453e09090de7ebe50e38d341/dvc/repo/reproduce.py#L132-L210
30,060
iterative/dvc
dvc/utils/compat.py
csv_reader
def csv_reader(unicode_csv_data, dialect=None, **kwargs): """csv.reader doesn't support Unicode input, so need to use some tricks to work around this. Source: https://docs.python.org/2/library/csv.html#csv-examples """ import csv dialect = dialect or csv.excel if is_py3: # Python3...
python
def csv_reader(unicode_csv_data, dialect=None, **kwargs): """csv.reader doesn't support Unicode input, so need to use some tricks to work around this. Source: https://docs.python.org/2/library/csv.html#csv-examples """ import csv dialect = dialect or csv.excel if is_py3: # Python3...
[ "def", "csv_reader", "(", "unicode_csv_data", ",", "dialect", "=", "None", ",", "*", "*", "kwargs", ")", ":", "import", "csv", "dialect", "=", "dialect", "or", "csv", ".", "excel", "if", "is_py3", ":", "# Python3 supports encoding by default, so just return the ob...
csv.reader doesn't support Unicode input, so need to use some tricks to work around this. Source: https://docs.python.org/2/library/csv.html#csv-examples
[ "csv", ".", "reader", "doesn", "t", "support", "Unicode", "input", "so", "need", "to", "use", "some", "tricks", "to", "work", "around", "this", "." ]
8bb21261e34c9632453e09090de7ebe50e38d341
https://github.com/iterative/dvc/blob/8bb21261e34c9632453e09090de7ebe50e38d341/dvc/utils/compat.py#L30-L52
30,061
iterative/dvc
dvc/repo/pkg/install.py
install
def install(self, address, target_dir, select=[], fname=None): """ Install package. The command can be run only from DVC project root. E.g. Having: DVC package in https://github.com/dmpetrov/tag_classifier $ dvc pkg install https://github.com/dmpetrov/tag_classifier Res...
python
def install(self, address, target_dir, select=[], fname=None): """ Install package. The command can be run only from DVC project root. E.g. Having: DVC package in https://github.com/dmpetrov/tag_classifier $ dvc pkg install https://github.com/dmpetrov/tag_classifier Res...
[ "def", "install", "(", "self", ",", "address", ",", "target_dir", ",", "select", "=", "[", "]", ",", "fname", "=", "None", ")", ":", "if", "not", "os", ".", "path", ".", "isdir", "(", "target_dir", ")", ":", "raise", "DvcException", "(", "\"target di...
Install package. The command can be run only from DVC project root. E.g. Having: DVC package in https://github.com/dmpetrov/tag_classifier $ dvc pkg install https://github.com/dmpetrov/tag_classifier Result: tag_classifier package in dvc_mod/ directory
[ "Install", "package", "." ]
8bb21261e34c9632453e09090de7ebe50e38d341
https://github.com/iterative/dvc/blob/8bb21261e34c9632453e09090de7ebe50e38d341/dvc/repo/pkg/install.py#L144-L173
30,062
iterative/dvc
dvc/stage.py
Stage.is_import
def is_import(self): """Whether the stage file was created with `dvc import`.""" return not self.cmd and len(self.deps) == 1 and len(self.outs) == 1
python
def is_import(self): """Whether the stage file was created with `dvc import`.""" return not self.cmd and len(self.deps) == 1 and len(self.outs) == 1
[ "def", "is_import", "(", "self", ")", ":", "return", "not", "self", ".", "cmd", "and", "len", "(", "self", ".", "deps", ")", "==", "1", "and", "len", "(", "self", ".", "outs", ")", "==", "1" ]
Whether the stage file was created with `dvc import`.
[ "Whether", "the", "stage", "file", "was", "created", "with", "dvc", "import", "." ]
8bb21261e34c9632453e09090de7ebe50e38d341
https://github.com/iterative/dvc/blob/8bb21261e34c9632453e09090de7ebe50e38d341/dvc/stage.py#L211-L213
30,063
iterative/dvc
dvc/stage.py
Stage.is_cached
def is_cached(self): """ Checks if this stage has been already ran and stored """ from dvc.remote.local import RemoteLOCAL from dvc.remote.s3 import RemoteS3 old = Stage.load(self.repo, self.path) if old._changed_outs(): return False # NOTE: ...
python
def is_cached(self): """ Checks if this stage has been already ran and stored """ from dvc.remote.local import RemoteLOCAL from dvc.remote.s3 import RemoteS3 old = Stage.load(self.repo, self.path) if old._changed_outs(): return False # NOTE: ...
[ "def", "is_cached", "(", "self", ")", ":", "from", "dvc", ".", "remote", ".", "local", "import", "RemoteLOCAL", "from", "dvc", ".", "remote", ".", "s3", "import", "RemoteS3", "old", "=", "Stage", ".", "load", "(", "self", ".", "repo", ",", "self", "....
Checks if this stage has been already ran and stored
[ "Checks", "if", "this", "stage", "has", "been", "already", "ran", "and", "stored" ]
8bb21261e34c9632453e09090de7ebe50e38d341
https://github.com/iterative/dvc/blob/8bb21261e34c9632453e09090de7ebe50e38d341/dvc/stage.py#L369-L411
30,064
iterative/dvc
dvc/daemon.py
daemon
def daemon(args): """Launch a `dvc daemon` command in a detached process. Args: args (list): list of arguments to append to `dvc daemon` command. """ if os.environ.get(DVC_DAEMON): logger.debug("skipping launching a new daemon.") return cmd = [sys.executable] if not is_...
python
def daemon(args): """Launch a `dvc daemon` command in a detached process. Args: args (list): list of arguments to append to `dvc daemon` command. """ if os.environ.get(DVC_DAEMON): logger.debug("skipping launching a new daemon.") return cmd = [sys.executable] if not is_...
[ "def", "daemon", "(", "args", ")", ":", "if", "os", ".", "environ", ".", "get", "(", "DVC_DAEMON", ")", ":", "logger", ".", "debug", "(", "\"skipping launching a new daemon.\"", ")", "return", "cmd", "=", "[", "sys", ".", "executable", "]", "if", "not", ...
Launch a `dvc daemon` command in a detached process. Args: args (list): list of arguments to append to `dvc daemon` command.
[ "Launch", "a", "dvc", "daemon", "command", "in", "a", "detached", "process", "." ]
8bb21261e34c9632453e09090de7ebe50e38d341
https://github.com/iterative/dvc/blob/8bb21261e34c9632453e09090de7ebe50e38d341/dvc/daemon.py#L85-L107
30,065
iterative/dvc
dvc/command/init.py
add_parser
def add_parser(subparsers, parent_parser): """Setup parser for `dvc init`.""" INIT_HELP = "Initialize DVC in the current directory." INIT_DESCRIPTION = ( "Initialize DVC in the current directory. Expects directory\n" "to be a Git repository unless --no-scm option is specified." ) in...
python
def add_parser(subparsers, parent_parser): """Setup parser for `dvc init`.""" INIT_HELP = "Initialize DVC in the current directory." INIT_DESCRIPTION = ( "Initialize DVC in the current directory. Expects directory\n" "to be a Git repository unless --no-scm option is specified." ) in...
[ "def", "add_parser", "(", "subparsers", ",", "parent_parser", ")", ":", "INIT_HELP", "=", "\"Initialize DVC in the current directory.\"", "INIT_DESCRIPTION", "=", "(", "\"Initialize DVC in the current directory. Expects directory\\n\"", "\"to be a Git repository unless --no-scm option ...
Setup parser for `dvc init`.
[ "Setup", "parser", "for", "dvc", "init", "." ]
8bb21261e34c9632453e09090de7ebe50e38d341
https://github.com/iterative/dvc/blob/8bb21261e34c9632453e09090de7ebe50e38d341/dvc/command/init.py#L31-L63
30,066
iterative/dvc
dvc/repo/metrics/show.py
_format_csv
def _format_csv(content, delimiter): """Format delimited text to have same column width. Args: content (str): The content of a metric. delimiter (str): Value separator Returns: str: Formatted content. Example: >>> content = ( "value_mse,deviation_mse,data_...
python
def _format_csv(content, delimiter): """Format delimited text to have same column width. Args: content (str): The content of a metric. delimiter (str): Value separator Returns: str: Formatted content. Example: >>> content = ( "value_mse,deviation_mse,data_...
[ "def", "_format_csv", "(", "content", ",", "delimiter", ")", ":", "reader", "=", "csv_reader", "(", "StringIO", "(", "content", ")", ",", "delimiter", "=", "builtin_str", "(", "delimiter", ")", ")", "rows", "=", "[", "row", "for", "row", "in", "reader", ...
Format delimited text to have same column width. Args: content (str): The content of a metric. delimiter (str): Value separator Returns: str: Formatted content. Example: >>> content = ( "value_mse,deviation_mse,data_set\n" "0.421601,0.173461,train\...
[ "Format", "delimited", "text", "to", "have", "same", "column", "width", "." ]
8bb21261e34c9632453e09090de7ebe50e38d341
https://github.com/iterative/dvc/blob/8bb21261e34c9632453e09090de7ebe50e38d341/dvc/repo/metrics/show.py#L77-L114
30,067
iterative/dvc
dvc/repo/metrics/show.py
_format_output
def _format_output(content, typ): """Tabularize the content according to its type. Args: content (str): The content of a metric. typ (str): The type of metric -- (raw|json|tsv|htsv|csv|hcsv). Returns: str: Content in a raw or tabular format. """ if "csv" in str(typ): ...
python
def _format_output(content, typ): """Tabularize the content according to its type. Args: content (str): The content of a metric. typ (str): The type of metric -- (raw|json|tsv|htsv|csv|hcsv). Returns: str: Content in a raw or tabular format. """ if "csv" in str(typ): ...
[ "def", "_format_output", "(", "content", ",", "typ", ")", ":", "if", "\"csv\"", "in", "str", "(", "typ", ")", ":", "return", "_format_csv", "(", "content", ",", "delimiter", "=", "\",\"", ")", "if", "\"tsv\"", "in", "str", "(", "typ", ")", ":", "retu...
Tabularize the content according to its type. Args: content (str): The content of a metric. typ (str): The type of metric -- (raw|json|tsv|htsv|csv|hcsv). Returns: str: Content in a raw or tabular format.
[ "Tabularize", "the", "content", "according", "to", "its", "type", "." ]
8bb21261e34c9632453e09090de7ebe50e38d341
https://github.com/iterative/dvc/blob/8bb21261e34c9632453e09090de7ebe50e38d341/dvc/repo/metrics/show.py#L117-L134
30,068
iterative/dvc
dvc/repo/metrics/show.py
_collect_metrics
def _collect_metrics(repo, path, recursive, typ, xpath, branch): """Gather all the metric outputs. Args: path (str): Path to a metric file or a directory. recursive (bool): If path is a directory, do a recursive search for metrics on the given path. typ (str): The type of me...
python
def _collect_metrics(repo, path, recursive, typ, xpath, branch): """Gather all the metric outputs. Args: path (str): Path to a metric file or a directory. recursive (bool): If path is a directory, do a recursive search for metrics on the given path. typ (str): The type of me...
[ "def", "_collect_metrics", "(", "repo", ",", "path", ",", "recursive", ",", "typ", ",", "xpath", ",", "branch", ")", ":", "outs", "=", "[", "out", "for", "stage", "in", "repo", ".", "stages", "(", ")", "for", "out", "in", "stage", ".", "outs", "]",...
Gather all the metric outputs. Args: path (str): Path to a metric file or a directory. recursive (bool): If path is a directory, do a recursive search for metrics on the given path. typ (str): The type of metric to search for, could be one of the following (raw|json|...
[ "Gather", "all", "the", "metric", "outputs", "." ]
8bb21261e34c9632453e09090de7ebe50e38d341
https://github.com/iterative/dvc/blob/8bb21261e34c9632453e09090de7ebe50e38d341/dvc/repo/metrics/show.py#L155-L200
30,069
iterative/dvc
dvc/repo/metrics/show.py
_read_metrics
def _read_metrics(repo, metrics, branch): """Read the content of each metric file and format it. Args: metrics (list): List of metric touples branch (str): Branch to look up for metrics. Returns: A dict mapping keys with metrics path name and content. For example: ...
python
def _read_metrics(repo, metrics, branch): """Read the content of each metric file and format it. Args: metrics (list): List of metric touples branch (str): Branch to look up for metrics. Returns: A dict mapping keys with metrics path name and content. For example: ...
[ "def", "_read_metrics", "(", "repo", ",", "metrics", ",", "branch", ")", ":", "res", "=", "{", "}", "for", "out", ",", "typ", ",", "xpath", "in", "metrics", ":", "assert", "out", ".", "scheme", "==", "\"local\"", "if", "not", "typ", ":", "typ", "="...
Read the content of each metric file and format it. Args: metrics (list): List of metric touples branch (str): Branch to look up for metrics. Returns: A dict mapping keys with metrics path name and content. For example: {'metric.csv': ("value_mse deviation_mse data_...
[ "Read", "the", "content", "of", "each", "metric", "file", "and", "format", "it", "." ]
8bb21261e34c9632453e09090de7ebe50e38d341
https://github.com/iterative/dvc/blob/8bb21261e34c9632453e09090de7ebe50e38d341/dvc/repo/metrics/show.py#L203-L256
30,070
iterative/dvc
dvc/repo/__init__.py
Repo.graph
def graph(self, stages=None, from_directory=None): """Generate a graph by using the given stages on the given directory The nodes of the graph are the stage's path relative to the root. Edges are created when the output of one stage is used as a dependency in other stage. The ...
python
def graph(self, stages=None, from_directory=None): """Generate a graph by using the given stages on the given directory The nodes of the graph are the stage's path relative to the root. Edges are created when the output of one stage is used as a dependency in other stage. The ...
[ "def", "graph", "(", "self", ",", "stages", "=", "None", ",", "from_directory", "=", "None", ")", ":", "import", "networkx", "as", "nx", "from", "dvc", ".", "exceptions", "import", "(", "OutputDuplicationError", ",", "StagePathAsOutputError", ",", "Overlapping...
Generate a graph by using the given stages on the given directory The nodes of the graph are the stage's path relative to the root. Edges are created when the output of one stage is used as a dependency in other stage. The direction of the edges goes from the stage to its dependency: ...
[ "Generate", "a", "graph", "by", "using", "the", "given", "stages", "on", "the", "given", "directory" ]
8bb21261e34c9632453e09090de7ebe50e38d341
https://github.com/iterative/dvc/blob/8bb21261e34c9632453e09090de7ebe50e38d341/dvc/repo/__init__.py#L300-L404
30,071
iterative/dvc
dvc/logger.py
ColorFormatter._progress_aware
def _progress_aware(self): """Add a new line if progress bar hasn't finished""" from dvc.progress import progress if not progress.is_finished: progress._print() progress.clearln()
python
def _progress_aware(self): """Add a new line if progress bar hasn't finished""" from dvc.progress import progress if not progress.is_finished: progress._print() progress.clearln()
[ "def", "_progress_aware", "(", "self", ")", ":", "from", "dvc", ".", "progress", "import", "progress", "if", "not", "progress", ".", "is_finished", ":", "progress", ".", "_print", "(", ")", "progress", ".", "clearln", "(", ")" ]
Add a new line if progress bar hasn't finished
[ "Add", "a", "new", "line", "if", "progress", "bar", "hasn", "t", "finished" ]
8bb21261e34c9632453e09090de7ebe50e38d341
https://github.com/iterative/dvc/blob/8bb21261e34c9632453e09090de7ebe50e38d341/dvc/logger.py#L134-L140
30,072
iterative/dvc
dvc/scm/tree.py
WorkingTree.open
def open(self, path, binary=False): """Open file and return a stream.""" if binary: return open(path, "rb") return open(path, encoding="utf-8")
python
def open(self, path, binary=False): """Open file and return a stream.""" if binary: return open(path, "rb") return open(path, encoding="utf-8")
[ "def", "open", "(", "self", ",", "path", ",", "binary", "=", "False", ")", ":", "if", "binary", ":", "return", "open", "(", "path", ",", "\"rb\"", ")", "return", "open", "(", "path", ",", "encoding", "=", "\"utf-8\"", ")" ]
Open file and return a stream.
[ "Open", "file", "and", "return", "a", "stream", "." ]
8bb21261e34c9632453e09090de7ebe50e38d341
https://github.com/iterative/dvc/blob/8bb21261e34c9632453e09090de7ebe50e38d341/dvc/scm/tree.py#L45-L49
30,073
iterative/dvc
dvc/remote/s3.py
RemoteS3._list_paths
def _list_paths(self, bucket, prefix): """ Read config for list object api, paginate through list objects.""" s3 = self.s3 kwargs = {"Bucket": bucket, "Prefix": prefix} if self.list_objects: list_objects_api = "list_objects" else: list_objects_api = "list_...
python
def _list_paths(self, bucket, prefix): """ Read config for list object api, paginate through list objects.""" s3 = self.s3 kwargs = {"Bucket": bucket, "Prefix": prefix} if self.list_objects: list_objects_api = "list_objects" else: list_objects_api = "list_...
[ "def", "_list_paths", "(", "self", ",", "bucket", ",", "prefix", ")", ":", "s3", "=", "self", ".", "s3", "kwargs", "=", "{", "\"Bucket\"", ":", "bucket", ",", "\"Prefix\"", ":", "prefix", "}", "if", "self", ".", "list_objects", ":", "list_objects_api", ...
Read config for list object api, paginate through list objects.
[ "Read", "config", "for", "list", "object", "api", "paginate", "through", "list", "objects", "." ]
8bb21261e34c9632453e09090de7ebe50e38d341
https://github.com/iterative/dvc/blob/8bb21261e34c9632453e09090de7ebe50e38d341/dvc/remote/s3.py#L212-L226
30,074
iterative/dvc
dvc/command/remote.py
CmdRemoteAdd.resolve_path
def resolve_path(path, config_file): """Resolve path relative to config file location. Args: path: Path to be resolved. config_file: Path to config file, which `path` is specified relative to. Returns: Path relative to the `config_file` locat...
python
def resolve_path(path, config_file): """Resolve path relative to config file location. Args: path: Path to be resolved. config_file: Path to config file, which `path` is specified relative to. Returns: Path relative to the `config_file` locat...
[ "def", "resolve_path", "(", "path", ",", "config_file", ")", ":", "if", "os", ".", "path", ".", "isabs", "(", "path", ")", ":", "return", "path", "return", "os", ".", "path", ".", "relpath", "(", "path", ",", "os", ".", "path", ".", "dirname", "(",...
Resolve path relative to config file location. Args: path: Path to be resolved. config_file: Path to config file, which `path` is specified relative to. Returns: Path relative to the `config_file` location. If `path` is an absolute path t...
[ "Resolve", "path", "relative", "to", "config", "file", "location", "." ]
8bb21261e34c9632453e09090de7ebe50e38d341
https://github.com/iterative/dvc/blob/8bb21261e34c9632453e09090de7ebe50e38d341/dvc/command/remote.py#L18-L33
30,075
iterative/dvc
dvc/remote/base.py
RemoteBase.changed
def changed(self, path_info, checksum_info): """Checks if data has changed. A file is considered changed if: - It doesn't exist on the working directory (was unlinked) - Checksum is not computed (saving a new file) - The checkusm stored in the State is different from...
python
def changed(self, path_info, checksum_info): """Checks if data has changed. A file is considered changed if: - It doesn't exist on the working directory (was unlinked) - Checksum is not computed (saving a new file) - The checkusm stored in the State is different from...
[ "def", "changed", "(", "self", ",", "path_info", ",", "checksum_info", ")", ":", "logger", ".", "debug", "(", "\"checking if '{}'('{}') has changed.\"", ".", "format", "(", "path_info", ",", "checksum_info", ")", ")", "if", "not", "self", ".", "exists", "(", ...
Checks if data has changed. A file is considered changed if: - It doesn't exist on the working directory (was unlinked) - Checksum is not computed (saving a new file) - The checkusm stored in the State is different from the given one - There's no file in the cach...
[ "Checks", "if", "data", "has", "changed", "." ]
8bb21261e34c9632453e09090de7ebe50e38d341
https://github.com/iterative/dvc/blob/8bb21261e34c9632453e09090de7ebe50e38d341/dvc/remote/base.py#L270-L318
30,076
iterative/dvc
dvc/prompt.py
confirm
def confirm(statement): """Ask the user for confirmation about the specified statement. Args: statement (unicode): statement to ask the user confirmation about. Returns: bool: whether or not specified statement was confirmed. """ prompt = "{statement} [y/n]".format(statement=statem...
python
def confirm(statement): """Ask the user for confirmation about the specified statement. Args: statement (unicode): statement to ask the user confirmation about. Returns: bool: whether or not specified statement was confirmed. """ prompt = "{statement} [y/n]".format(statement=statem...
[ "def", "confirm", "(", "statement", ")", ":", "prompt", "=", "\"{statement} [y/n]\"", ".", "format", "(", "statement", "=", "statement", ")", "answer", "=", "_ask", "(", "prompt", ",", "limited_to", "=", "[", "\"yes\"", ",", "\"no\"", ",", "\"y\"", ",", ...
Ask the user for confirmation about the specified statement. Args: statement (unicode): statement to ask the user confirmation about. Returns: bool: whether or not specified statement was confirmed.
[ "Ask", "the", "user", "for", "confirmation", "about", "the", "specified", "statement", "." ]
8bb21261e34c9632453e09090de7ebe50e38d341
https://github.com/iterative/dvc/blob/8bb21261e34c9632453e09090de7ebe50e38d341/dvc/prompt.py#L38-L49
30,077
iterative/dvc
dvc/main.py
main
def main(argv=None): """Run dvc CLI command. Args: argv: optional list of arguments to parse. sys.argv is used by default. Returns: int: command's return code. """ args = None cmd = None try: args = parse_args(argv) if args.quiet: logger.setLev...
python
def main(argv=None): """Run dvc CLI command. Args: argv: optional list of arguments to parse. sys.argv is used by default. Returns: int: command's return code. """ args = None cmd = None try: args = parse_args(argv) if args.quiet: logger.setLev...
[ "def", "main", "(", "argv", "=", "None", ")", ":", "args", "=", "None", "cmd", "=", "None", "try", ":", "args", "=", "parse_args", "(", "argv", ")", "if", "args", ".", "quiet", ":", "logger", ".", "setLevel", "(", "logging", ".", "CRITICAL", ")", ...
Run dvc CLI command. Args: argv: optional list of arguments to parse. sys.argv is used by default. Returns: int: command's return code.
[ "Run", "dvc", "CLI", "command", "." ]
8bb21261e34c9632453e09090de7ebe50e38d341
https://github.com/iterative/dvc/blob/8bb21261e34c9632453e09090de7ebe50e38d341/dvc/main.py#L15-L52
30,078
iterative/dvc
dvc/config.py
supported_cache_type
def supported_cache_type(types): """Checks if link type config option has a valid value. Args: types (list/string): type(s) of links that dvc should try out. """ if isinstance(types, str): types = [typ.strip() for typ in types.split(",")] for typ in types: if typ not in ["re...
python
def supported_cache_type(types): """Checks if link type config option has a valid value. Args: types (list/string): type(s) of links that dvc should try out. """ if isinstance(types, str): types = [typ.strip() for typ in types.split(",")] for typ in types: if typ not in ["re...
[ "def", "supported_cache_type", "(", "types", ")", ":", "if", "isinstance", "(", "types", ",", "str", ")", ":", "types", "=", "[", "typ", ".", "strip", "(", ")", "for", "typ", "in", "types", ".", "split", "(", "\",\"", ")", "]", "for", "typ", "in", ...
Checks if link type config option has a valid value. Args: types (list/string): type(s) of links that dvc should try out.
[ "Checks", "if", "link", "type", "config", "option", "has", "a", "valid", "value", "." ]
8bb21261e34c9632453e09090de7ebe50e38d341
https://github.com/iterative/dvc/blob/8bb21261e34c9632453e09090de7ebe50e38d341/dvc/config.py#L32-L43
30,079
iterative/dvc
dvc/config.py
Config.init
def init(dvc_dir): """Initializes dvc config. Args: dvc_dir (str): path to .dvc directory. Returns: dvc.config.Config: config object. """ config_file = os.path.join(dvc_dir, Config.CONFIG) open(config_file, "w+").close() return Config(dvc...
python
def init(dvc_dir): """Initializes dvc config. Args: dvc_dir (str): path to .dvc directory. Returns: dvc.config.Config: config object. """ config_file = os.path.join(dvc_dir, Config.CONFIG) open(config_file, "w+").close() return Config(dvc...
[ "def", "init", "(", "dvc_dir", ")", ":", "config_file", "=", "os", ".", "path", ".", "join", "(", "dvc_dir", ",", "Config", ".", "CONFIG", ")", "open", "(", "config_file", ",", "\"w+\"", ")", ".", "close", "(", ")", "return", "Config", "(", "dvc_dir"...
Initializes dvc config. Args: dvc_dir (str): path to .dvc directory. Returns: dvc.config.Config: config object.
[ "Initializes", "dvc", "config", "." ]
8bb21261e34c9632453e09090de7ebe50e38d341
https://github.com/iterative/dvc/blob/8bb21261e34c9632453e09090de7ebe50e38d341/dvc/config.py#L345-L356
30,080
iterative/dvc
dvc/config.py
Config.load
def load(self, validate=True): """Loads config from all the config files. Args: validate (bool): optional flag to tell dvc if it should validate the config or just load it as is. 'True' by default. Raises: dvc.config.ConfigError: thrown if config has in...
python
def load(self, validate=True): """Loads config from all the config files. Args: validate (bool): optional flag to tell dvc if it should validate the config or just load it as is. 'True' by default. Raises: dvc.config.ConfigError: thrown if config has in...
[ "def", "load", "(", "self", ",", "validate", "=", "True", ")", ":", "self", ".", "_load", "(", ")", "try", ":", "self", ".", "config", "=", "self", ".", "_load_config", "(", "self", ".", "system_config_file", ")", "user", "=", "self", ".", "_load_con...
Loads config from all the config files. Args: validate (bool): optional flag to tell dvc if it should validate the config or just load it as is. 'True' by default. Raises: dvc.config.ConfigError: thrown if config has invalid format.
[ "Loads", "config", "from", "all", "the", "config", "files", "." ]
8bb21261e34c9632453e09090de7ebe50e38d341
https://github.com/iterative/dvc/blob/8bb21261e34c9632453e09090de7ebe50e38d341/dvc/config.py#L408-L441
30,081
iterative/dvc
dvc/config.py
Config.save
def save(self, config=None): """Saves config to config files. Args: config (configobj.ConfigObj): optional config object to save. Raises: dvc.config.ConfigError: thrown if failed to write config file. """ if config is not None: clist = [confi...
python
def save(self, config=None): """Saves config to config files. Args: config (configobj.ConfigObj): optional config object to save. Raises: dvc.config.ConfigError: thrown if failed to write config file. """ if config is not None: clist = [confi...
[ "def", "save", "(", "self", ",", "config", "=", "None", ")", ":", "if", "config", "is", "not", "None", ":", "clist", "=", "[", "config", "]", "else", ":", "clist", "=", "[", "self", ".", "_system_config", ",", "self", ".", "_global_config", ",", "s...
Saves config to config files. Args: config (configobj.ConfigObj): optional config object to save. Raises: dvc.config.ConfigError: thrown if failed to write config file.
[ "Saves", "config", "to", "config", "files", "." ]
8bb21261e34c9632453e09090de7ebe50e38d341
https://github.com/iterative/dvc/blob/8bb21261e34c9632453e09090de7ebe50e38d341/dvc/config.py#L455-L489
30,082
iterative/dvc
dvc/config.py
Config.set
def set(config, section, opt, value): """Sets specified option in the config. Args: config (configobj.ConfigObj): config to work on. section (str): section name. opt (str): option name. value: value to set option to. """ if section not in ...
python
def set(config, section, opt, value): """Sets specified option in the config. Args: config (configobj.ConfigObj): config to work on. section (str): section name. opt (str): option name. value: value to set option to. """ if section not in ...
[ "def", "set", "(", "config", ",", "section", ",", "opt", ",", "value", ")", ":", "if", "section", "not", "in", "config", ".", "keys", "(", ")", ":", "config", "[", "section", "]", "=", "{", "}", "config", "[", "section", "]", "[", "opt", "]", "...
Sets specified option in the config. Args: config (configobj.ConfigObj): config to work on. section (str): section name. opt (str): option name. value: value to set option to.
[ "Sets", "specified", "option", "in", "the", "config", "." ]
8bb21261e34c9632453e09090de7ebe50e38d341
https://github.com/iterative/dvc/blob/8bb21261e34c9632453e09090de7ebe50e38d341/dvc/config.py#L567-L579
30,083
iterative/dvc
dvc/config.py
Config.show
def show(config, section, opt): """Prints option value from the config. Args: config (configobj.ConfigObj): config to work on. section (str): section name. opt (str): option name. """ if section not in config.keys(): raise ConfigError("sec...
python
def show(config, section, opt): """Prints option value from the config. Args: config (configobj.ConfigObj): config to work on. section (str): section name. opt (str): option name. """ if section not in config.keys(): raise ConfigError("sec...
[ "def", "show", "(", "config", ",", "section", ",", "opt", ")", ":", "if", "section", "not", "in", "config", ".", "keys", "(", ")", ":", "raise", "ConfigError", "(", "\"section '{}' doesn't exist\"", ".", "format", "(", "section", ")", ")", "if", "opt", ...
Prints option value from the config. Args: config (configobj.ConfigObj): config to work on. section (str): section name. opt (str): option name.
[ "Prints", "option", "value", "from", "the", "config", "." ]
8bb21261e34c9632453e09090de7ebe50e38d341
https://github.com/iterative/dvc/blob/8bb21261e34c9632453e09090de7ebe50e38d341/dvc/config.py#L582-L598
30,084
iterative/dvc
dvc/repo/move.py
move
def move(self, from_path, to_path): """ Renames an output file and modifies the stage associated to reflect the change on the pipeline. If the output has the same name as its stage, it would also rename the corresponding stage file. E.g. Having: (hello, hello.dvc) $ dvc mo...
python
def move(self, from_path, to_path): """ Renames an output file and modifies the stage associated to reflect the change on the pipeline. If the output has the same name as its stage, it would also rename the corresponding stage file. E.g. Having: (hello, hello.dvc) $ dvc mo...
[ "def", "move", "(", "self", ",", "from_path", ",", "to_path", ")", ":", "import", "dvc", ".", "output", "as", "Output", "from", "dvc", ".", "stage", "import", "Stage", "from_out", "=", "Output", ".", "loads_from", "(", "Stage", "(", "self", ")", ",", ...
Renames an output file and modifies the stage associated to reflect the change on the pipeline. If the output has the same name as its stage, it would also rename the corresponding stage file. E.g. Having: (hello, hello.dvc) $ dvc move hello greetings Result: (greeting,...
[ "Renames", "an", "output", "file", "and", "modifies", "the", "stage", "associated", "to", "reflect", "the", "change", "on", "the", "pipeline", "." ]
8bb21261e34c9632453e09090de7ebe50e38d341
https://github.com/iterative/dvc/blob/8bb21261e34c9632453e09090de7ebe50e38d341/dvc/repo/move.py#L14-L68
30,085
iterative/dvc
dvc/version.py
_generate_version
def _generate_version(base_version): """Generate a version with information about the git repository""" pkg_dir = os.path.abspath(os.path.dirname(os.path.dirname(__file__))) if not _is_git_repo(pkg_dir) or not _have_git(): return base_version if _is_release(pkg_dir, base_version) and not _is_d...
python
def _generate_version(base_version): """Generate a version with information about the git repository""" pkg_dir = os.path.abspath(os.path.dirname(os.path.dirname(__file__))) if not _is_git_repo(pkg_dir) or not _have_git(): return base_version if _is_release(pkg_dir, base_version) and not _is_d...
[ "def", "_generate_version", "(", "base_version", ")", ":", "pkg_dir", "=", "os", ".", "path", ".", "abspath", "(", "os", ".", "path", ".", "dirname", "(", "os", ".", "path", ".", "dirname", "(", "__file__", ")", ")", ")", "if", "not", "_is_git_repo", ...
Generate a version with information about the git repository
[ "Generate", "a", "version", "with", "information", "about", "the", "git", "repository" ]
8bb21261e34c9632453e09090de7ebe50e38d341
https://github.com/iterative/dvc/blob/8bb21261e34c9632453e09090de7ebe50e38d341/dvc/version.py#L13-L27
30,086
iterative/dvc
dvc/version.py
_is_dirty
def _is_dirty(dir_path): """Check whether a git repository has uncommitted changes.""" try: subprocess.check_call(["git", "diff", "--quiet"], cwd=dir_path) return False except subprocess.CalledProcessError: return True
python
def _is_dirty(dir_path): """Check whether a git repository has uncommitted changes.""" try: subprocess.check_call(["git", "diff", "--quiet"], cwd=dir_path) return False except subprocess.CalledProcessError: return True
[ "def", "_is_dirty", "(", "dir_path", ")", ":", "try", ":", "subprocess", ".", "check_call", "(", "[", "\"git\"", ",", "\"diff\"", ",", "\"--quiet\"", "]", ",", "cwd", "=", "dir_path", ")", "return", "False", "except", "subprocess", ".", "CalledProcessError",...
Check whether a git repository has uncommitted changes.
[ "Check", "whether", "a", "git", "repository", "has", "uncommitted", "changes", "." ]
8bb21261e34c9632453e09090de7ebe50e38d341
https://github.com/iterative/dvc/blob/8bb21261e34c9632453e09090de7ebe50e38d341/dvc/version.py#L66-L72
30,087
iterative/dvc
dvc/utils/__init__.py
dict_filter
def dict_filter(d, exclude=[]): """ Exclude specified keys from a nested dict """ if isinstance(d, list): ret = [] for e in d: ret.append(dict_filter(e, exclude)) return ret elif isinstance(d, dict): ret = {} for k, v in d.items(): if ...
python
def dict_filter(d, exclude=[]): """ Exclude specified keys from a nested dict """ if isinstance(d, list): ret = [] for e in d: ret.append(dict_filter(e, exclude)) return ret elif isinstance(d, dict): ret = {} for k, v in d.items(): if ...
[ "def", "dict_filter", "(", "d", ",", "exclude", "=", "[", "]", ")", ":", "if", "isinstance", "(", "d", ",", "list", ")", ":", "ret", "=", "[", "]", "for", "e", "in", "d", ":", "ret", ".", "append", "(", "dict_filter", "(", "e", ",", "exclude", ...
Exclude specified keys from a nested dict
[ "Exclude", "specified", "keys", "from", "a", "nested", "dict" ]
8bb21261e34c9632453e09090de7ebe50e38d341
https://github.com/iterative/dvc/blob/8bb21261e34c9632453e09090de7ebe50e38d341/dvc/utils/__init__.py#L83-L105
30,088
iterative/dvc
dvc/utils/__init__.py
copyfile
def copyfile(src, dest, no_progress_bar=False, name=None): """Copy file with progress bar""" from dvc.progress import progress copied = 0 name = name if name else os.path.basename(dest) total = os.stat(src).st_size if os.path.isdir(dest): dest = os.path.join(dest, os.path.basename(src)...
python
def copyfile(src, dest, no_progress_bar=False, name=None): """Copy file with progress bar""" from dvc.progress import progress copied = 0 name = name if name else os.path.basename(dest) total = os.stat(src).st_size if os.path.isdir(dest): dest = os.path.join(dest, os.path.basename(src)...
[ "def", "copyfile", "(", "src", ",", "dest", ",", "no_progress_bar", "=", "False", ",", "name", "=", "None", ")", ":", "from", "dvc", ".", "progress", "import", "progress", "copied", "=", "0", "name", "=", "name", "if", "name", "else", "os", ".", "pat...
Copy file with progress bar
[ "Copy", "file", "with", "progress", "bar" ]
8bb21261e34c9632453e09090de7ebe50e38d341
https://github.com/iterative/dvc/blob/8bb21261e34c9632453e09090de7ebe50e38d341/dvc/utils/__init__.py#L114-L136
30,089
iterative/dvc
dvc/utils/__init__.py
dvc_walk
def dvc_walk( top, topdown=True, onerror=None, followlinks=False, ignore_file_handler=None, ): """ Proxy for `os.walk` directory tree generator. Utilizes DvcIgnoreFilter functionality. """ ignore_filter = None if topdown: from dvc.ignore import DvcIgnoreFilter ...
python
def dvc_walk( top, topdown=True, onerror=None, followlinks=False, ignore_file_handler=None, ): """ Proxy for `os.walk` directory tree generator. Utilizes DvcIgnoreFilter functionality. """ ignore_filter = None if topdown: from dvc.ignore import DvcIgnoreFilter ...
[ "def", "dvc_walk", "(", "top", ",", "topdown", "=", "True", ",", "onerror", "=", "None", ",", "followlinks", "=", "False", ",", "ignore_file_handler", "=", "None", ",", ")", ":", "ignore_filter", "=", "None", "if", "topdown", ":", "from", "dvc", ".", "...
Proxy for `os.walk` directory tree generator. Utilizes DvcIgnoreFilter functionality.
[ "Proxy", "for", "os", ".", "walk", "directory", "tree", "generator", ".", "Utilizes", "DvcIgnoreFilter", "functionality", "." ]
8bb21261e34c9632453e09090de7ebe50e38d341
https://github.com/iterative/dvc/blob/8bb21261e34c9632453e09090de7ebe50e38d341/dvc/utils/__init__.py#L251-L277
30,090
iterative/dvc
dvc/utils/__init__.py
colorize
def colorize(message, color=None): """Returns a message in a specified color.""" if not color: return message colors = { "green": colorama.Fore.GREEN, "yellow": colorama.Fore.YELLOW, "blue": colorama.Fore.BLUE, "red": colorama.Fore.RED, } return "{color}{mes...
python
def colorize(message, color=None): """Returns a message in a specified color.""" if not color: return message colors = { "green": colorama.Fore.GREEN, "yellow": colorama.Fore.YELLOW, "blue": colorama.Fore.BLUE, "red": colorama.Fore.RED, } return "{color}{mes...
[ "def", "colorize", "(", "message", ",", "color", "=", "None", ")", ":", "if", "not", "color", ":", "return", "message", "colors", "=", "{", "\"green\"", ":", "colorama", ".", "Fore", ".", "GREEN", ",", "\"yellow\"", ":", "colorama", ".", "Fore", ".", ...
Returns a message in a specified color.
[ "Returns", "a", "message", "in", "a", "specified", "color", "." ]
8bb21261e34c9632453e09090de7ebe50e38d341
https://github.com/iterative/dvc/blob/8bb21261e34c9632453e09090de7ebe50e38d341/dvc/utils/__init__.py#L288-L302
30,091
iterative/dvc
dvc/utils/__init__.py
boxify
def boxify(message, border_color=None): """Put a message inside a box. Args: message (unicode): message to decorate. border_color (unicode): name of the color to outline the box with. """ lines = message.split("\n") max_width = max(_visual_width(line) for line in lines) padding...
python
def boxify(message, border_color=None): """Put a message inside a box. Args: message (unicode): message to decorate. border_color (unicode): name of the color to outline the box with. """ lines = message.split("\n") max_width = max(_visual_width(line) for line in lines) padding...
[ "def", "boxify", "(", "message", ",", "border_color", "=", "None", ")", ":", "lines", "=", "message", ".", "split", "(", "\"\\n\"", ")", "max_width", "=", "max", "(", "_visual_width", "(", "line", ")", "for", "line", "in", "lines", ")", "padding_horizont...
Put a message inside a box. Args: message (unicode): message to decorate. border_color (unicode): name of the color to outline the box with.
[ "Put", "a", "message", "inside", "a", "box", "." ]
8bb21261e34c9632453e09090de7ebe50e38d341
https://github.com/iterative/dvc/blob/8bb21261e34c9632453e09090de7ebe50e38d341/dvc/utils/__init__.py#L305-L349
30,092
iterative/dvc
dvc/utils/__init__.py
_visual_width
def _visual_width(line): """Get the the number of columns required to display a string""" return len(re.sub(colorama.ansitowin32.AnsiToWin32.ANSI_CSI_RE, "", line))
python
def _visual_width(line): """Get the the number of columns required to display a string""" return len(re.sub(colorama.ansitowin32.AnsiToWin32.ANSI_CSI_RE, "", line))
[ "def", "_visual_width", "(", "line", ")", ":", "return", "len", "(", "re", ".", "sub", "(", "colorama", ".", "ansitowin32", ".", "AnsiToWin32", ".", "ANSI_CSI_RE", ",", "\"\"", ",", "line", ")", ")" ]
Get the the number of columns required to display a string
[ "Get", "the", "the", "number", "of", "columns", "required", "to", "display", "a", "string" ]
8bb21261e34c9632453e09090de7ebe50e38d341
https://github.com/iterative/dvc/blob/8bb21261e34c9632453e09090de7ebe50e38d341/dvc/utils/__init__.py#L352-L355
30,093
iterative/dvc
dvc/utils/__init__.py
_visual_center
def _visual_center(line, width): """Center align string according to it's visual width""" spaces = max(width - _visual_width(line), 0) left_padding = int(spaces / 2) right_padding = spaces - left_padding return (left_padding * " ") + line + (right_padding * " ")
python
def _visual_center(line, width): """Center align string according to it's visual width""" spaces = max(width - _visual_width(line), 0) left_padding = int(spaces / 2) right_padding = spaces - left_padding return (left_padding * " ") + line + (right_padding * " ")
[ "def", "_visual_center", "(", "line", ",", "width", ")", ":", "spaces", "=", "max", "(", "width", "-", "_visual_width", "(", "line", ")", ",", "0", ")", "left_padding", "=", "int", "(", "spaces", "/", "2", ")", "right_padding", "=", "spaces", "-", "l...
Center align string according to it's visual width
[ "Center", "align", "string", "according", "to", "it", "s", "visual", "width" ]
8bb21261e34c9632453e09090de7ebe50e38d341
https://github.com/iterative/dvc/blob/8bb21261e34c9632453e09090de7ebe50e38d341/dvc/utils/__init__.py#L358-L365
30,094
iterative/dvc
dvc/command/base.py
CmdBase.default_targets
def default_targets(self): """Default targets for `dvc repro` and `dvc pipeline`.""" from dvc.stage import Stage msg = "assuming default target '{}'.".format(Stage.STAGE_FILE) logger.warning(msg) return [Stage.STAGE_FILE]
python
def default_targets(self): """Default targets for `dvc repro` and `dvc pipeline`.""" from dvc.stage import Stage msg = "assuming default target '{}'.".format(Stage.STAGE_FILE) logger.warning(msg) return [Stage.STAGE_FILE]
[ "def", "default_targets", "(", "self", ")", ":", "from", "dvc", ".", "stage", "import", "Stage", "msg", "=", "\"assuming default target '{}'.\"", ".", "format", "(", "Stage", ".", "STAGE_FILE", ")", "logger", ".", "warning", "(", "msg", ")", "return", "[", ...
Default targets for `dvc repro` and `dvc pipeline`.
[ "Default", "targets", "for", "dvc", "repro", "and", "dvc", "pipeline", "." ]
8bb21261e34c9632453e09090de7ebe50e38d341
https://github.com/iterative/dvc/blob/8bb21261e34c9632453e09090de7ebe50e38d341/dvc/command/base.py#L47-L53
30,095
iterative/dvc
dvc/scm/__init__.py
SCM
def SCM(root_dir, repo=None): # pylint: disable=invalid-name """Returns SCM instance that corresponds to a repo at the specified path. Args: root_dir (str): path to a root directory of the repo. repo (dvc.repo.Repo): dvc repo instance that root_dir belongs to. Returns: dvc.scm...
python
def SCM(root_dir, repo=None): # pylint: disable=invalid-name """Returns SCM instance that corresponds to a repo at the specified path. Args: root_dir (str): path to a root directory of the repo. repo (dvc.repo.Repo): dvc repo instance that root_dir belongs to. Returns: dvc.scm...
[ "def", "SCM", "(", "root_dir", ",", "repo", "=", "None", ")", ":", "# pylint: disable=invalid-name", "if", "Git", ".", "is_repo", "(", "root_dir", ")", "or", "Git", ".", "is_submodule", "(", "root_dir", ")", ":", "return", "Git", "(", "root_dir", ",", "r...
Returns SCM instance that corresponds to a repo at the specified path. Args: root_dir (str): path to a root directory of the repo. repo (dvc.repo.Repo): dvc repo instance that root_dir belongs to. Returns: dvc.scm.base.Base: SCM instance.
[ "Returns", "SCM", "instance", "that", "corresponds", "to", "a", "repo", "at", "the", "specified", "path", "." ]
8bb21261e34c9632453e09090de7ebe50e38d341
https://github.com/iterative/dvc/blob/8bb21261e34c9632453e09090de7ebe50e38d341/dvc/scm/__init__.py#L15-L29
30,096
iterative/dvc
dvc/cli.py
get_parent_parser
def get_parent_parser(): """Create instances of a parser containing common arguments shared among all the commands. When overwritting `-q` or `-v`, you need to instantiate a new object in order to prevent some weird behavior. """ parent_parser = argparse.ArgumentParser(add_help=False) log_...
python
def get_parent_parser(): """Create instances of a parser containing common arguments shared among all the commands. When overwritting `-q` or `-v`, you need to instantiate a new object in order to prevent some weird behavior. """ parent_parser = argparse.ArgumentParser(add_help=False) log_...
[ "def", "get_parent_parser", "(", ")", ":", "parent_parser", "=", "argparse", ".", "ArgumentParser", "(", "add_help", "=", "False", ")", "log_level_group", "=", "parent_parser", ".", "add_mutually_exclusive_group", "(", ")", "log_level_group", ".", "add_argument", "(...
Create instances of a parser containing common arguments shared among all the commands. When overwritting `-q` or `-v`, you need to instantiate a new object in order to prevent some weird behavior.
[ "Create", "instances", "of", "a", "parser", "containing", "common", "arguments", "shared", "among", "all", "the", "commands", "." ]
8bb21261e34c9632453e09090de7ebe50e38d341
https://github.com/iterative/dvc/blob/8bb21261e34c9632453e09090de7ebe50e38d341/dvc/cli.py#L98-L119
30,097
iterative/dvc
dvc/cli.py
parse_args
def parse_args(argv=None): """Parses CLI arguments. Args: argv: optional list of arguments to parse. sys.argv is used by default. Raises: dvc.exceptions.DvcParserError: raised for argument parsing errors. """ parent_parser = get_parent_parser() # Main parser desc = "Data V...
python
def parse_args(argv=None): """Parses CLI arguments. Args: argv: optional list of arguments to parse. sys.argv is used by default. Raises: dvc.exceptions.DvcParserError: raised for argument parsing errors. """ parent_parser = get_parent_parser() # Main parser desc = "Data V...
[ "def", "parse_args", "(", "argv", "=", "None", ")", ":", "parent_parser", "=", "get_parent_parser", "(", ")", "# Main parser", "desc", "=", "\"Data Version Control\"", "parser", "=", "DvcParser", "(", "prog", "=", "\"dvc\"", ",", "description", "=", "desc", ",...
Parses CLI arguments. Args: argv: optional list of arguments to parse. sys.argv is used by default. Raises: dvc.exceptions.DvcParserError: raised for argument parsing errors.
[ "Parses", "CLI", "arguments", "." ]
8bb21261e34c9632453e09090de7ebe50e38d341
https://github.com/iterative/dvc/blob/8bb21261e34c9632453e09090de7ebe50e38d341/dvc/cli.py#L122-L167
30,098
iterative/dvc
dvc/utils/collections.py
apply_diff
def apply_diff(src, dest): """Recursively apply changes from src to dest. Preserves dest type and hidden info in dest structure, like ruamel.yaml leaves when parses files. This includes comments, ordering and line foldings. Used in Stage load/dump cycle to preserve comments and custom formatting. ...
python
def apply_diff(src, dest): """Recursively apply changes from src to dest. Preserves dest type and hidden info in dest structure, like ruamel.yaml leaves when parses files. This includes comments, ordering and line foldings. Used in Stage load/dump cycle to preserve comments and custom formatting. ...
[ "def", "apply_diff", "(", "src", ",", "dest", ")", ":", "Seq", "=", "(", "list", ",", "tuple", ")", "Container", "=", "(", "Mapping", ",", "list", ",", "tuple", ")", "def", "is_same_type", "(", "a", ",", "b", ")", ":", "return", "any", "(", "isin...
Recursively apply changes from src to dest. Preserves dest type and hidden info in dest structure, like ruamel.yaml leaves when parses files. This includes comments, ordering and line foldings. Used in Stage load/dump cycle to preserve comments and custom formatting.
[ "Recursively", "apply", "changes", "from", "src", "to", "dest", "." ]
8bb21261e34c9632453e09090de7ebe50e38d341
https://github.com/iterative/dvc/blob/8bb21261e34c9632453e09090de7ebe50e38d341/dvc/utils/collections.py#L10-L54
30,099
iterative/dvc
dvc/remote/ssh/connection.py
percent_cb
def percent_cb(name, complete, total): """ Callback for updating target progress """ logger.debug( "{}: {} transferred out of {}".format( name, sizeof_fmt(complete), sizeof_fmt(total) ) ) progress.update_target(name, complete, total)
python
def percent_cb(name, complete, total): """ Callback for updating target progress """ logger.debug( "{}: {} transferred out of {}".format( name, sizeof_fmt(complete), sizeof_fmt(total) ) ) progress.update_target(name, complete, total)
[ "def", "percent_cb", "(", "name", ",", "complete", ",", "total", ")", ":", "logger", ".", "debug", "(", "\"{}: {} transferred out of {}\"", ".", "format", "(", "name", ",", "sizeof_fmt", "(", "complete", ")", ",", "sizeof_fmt", "(", "total", ")", ")", ")",...
Callback for updating target progress
[ "Callback", "for", "updating", "target", "progress" ]
8bb21261e34c9632453e09090de7ebe50e38d341
https://github.com/iterative/dvc/blob/8bb21261e34c9632453e09090de7ebe50e38d341/dvc/remote/ssh/connection.py#L31-L38