라이선스 업데이트

현재의 Driverless AI 라이선스가 만료된 경우, Driverless AI의 실행을 지속하고 스코어링 파이프라인을 실행하며 AWS Lambdas에 배포된 파이프라인에 액세스하기 위해서는 라이선스를 업데이트해야 합니다.

Driverless AI 라이선스 업데이트

최초로 라이선스를 추가하는 것과 비슷하게, 현재 license.sig 파일의 교체 또는 웹 UI를 통해 Driverless AI의 실행을 위한 라이선스를 업데이트할 수 있습니다.

license.sig 파일 업데이트

/opt/h2oai/dai/home/.driverlessai/license.sig 파일에서 원래 라이선스를 새 라이선스로 교체하여 라이선스 키를 업데이트합니다.

웹 UI를 통한 라이선스 업데이트

라이선스가 만료된 경우, 웹 UI에 새 라이선스를 입력하라는 메시지가 나타납니다. 이 단계는 Driverless AI 웹 UI를 통해 최초로 라이선스를 추가하는 것과 동일합니다.

스코어링 파이프라인 라이선스 업데이트

Python Scoring Pipeline의 경우 Python에서 환경 변수 설정 시, 업데이트된 라이선스 파일을 포함합니다. 라이선스 추가는 상단의 Python Scoring Pipeline 섹션을 참조하십시오.

MOJO Scoring Pipeline의 경우 업데이트된 라이선스 파일은 환경 변수 사용, JVM의 시스템 속성 사용 또는 응용 프로그램 클래스패스를 통해 지정할 수 있습니다. 이 과정은 최초로 라이선스를 추가하는 것과 같습니다. 라이선스를 추가하려면 위의 MOJO Scoring Pipeline 섹션을 참조하십시오.

AWS Lambda에서 Driverless AI 라이선스 업데이트

사용자는 AWS Lambda 상에서 프로덕션에 배포된 각각의 Driverless AI 라이선스를 수동으로 업데이트할 수 있습니다. 하지만 프로덕션에 많은 MOJO가 있는 사용자에 대해, H2O는 현재 AWS Lambda에 배포된 모든 MOJO에 대한 Driverless AI 라이선스를 업데이트해주는 스크립트를 제공합니다.

수동 업데이트

AWS Lambdas에 대한 Driverless AI 배포 파이프라인은 라이선스 키를 환경 변수로 명시적으로 설정합니다. 만료된 라이선스 키를 업데이트된 키로 교체합니다.

Update license key in production

자동 업데이트

H2O는 특정 AWS Lambda 지역에 배포된 모든 MOJO에 대한 Driverless AI 라이선스를 업데이트에 사용할 수 있는 스크립트를 제공합니다. 해당 스크립트는 모든 머신에서 실행할 수 있습니다.

요구 사항

  • 신규 Driverless AI 라이선스

  • 이 스크립트에는 다음 Python 패키지가 필요합니다.

    • boto3

    • argparse

    • os

업데이트 단계

AWS Lambda에서 MOJO 용 Driverless AI 라이선스를 업데이트하기 위해서는 다음 단계를 수행해야 합니다.

  1. 다음 코드를 복사하여 update_lambda.py 로 저장합니다.

import boto3
import argparse
import os


def load_license(license_path):
    with open(license_path, 'r') as license_file:
        license_key = license_file.read()  
        return license_key

def update_function(client, license_key, function_names): 

    for name in function_names: 
        config = client.get_function_configuration(FunctionName=name)   
        config['Environment']['Variables']['DRIVERLESS_AI_LICENSE_KEY'] = license_key    

        response = client.update_function_configuration(
                    FunctionName= name,
                    Environment= config['Environment']
                )
        print("{} License Key updated successfully! ".format(name))

def list_functions(client):
    """Get the list of potential DAI lambda function names"""
    dai_functions = []
    response = client.list_functions()
    while True:
        for f in response['Functions']:
            if 'h2oai' not in f['FunctionName']:
                continue
            dai_functions.append(f['FunctionName'])
        if 'NextMarker' in response:
            marker = response['NextMarker']
            response = client.list_functions(Marker=marker)
            continue
        break

    return dai_functions

def main():
  
    parser = argparse.ArgumentParser()    
    parser.add_argument("--list", action='store_true', required=False, help="List all DAI lambda functions on the selected region. ")
    parser.add_argument("--update_all", action='store_true', required=False, help="Update all DAI Lambda functions on the selected region. ")
    parser.add_argument("--region", type=str, required=True, help="Region where the lambda function is deployed.")
    parser.add_argument("--name", type=str, required=False, help="The name of the Lambda function. ")    
    parser.add_argument("--license_path", type=str, required=False, help="Location of the license.sig file")
    parser.add_argument("--aws_access_key_id", type=str, required=False, help="AWS Credentials")
    parser.add_argument("--aws_secret_access_key", type=str, required=False, help="AWS Credentials")    
    args = parser.parse_args()
    
    if None not in (args.aws_access_key_id, args.aws_secret_access_key):
        os.environ['aws_access_key_id'] = args.aws_access_key_id
        os.environ['aws_secret_access_key'] = args.aws_secret_access_key
    
    client = boto3.client('lambda', region_name=args.region)

    if args.update_all or args.list: 
        dai_functions = list_functions(client)
        print("H2O Driverless AI Lambda Functions in {}: {}".format(args.region, dai_functions))

    _functions = []
    if args.update_all:     
        _functions = dai_functions
    elif args.name is not None: 
        _functions.append(args.name)
    else:
        print("Please set a name of a function to update") 

    if args.license_path is not None:
        license_key = load_license(args.license_path)
    elif "DRIVERLESS_AI_LICENSE_FILE" in os.environ:
        license_key = load_license(os.environ['DRIVERLESS_AI_LICENSE_FILE'])
    elif "DRIVERLESS_AI_LICENSE_KEY" in os.environ:
        license_key = os.environ['DRIVERLESS_AI_LICENSE_KEY']
    else:    
        print("No License Found")
        return 0

    update_function(client, license_key, _functions)


if __name__ == '__main__':
    main()
  1. 스크립트를 실행하려면 다음을 제공하십시오.

  • MOJO가 배포된 지역. 배치된 MOJO를 포함하는 각각의 지역에 대해 본 스크립트를 실행해야 합니다.

  • Lambda 기능 명칭

  • Driverless AI 라이선스 경로

  • AWS 비밀 키 ID

  • AWS 비밀 액세스 키

# run the upgrade script
python update_lambda.py --update_all --region [deployed_region] --name [Lambda_function_name] --license_path [path_to_license_file] --aws_access_key_id [AWS_ACCESS_KEY_ID] --aws_secret_access_key [AWS_SECRET_ACCESS_KEY]

# optionally view the help using either python or python3
python update_lambda.py --help