Skip to content

Commit

Permalink
Fix issue with redundant initializing wandb
Browse files Browse the repository at this point in the history
  • Loading branch information
Eve-ning committed Jan 8, 2024
1 parent 3794501 commit c8b050a
Showing 1 changed file with 7 additions and 7 deletions.
14 changes: 7 additions & 7 deletions tests/model_tests/chestnut_dec_may/train.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
This test is done by training a model on the 20201218 dataset, then testing on
the 20210510 dataset.
"""
import os

# Uncomment this to run the W&B monitoring locally
# import os
Expand Down Expand Up @@ -41,9 +42,6 @@ def main(
val_iters=15,
lr=1e-3,
):
run = wandb.init()
logger = WandbLogger(name="chestnut_dec_may", project="frdc")

# Prepare the dataset
train_lab_ds = ds.chestnut_20201218(transform=train_preprocess)
train_unl_ds = ds.chestnut_20201218.unlabelled(
Expand Down Expand Up @@ -87,7 +85,9 @@ def main(
monitor="val_loss", mode="min", save_top_k=1
),
],
logger=logger,
logger=(
logger := WandbLogger(name="chestnut_dec_may", project="frdc")
),
)

m = InceptionV3MixMatchModule(
Expand All @@ -103,7 +103,7 @@ def main(
with open(Path(__file__).parent / "report.md", "w") as f:
f.write(
f"# Chestnut Nature Park (Dec 2020 vs May 2021)\n"
f"- Results: [WandB Report]({run.get_url()})"
f"- Results: [WandB Report]({wandb.run.get_url()})"
)

y_true, y_pred = predict(
Expand Down Expand Up @@ -133,8 +133,8 @@ def main(
VAL_ITERS = 15
LR = 1e-3

assert wandb.run is None
wandb.setup(wandb.Settings(program=__name__, program_relpath=__name__))
wandb.login(key=os.environ["WANDB_API_KEY"])

main(
batch_size=BATCH_SIZE,
epochs=EPOCHS,
Expand Down

0 comments on commit c8b050a

Please sign in to comment.