Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
def update_learning(recall,recall_live):
s3_client = boto3.Session(profile_name=None).client('s3')
s3_resource = boto3.resource('s3')
artifact_bucket = 'YOUR ARTIFACT BUCKET ON S3'
if recall>recall_live:
# Push live champion to history
try:
object = s3_client.get_object(Bucket=artifact_bucket, Key='mlflow/'+proj_id+'/live_model_run_history')
live_hist = object['Body'].read().decode("utf-8")
except botocore.exceptions.ClientError as e:
live_hist=''
object = s3_resource.Object(artifact_bucket, 'mlflow/'+proj_id+'/live_model_run_history')
object.put(Body=live_run+" \n"+live_hist)
#Promote active challenger to live champion
object = s3_resource.Object(artifact_bucket, 'mlflow/'+proj_id+'/live_model_run')
object.put(Body=active_run)
print("INFO: New model learnt.")
return 1
else:
print("INFO: Old model has better performance, keeping it.")
return 0
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment