-
-
Save dq-hustlecoding/4bdcdc72ac4320717de8cdf8b19dd69a to your computer and use it in GitHub Desktop.
create solution for AWS Personalize
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def create_solution() -> None: | |
DSG_ARN = personalize.list_dataset_groups()['datasetGroups'][0]['datasetGroupArn'] | |
dataset_list = personalize.list_datasets( datasetGroupArn=DSG_ARN )['datasets'] | |
# solution 을 만들기 위해서는 dataset import job 이 끝나야 하므로, | |
# 만들어질 때까지 진행을 block 하는 while loop 를 만들어줍니다. | |
DSIJ_STATUS = ['', '', ''] | |
while DSIJ_STATUS != ['ACTIVE'] * 3: | |
print("WAITING... ::", DSIJ_STATUS) | |
time.sleep(10) | |
for i, dataset in enumerate(dataset_list): | |
DSIJ_STATUS[i] = personalize.list_dataset_import_jobs( datasetArn=dataset['datasetArn'] )['datasetImportJobs'][0]['status'] | |
solution_obj = personalize.create_solution( | |
name=f"solution-{int(time.time())}", | |
datasetGroupArn=DSG_ARN, | |
performAutoML=True, | |
performHPO=True | |
) | |
solution_arn = solution_obj['solutionArn'] | |
print("1. SOLUTION :: ", solution_arn) | |
time.sleep(10) | |
sv_obj = personalize.create_solution_version( | |
solutionArn=solution_arn, | |
trainingMode='FULL' | |
) | |
sv_arn = sv_obj['solutionVersionArn'] | |
print("2. Solution is Training :: ", sv_arn) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment