Last active
July 14, 2020 20:08
-
-
Save awaiskaleem/227427d8b0ebcaa960ab9840143efc3b to your computer and use it in GitHub Desktop.
This file contains hidden or 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 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