def main()

in scikit_learn_script_mode_local_serving_no_model_artifact/scikit_learn_script_mode_local_serving_no_model_artifact.py [0:0]


def main():
    sagemaker_session = LocalSession()
    sagemaker_session.config = {'local': {'local_code': True}}

    dummy_model_file = Path("dummy.model")
    dummy_model_file.touch()

    with tarfile.open("model.tar.gz", "w:gz") as tar:
        tar.add(dummy_model_file.as_posix())

    # For local training a dummy role will be sufficient
    role = DUMMY_IAM_ROLE

    model = SKLearnModel(
        role=role,
        model_data='file://./model.tar.gz',
        framework_version='0.23-1',
        py_version='py3',
        source_dir='code',
        entry_point='inference.py'
    )

    print('Deploying endpoint in local mode')
    print(
        'Note: if launching for the first time in local mode, container image download might take a few minutes to complete.')
    predictor = model.deploy(
        initial_instance_count=1,
        instance_type='local',
    )

    do_inference_on_local_endpoint(predictor)

    print('About to delete the endpoint to stop paying (if in cloud mode).')
    predictor.delete_endpoint(predictor.endpoint_name)