Skip to content

Commit 931bd04

Browse files
feat: change log time for wandb (#166)
* feat: change log time for wandb * feat: added log_interval_time to loggerconfig * Update optimizer_config.schema.json * chore: for checks * chore: for checks * fix: added log_interval_time to the tensorboard --------- Co-authored-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com>
1 parent a35046b commit 931bd04

File tree

7 files changed

+25
-6
lines changed

7 files changed

+25
-6
lines changed

autointent/_callbacks/base.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,12 +16,13 @@ def __init__(self) -> None:
1616
pass
1717

1818
@abstractmethod
19-
def start_run(self, run_name: str, dirpath: Path) -> None:
19+
def start_run(self, run_name: str, dirpath: Path, log_interval_time: float) -> None:
2020
"""Start a new run.
2121
2222
Args:
2323
run_name: Name of the run.
2424
dirpath: Path to the directory where the logs will be saved.
25+
log_interval_time: Sampling interval for the system monitor in seconds.
2526
"""
2627

2728
@abstractmethod

autointent/_callbacks/callback_handler.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,14 +21,15 @@ def __init__(self, callbacks: list[type[OptimizerCallback]] | None = None) -> No
2121

2222
self.callbacks = [cb() for cb in callbacks]
2323

24-
def start_run(self, run_name: str, dirpath: Path) -> None:
24+
def start_run(self, run_name: str, dirpath: Path, log_interval_time: float) -> None:
2525
"""Start a new run.
2626
2727
Args:
2828
run_name: Name of the run.
2929
dirpath: Path to the directory where the logs will be saved.
30+
log_interval_time: Sampling interval for the system monitor in seconds.
3031
"""
31-
self.call_events("start_run", run_name=run_name, dirpath=dirpath)
32+
self.call_events("start_run", run_name=run_name, dirpath=dirpath, log_interval_time=log_interval_time)
3233

3334
def start_module(self, module_name: str, num: int, module_kwargs: dict[str, Any]) -> None:
3435
"""Start a new module.

autointent/_callbacks/tensorboard.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,15 +31,17 @@ def __init__(self) -> None:
3131
)
3232
raise ImportError(msg) from None
3333

34-
def start_run(self, run_name: str, dirpath: Path) -> None:
34+
def start_run(self, run_name: str, dirpath: Path, log_interval_time: float) -> None:
3535
"""Starts a new run and sets the directory for storing logs.
3636
3737
Args:
3838
run_name: Name of the run.
3939
dirpath: Path to the directory where logs will be saved.
40+
log_interval_time: Sampling interval for the system monitor in seconds.
4041
"""
4142
self.run_name = run_name
4243
self.dirpath = dirpath
44+
self.log_interval_time = log_interval_time
4345

4446
def start_module(self, module_name: str, num: int, module_kwargs: dict[str, Any]) -> None:
4547
"""Starts a new module and initializes a TensorBoard writer for it.

autointent/_callbacks/wandb.py

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ def __init__(self) -> None:
3333

3434
self.wandb = wandb
3535

36-
def start_run(self, run_name: str, dirpath: Path) -> None:
36+
def start_run(self, run_name: str, dirpath: Path, log_interval_time: float) -> None:
3737
"""Starts a new W&B run.
3838
3939
Initializes the project name and run group. The directory path argument is not
@@ -42,10 +42,12 @@ def start_run(self, run_name: str, dirpath: Path) -> None:
4242
Args:
4343
run_name: Name of the run (used as a W&B group).
4444
dirpath: Path to store logs (not utilized in W&B logging).
45+
log_interval_time: Sampling interval for the system monitor in seconds.
4546
"""
4647
self.project_name = os.getenv("WANDB_PROJECT", "autointent")
4748
self.group = run_name
4849
self.dirpath = dirpath
50+
self.log_interval_time = log_interval_time
4951

5052
def start_module(self, module_name: str, num: int, module_kwargs: dict[str, Any]) -> None:
5153
"""Starts a new module within the W&B logging system.
@@ -63,6 +65,7 @@ def start_module(self, module_name: str, num: int, module_kwargs: dict[str, Any]
6365
group=self.group,
6466
name=f"{module_name}_{num}",
6567
config=module_kwargs,
68+
settings=self.wandb.Settings(x_stats_sampling_interval=self.log_interval_time),
6669
)
6770

6871
def log_value(self, **kwargs: dict[str, Any]) -> None:
@@ -96,6 +99,7 @@ def log_final_metrics(self, metrics: dict[str, Any]) -> None:
9699
group=self.group,
97100
name="final_metrics",
98101
config=metrics,
102+
settings=self.wandb.Settings(x_stats_sampling_interval=self.log_interval_time),
99103
)
100104

101105
self.wandb.log(metrics.get("pipeline_metrics", {}))

autointent/_pipeline/_pipeline.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -147,6 +147,7 @@ def _fit(self, context: Context, sampler: SamplerType) -> None:
147147
self.context.callback_handler.start_run(
148148
run_name=self.context.logging_config.get_run_name(),
149149
dirpath=self.context.logging_config.dirpath,
150+
log_interval_time=self.context.logging_config.log_interval_time,
150151
)
151152
for node_type in NodeType:
152153
node_optimizer = self.nodes.get(node_type, None)

autointent/configs/_optimization.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,9 @@ class LoggingConfig(BaseModel):
5151
report_to: list[REPORTERS_NAMES] | None = Field( # type: ignore[valid-type]
5252
None, description="List of callbacks to report to. If None, no callbacks will be used"
5353
)
54+
log_interval_time: float = Field(
55+
0.1, description="Sampling interval for the system monitor in seconds for Wandb logger."
56+
)
5457
"""List of callbacks to report to. If None, no callbacks will be used"""
5558

5659
@property

docs/optimizer_config.schema.json

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -297,6 +297,12 @@
297297
"default": null,
298298
"description": "List of callbacks to report to. If None, no callbacks will be used",
299299
"title": "Report To"
300+
},
301+
"log_interval_time": {
302+
"default": 0.1,
303+
"description": "Sampling interval for the system monitor in seconds for Wandb logger.",
304+
"title": "Log Interval Time",
305+
"type": "number"
300306
}
301307
},
302308
"title": "LoggingConfig",
@@ -328,7 +334,8 @@
328334
"run_name": null,
329335
"dump_modules": false,
330336
"clear_ram": false,
331-
"report_to": null
337+
"report_to": null,
338+
"log_interval_time": 0.1
332339
}
333340
},
334341
"embedder_config": {

0 commit comments

Comments
 (0)