예제 #1
0
    def to_profiler_rule_config_dict(self):
        """Generates a request dictionary using the parameters provided when initializing object.

        Returns:
            dict: An portion of an API request as a dictionary.

        """
        profiler_rule_config_request = {
            "RuleConfigurationName": self.name,
            "RuleEvaluatorImage": self.image_uri,
        }

        profiler_rule_config_request.update(
            build_dict("InstanceType", self.instance_type))
        profiler_rule_config_request.update(
            build_dict("VolumeSizeInGB", self.volume_size_in_gb))
        profiler_rule_config_request.update(
            build_dict("LocalPath", self.container_local_output_path))
        profiler_rule_config_request.update(
            build_dict("S3OutputPath", self.s3_output_path))

        if self.rule_parameters:
            profiler_rule_config_request[
                "RuleParameters"] = self.rule_parameters
            for k, v in profiler_rule_config_request["RuleParameters"].items():
                profiler_rule_config_request["RuleParameters"][k] = str(v)

        return profiler_rule_config_request
예제 #2
0
    def _set_rule_parameters(source, rule_to_invoke, rule_parameters):
        """Create a dictionary of rule parameters.

        Args:
            source (str): Optional. A source file containing a rule to invoke. If provided,
                you must also provide rule_to_invoke. This can either be an S3 uri or
                a local path.
            rule_to_invoke (str): Optional. The name of the rule to invoke within the source.
                If provided, you must also provide source.
            rule_parameters (dict): Optional. A dictionary of parameters for the rule.

        Returns:
            dict: A dictionary of rule parameters.

        """
        if bool(source) ^ bool(rule_to_invoke):
            raise ValueError(
                "If you provide a source, you must also provide a rule to invoke (and vice versa)."
            )

        merged_rule_params = {}
        merged_rule_params.update(build_dict("source_s3_uri", source))
        merged_rule_params.update(build_dict("rule_to_invoke", rule_to_invoke))
        merged_rule_params.update(rule_parameters or {})

        return merged_rule_params
예제 #3
0
    def to_debugger_rule_config_dict(self):
        """Generates a request dictionary using the parameters provided when initializing object.

        Returns:
            dict: An portion of an API request as a dictionary.

        """
        debugger_rule_config_request = {
            "RuleConfigurationName": self.name,
            "RuleEvaluatorImage": self.image_uri,
        }

        debugger_rule_config_request.update(
            build_dict("InstanceType", self.instance_type))
        debugger_rule_config_request.update(
            build_dict("VolumeSizeInGB", self.volume_size_in_gb))
        debugger_rule_config_request.update(
            build_dict("LocalPath", self.container_local_output_path))
        debugger_rule_config_request.update(
            build_dict("S3OutputPath", self.s3_output_path))
        debugger_rule_config_request.update(
            build_dict("RuleParameters", self.rule_parameters))

        return debugger_rule_config_request