add hack_utils with artifact_tools.py and refactor project one more time

This commit is contained in:
hobogalaxy committed 2020-11-20 01:20:41 +01:00
1 parent 7c922e4ffe
commit 6761d81353
12 files changed
+337 -25

No files matched your search

+49
View File
@@ -0,0 +1,49 @@
import wandb
import os
def upload_artifact():
WANDB_PROJECT = "hackathon_template_test"
WANDB_TEAM = "kino"
FILES_TO_UPLOAD_PATH = "../data/skyhacks"
ARTIFACT_NAME = "skyhacks-dataset"
TYPE = "dataset" # type can be anything but we recommend sticking to "dataset" / "model" / "result"
# Set project which will own the artifact
os.mkdir("../logs") if not os.path.exists("../logs") else None
run = wandb.init(
project=WANDB_PROJECT,
entity=WANDB_TEAM,
dir="../logs",
name="artifact_upload",
job_type="artifact"
)
# Recursively add all files from a directory
artifact = wandb.Artifact(
name=ARTIFACT_NAME,
type=TYPE
)
artifact.add_dir(FILES_TO_UPLOAD_PATH)
# Upload artifact
run.log_artifact(artifact, aliases=["latest"])
print("Files are being uploaded now...")
def download_artifact():
SAVE_DIR = "../data/skyhacks"
ARTIFACT = "kino/hackathon_template_test/skyhacks-dataset:v0"
# Choose what artifact you want to download
api = wandb.Api()
artifact = api.artifact(ARTIFACT)
# Download artifact
artifact.download(root=SAVE_DIR)
print("Files are being downloaded now...")
if __name__ == "__main__":
# upload_artifact()
download_artifact()