Skip to content

Commit

Permalink
fix Duplicate identifier 'runId'
Browse files Browse the repository at this point in the history
  • Loading branch information
visualDust committed Dec 21, 2023
1 parent 8e301b1 commit 35932eb
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 16 deletions.
33 changes: 22 additions & 11 deletions docs/docs/howto/index.mdx
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
---
title: An minimal example
title: Get started with an example
sidebar_position: 1
---

Expand Down Expand Up @@ -28,8 +28,10 @@ import os
import time
from random import random
from time import sleep

import numpy as np
from PIL import Image

import neetbox
from neetbox import logger

Expand Down Expand Up @@ -134,11 +136,11 @@ def run_test_mention(text: str):


@neetbox.watch("train")
def train(epoch):
def train(step):
loss, acc = random(), random()
neetbox.add_scalar("sin", epoch, math.sin(epoch * 0.1))
neetbox.add_scalar("cos", epoch, math.cos(epoch * 0.1))
return {"loss": loss, "acc": acc}
neetbox.add_scalar("sin", step, math.sin(step * 0.1))
neetbox.add_scalar("cos", step, math.cos(step * 0.1))
return {"global_step": step, "loss": loss, "acc": acc}


@neetbox.listen("train") # listen to train
Expand All @@ -155,14 +157,23 @@ def log_with_some_prefix():
logger.err("some error")


train_config = {"epoch": 9999}
train_config = {"epoch": 99, "batch_size": 10}


def train_epoch(config):
def train_batch_in_epoch(current_epoch, batch_size):
for i in neetbox.progress(batch_size):
time.sleep(1)
train(current_epoch * batch_size + i)

with neetbox.progress(config["epoch"]) as epoch:
for e in epoch:
train_batch_in_epoch(current_epoch=e, batch_size=config["batch_size"])


if __name__ == "__main__":
neetbox.add_hyperparams(train_config)
with neetbox.progress(train_config["epoch"]) as epochs:
for i in epochs:
sleep(1)
train(i)
train_epoch(train_config)

```

Expand All @@ -180,7 +191,7 @@ visit [http://localhost:5000/](http://localhost:5000/) and see the dashboard. Yo
- [x] send images or tensors as images to frontend
- [x] send scalars to show a line chart
- [x] check hardware usage
- [x] register python functions as buttons and run remote python codes in dashboard
- [x] register python functions as buttons and run remote python codes in dashboard
- [x] manage projects and runs, as well as check history runs
- [x] more features check the doc

Expand Down
5 changes: 0 additions & 5 deletions frontend/src/utils/condition.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,13 +7,8 @@ export interface Condition {
order?: Record<string, "ASC" | "DESC">;
limit?: number;
runId?: string;
runId?: string;
}

export function createCondition(condition: Condition) {
if (condition.runId) {
condition.runId = condition.runId;
delete condition.runId;
}
return new URLSearchParams({ condition: JSON.stringify({ ...condition }) }).toString();
}

0 comments on commit 35932eb

Please sign in to comment.