Skip to content

Instantly share code, notes, and snippets.

@awaiskaleem
Last active July 14, 2020 19:56
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save awaiskaleem/81fcf0ed227c718fb3fe03b6c975260e to your computer and use it in GitHub Desktop.
Save awaiskaleem/81fcf0ed227c718fb3fe03b6c975260e to your computer and use it in GitHub Desktop.
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