def do_eager_lazy()

in amzn-smt-prediction/scripts/generate_predictions.py [0:0]


def do_eager_lazy(problem_file, endpoint_eager_v_lazy):

    # Check for eager-arithmetic executable
    if not isfile(path_to_ea_exec):
        print("ERROR: In order to use this script (as configured), you must compile a binary for 'amzn-smt-eager-arithmetic' (and have it in the right place).")
        print("It is necessary to generate the features for problems of the theory type specified in " + config_file)
        print("From the 'rust-smt-ir/amzn-smt-eager-arithmetic' directory, run:")
        print("cargo build --release --target-dir .")
        exit(1)

    # Check that the config file includes a reference to a SageMaker endpoint for the Eager v. Lazy Model
    if endpoint_eager_v_lazy == None:
        missing_endpoint_error(theory, "endpoint_eager_v_lazy")
        exit(1)


    ##### GENERATE FEATURES #####

    # Generate statistics for feature set
    # Cuts off after 5 seconds, after which encoding is generally done and it is on to solving, which isn't necessary here
    if v == 'Full': print("Generating features... (calling amzn-smt-eager-arithmetic)")
    try:
        raw_out = subprocess.run([path_to_ea_exec, "solve", problem_file], capture_output=True, text=True, timeout=ea_timeout)
        out = raw_out.stdout.strip()
    except subprocess.TimeoutExpired as e:
        out = str(e.stdout, 'utf-8')
    if v == 'Full': print("Done.\n")

    # Parse the output to generate the features
    feature_string = parse_eager_encoding_output(out, problem_file)
    # Convert features to list of integers
    features = [int(x) for x in feature_string.split(',')]

    if v == 'Full': print("Feature Vector: " + get_eager_lazy_feature_string(features) + "\n")


    ##### GENERATE INFERENCE #####

    # Create a Predictor object which references the endpoint in AWS SageMaker
    predictor = Predictor(endpoint_eager_v_lazy, serializer=CSVSerializer())
    # Call the endpoint to get a prediction for our example
    prediction = get_prediction(predictor, features)

    confidence = round(max(prediction) * 100, 2)
    best_solver = outputs_eager_v_lazy[np.argmax(prediction)]

    if v == 'Full': print("Possible Outputs: " + str(outputs_eager_v_lazy))
    if v == 'Full': print("Probabilities: " + str(prediction) + "\n")

    if v == 'Full' or v == 'Pretty': 
        print(start_green + "The Eager v. Lazy Model predicted -- with " + str(confidence) + "% confidence -- that the fastest method to solve this benchmark is: " + best_solver + end_green)
    elif v == 'Vector':
        print(prediction)