• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

sisl / astra-rl / 16644728304

23 Jul 2025 11:59PM UTC coverage: 44.276% (-0.3%) from 44.578%
16644728304

push

github

web-flow
Merge pull request #5 from sisl/feat/trainer

a basic trainer implementation

22 of 51 new or added lines in 4 files covered. (43.14%)

205 of 463 relevant lines covered (44.28%)

0.89 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

52.17
/src/astra_rl/logging.py
1
import logging
2✔
2
from typing import Any, Dict
2✔
3
import os
2✔
4

5
is_wandb_installed: bool = False
2✔
6
try:
2✔
7
    import wandb
2✔
8

9
    is_wandb_installed = True
2✔
10
except ImportError:
×
11
    logging.warning("Wandb not installed/found in path.")
×
12
    is_wandb_installed = False
×
13

14
logger = logging.getLogger("astra")
2✔
15

16

17
def config_logging() -> None:
2✔
18
    logging.basicConfig(
×
19
        level=logging.INFO,
20
        format="%(asctime)s - %(name)s - %(levelname)s - %(message)s",
21
        datefmt="%Y-%m-%d %H:%M:%S",
22
    )
23
    logging.getLogger("astra").setLevel(logging.DEBUG)
×
24

25

26
class ASTRAWandbLogger:
2✔
27
    """Wandb logger class for ASTRA RL.
28

29
    Checks if wandb is installed and needs WANDB_API_KEY set in the environment.
30

31
    Attributes:
32
        run (wandb.Run): The Weights & Biases run object.
33
    """
34

35
    def __init__(self, wandb_kwargs: Dict[str, Any]) -> None:
2✔
36
        """Initialize the Weights & Biases logger.
37

38
        Args:
39
            wandb_kwargs (Dict[str, Any]): Keyword arguments for configuring Weights & Biases.
40
        """
41

42
        if not is_wandb_installed:
×
43
            raise ImportError(
×
44
                "Wandb not installed. Install it with `pip install wandb` or `pip install astra_rl[wandb]` to use Weights & Biases logging."
45
            )
46

47
        if "WANDB_API_KEY" not in os.environ:
×
48
            raise EnvironmentError(
×
49
                "WANDB_API_KEY environment variable is not set. Please set it to use Weights & Biases."
50
            )
NEW
51
        self.run = wandb.init(project="astra_rl", config=wandb_kwargs)
×
52

53
    def log(self, current_logs: Dict[Any, Any]) -> None:
2✔
54
        """Log the current step to Weights & Biases.
55

56
        Args:
57
            current_logs (Dict[Any, Any]): A dictionary containing the logs for the current step.
58
        """
59

60
        self.run.log(current_logs)
×
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2026 Coveralls, Inc