Exemplo n.º 1
0
if len(sys.argv) < 2:
    raise ValueError(
        "An experiment run guid must be passed as the first argument")

# Print run details as may be useful for debugging
experiment_run_guid = sys.argv[1]
experiment_run_details = studio_utils.get_wml_client(
).experiments.get_run_details(experiment_run_guid)
print("\nExperiment run details",
      json.dumps(experiment_run_details, sort_keys=True, indent=4))

training_runs = experiment_run_details["entity"]["training_statuses"]
for run in training_runs:
    run_guid = run["training_guid"]

    # Download logs for this training run
    remote_path = "%s/learner-1" % run_guid
    remote_log_name = "training-log.txt"
    remote_log_file = "%s/%s" % (remote_path, remote_log_name)

    local_path = os.path.join("experiment_runs", experiment_run_guid)
    os.makedirs(local_path, exist_ok=True)

    local_log_file = os.path.join(local_path, "%s-log.txt" % run_guid)
    print("Downloading log file to: %s" % local_log_file)
    studio_utils.get_cos_utils().download_file(
        project_utils.get_results_bucket(),
        remote_log_file,
        local_log_file,
        is_redownload=True)
Exemplo n.º 2
0
# Initialize various utilities that will make our lives easier
studio_utils = WatsonStudioUtils(region="us-south")
studio_utils.configure_utilities_from_file()

project_utils = ProjectUtils(studio_utils)

# Did user pass a training run?
if len(sys.argv) < 2:
    raise ValueError(
        "A training run guid must be passed as the first argument")

training_run_guid = sys.argv[1]

results_bucket = project_utils.get_results_bucket()
all_objects = studio_utils.get_cos_utils().get_all_objects_in_bucket(
    results_bucket, prefix=training_run_guid)

for object in all_objects:

    remote_file = object["Key"]
    local_file = remote_file
    local_file = os.path.join("training_runs", local_file)

    if local_file.rfind(os.sep) != len(local_file) - 1:  # not a directory

        studio_utils.get_cos_utils().download_file(results_bucket,
                                                   remote_file,
                                                   local_file,
                                                   is_redownload=True)