Ejemplo n.º 1
0
def test_prepare_output_config():
    kms_key_id = "kms_key"

    config = _Job._prepare_output_config(BUCKET_NAME, kms_key_id)

    assert config["S3OutputPath"] == BUCKET_NAME
    assert config["KmsKeyId"] == kms_key_id
Ejemplo n.º 2
0
def test_prepare_output_config():
    kms_key_id = 'kms_key'

    config = _Job._prepare_output_config(BUCKET_NAME, kms_key_id)

    assert config['S3OutputPath'] == BUCKET_NAME
    assert config['KmsKeyId'] == kms_key_id
Ejemplo n.º 3
0
def test_prepare_output_config_kms_key_none():
    s3_path = BUCKET_NAME
    kms_key_id = None

    config = _Job._prepare_output_config(s3_path, kms_key_id)

    assert config["S3OutputPath"] == s3_path
    assert "KmsKeyId" not in config
Ejemplo n.º 4
0
def test_prepare_output_config_kms_key_none():
    s3_path = BUCKET_NAME
    kms_key_id = None

    config = _Job._prepare_output_config(s3_path, kms_key_id)

    assert config['S3OutputPath'] == s3_path
    assert 'KmsKeyId' not in config
Ejemplo n.º 5
0
    def _load_config(cls, inputs, auto_ml, expand_role=True, validate_uri=True):
        """Load job_config, input_config and output config from auto_ml and inputs.

        Args:
            inputs (str): S3 Uri where the training data is stored, must start
                with "s3://".
            auto_ml (AutoML): an AutoML object that user initiated.
            expand_role (str): The expanded role arn that allows for Sagemaker
                executionts.
            validate_uri (bool): indicate whether to validate the S3 uri.

        Returns (dict): a config dictionary that contains input_config, output_config,
            job_config and role information.

        """
        # JobConfig
        # InputDataConfig
        # OutputConfig

        if isinstance(inputs, AutoMLInput):
            input_config = inputs.to_request_dict()
        else:
            input_config = cls._format_inputs_to_input_config(
                inputs, validate_uri, auto_ml.compression_type, auto_ml.target_attribute_name
            )
        output_config = _Job._prepare_output_config(auto_ml.output_path, auto_ml.output_kms_key)

        role = auto_ml.sagemaker_session.expand_role(auto_ml.role) if expand_role else auto_ml.role

        stop_condition = cls._prepare_auto_ml_stop_condition(
            auto_ml.max_candidate,
            auto_ml.max_runtime_per_training_job_in_seconds,
            auto_ml.total_job_runtime_in_seconds,
        )

        auto_ml_job_config = {
            "CompletionCriteria": stop_condition,
            "SecurityConfig": {
                "EnableInterContainerTrafficEncryption": auto_ml.encrypt_inter_container_traffic
            },
        }

        if auto_ml.volume_kms_key:
            auto_ml_job_config["SecurityConfig"]["VolumeKmsKeyId"] = auto_ml.volume_kms_key
        if auto_ml.vpc_config:
            auto_ml_job_config["SecurityConfig"]["VpcConfig"] = auto_ml.vpc_config

        config = {
            "input_config": input_config,
            "output_config": output_config,
            "auto_ml_job_config": auto_ml_job_config,
            "role": role,
            "generate_candidate_definitions_only": auto_ml.generate_candidate_definitions_only,
        }
        return config