fix test to check for failure better than before
-import wandb
+#!/usr/bin/env python
+"""
+Test for WB-3758.
+"""
+
import os
+import wandb
+
+
# test to ensure
-run = wandb.init(project='chdir_media_test', entity='kylegoyette')
+run = wandb.init()
+run_project = run.project
+run_id = run.id
+print("Started run {}/{}".format(run_project, run_id))
+
try:
os.makedirs('./chdir_test')
except Exception as e:
- print(e)
+ pass
+
os.chdir('./chdir_test')
# log some table data, which is saved in the media folder
pr_data = [
@@ -20,9 +32,16 @@ pr_data = [
['versicolor', 1.0, 0.0], ['versicolor', 1.0, 0.0], ['versicolor', 1.0, 0.0], ['versicolor', 1.0, 0.0],
['versicolor', 1.0, 0.0], ['versicolor', 1.0, 0.0], ['versicolor', 1.0, 0.0], ['versicolor', 1.0, 0.0]
]
+
# convert the data to a table
pr_table = wandb.Table(data=pr_data, columns=["class", "precision", "recall"])
wandb.log({'pr_table': pr_table})
-files = os.listdir(run.dir)
-# check that the media folder exists in the run dir
-assert 'media' in files
+wandb.finish()
+
+# Check results
+api = wandb.Api()
+last_run = api.run("%s/%s" % (run_project, run_id))
+media_path = last_run.summary_metrics["pr_table"]["path"]
+media_file = last_run.file(media_path)
+assert media_file.size > 0
+print("Success")
