Hey, I am using this code to log test results of my experiments, I want to update the table everytime I call this function (in multiple runs) however, the artifact is not updated, what do I need to do? (The Tables are successfully retreived and updated)
artifact_name = "results-table"
table_name = "Test/Results"
try:
api = wandb.Api()
project_name = "myproject"
entity_name = "myentity"
run_name = "myrun"
run_path = f"{entity_name}/{project_name}/{run_name}"
run = api.run(run_path)
# Retrieve artifacts logged by this run
artifacts = run.logged_artifacts(per_page=50) # Adjust 'per_page' as needed
# Find the latest version of a specific type of artifact
latest_artifact = None
for artifact in artifacts:
if not latest_artifact or artifact.updated_at > latest_artifact.updated_at:
latest_artifact = artifact
table = latest_artifact.get(table_name)
print("Retrieved Artifact")
except:
print("Create new table")
# If the artifact doesn't exist, create a new table
columns = ["ckpt", "acc yt", "acc df", "auc df", "acc nt", "auc nt",
"acc f2f", "auc f2f", "acc fs", "auc fs", "acc fsh", "auc fsh",
"acc yr", "acc cr", "acc cs", "auc cdf"]
table = wandb.Table(columns=columns)
ckpt = self.trainer.ckpt_path.rpartition("-")[-1].rpartition("=")[0]
self.test_row = [ckpt] + self.test_row
table.add_data(*self.test_row)
# Create a new artifact for logging
new_artifact = wandb.Artifact(artifact_name, type='dataset')
new_artifact.add(table, table_name)
# Increment version or manage versions here
self.logger.experiment.log_artifact(new_artifact)