Skip to content

Instantly share code, notes, and snippets.

@awaiskaleem
Last active July 14, 2020 20:08
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/227427d8b0ebcaa960ab9840143efc3b to your computer and use it in GitHub Desktop.
Save awaiskaleem/227427d8b0ebcaa960ab9840143efc3b to your computer and use it in GitHub Desktop.
def set_run(proj_id):
'''
+ This creates a file called "active_run" in S3 and writes current run_id into it.
+ If a file named "live_run" does not exist, it creates one and throws active_run into it
'''
s3_client = boto3.Session(profile_name=None).client('s3')
s3_resource = boto3.resource('s3')
artifact_bucket = 'YOUR ARTIFACT BUCKET ON S3'
active_run_id = mlflow.active_run().info.run_id
object = s3_resource.Object(artifact_bucket, 'mlflow/'+proj_id+'/active_model_run')
object.put(Body=active_run_id)
try:
s3_object = s3_client.get_object(Bucket=artifact_bucket, Key='mlflow/'+proj_id+'/live_model_run')
except botocore.exceptions.ClientError as e:
print('NO LIVE RUN FOUND, CREATING...')
object = s3_resource.Object(artifact_bucket, 'mlflow/'+proj_id+'/live_model_run')
object.put(Body=active_run_id)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment