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

sisl / astra-rl / 18228107278

03 Oct 2025 04:34PM UTC coverage: 37.121% (-1.6%) from 38.697%
18228107278

push

github

web-flow
Merge pull request #22 from sisl/de/qol

Datasets, Quality-of-Life Improvements, Small Fixes

5 of 44 new or added lines in 8 files covered. (11.36%)

294 of 792 relevant lines covered (37.12%)

0.74 hits per line

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

50.0
/src/astra_rl/utils/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. e.g. run 'export WANDB_API_KEY=your_api_key_here' in your terminal."
50
            )
51

NEW
52
        project = wandb_kwargs.pop("project", "astra_rl")
×
NEW
53
        self.run = wandb.init(project=project, config=wandb_kwargs)
×
54

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

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

62
        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