Skip to content
This repository was archived by the owner on Sep 26, 2020. It is now read-only.

Commit f72c689

Browse files
committed
Add log file uploading
1 parent 4743e1e commit f72c689

1 file changed

Lines changed: 32 additions & 0 deletions

File tree

axon/client.py

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -695,6 +695,22 @@ def impl_remove_heartbeat(job_id, bucket_name, region):
695695
print("Removed heartbeat file in: {}\n".format(remote_path))
696696

697697

698+
def impl_set_training_log_file(job_id, log_file, bucket_name, region):
699+
"""
700+
Sets the training log file contents to the contents of the log file.
701+
702+
:param job_id: The unique Job ID.
703+
:param log_file: The log file to read from.
704+
:param bucket_name: The S3 bucket name.
705+
:param region: The region, or `None` to pull the region from the environment.
706+
"""
707+
client = make_client("s3", region)
708+
remote_path = create_progress_prefix(job_id) + "/log.txt"
709+
with open(log_file, "r") as f:
710+
client.put_object(Body=f.read(), Bucket=bucket_name, Key=remote_path)
711+
print("Set training log file in: {}\n".format(remote_path))
712+
713+
698714
def impl_upload_training_results(job_id, output_dir, bucket_name, region):
699715
client = make_client("s3", region)
700716
files_to_upload = [os.path.join(output_dir, it) for it in os.listdir(output_dir)]
@@ -913,6 +929,22 @@ def remove_heartbeat(job_id, region):
913929
impl_remove_heartbeat(job_id, ensure_s3_bucket(region), region)
914930

915931

932+
@cli.command(name="set-training-log-file")
933+
@click.argument("job-id")
934+
@click.argument("log-file")
935+
@click.option("--region", help="The region to connect to.",
936+
type=click.Choice(region_choices))
937+
def set_training_log_file(job_id, log_file, region):
938+
"""
939+
Sets the training log file contents to the contents of the log file.
940+
941+
JOB_ID The unique Job ID.
942+
943+
LOG_FILE The log file to read from.
944+
"""
945+
impl_set_training_log_file(job_id, log_file, ensure_s3_bucket(region), region)
946+
947+
916948
@cli.command(name="upload-training-results")
917949
@click.argument("job-id")
918950
@click.argument("output-dir")

0 commit comments

Comments
 (0)