Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 13 additions & 4 deletions models/rf3/src/rf3/cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,10 +23,19 @@ def fold(
configure_minimal_inference_logging()

# Find the RF3 configs directory relative to this file
# This file is at: models/rf3/src/rf3/cli.py
# Configs are at: models/rf3/configs/
rf3_package_dir = Path(__file__).parent.parent.parent # Go up to models/rf3/
config_path = str(rf3_package_dir / "configs")
# In development: models/rf3/src/rf3/cli.py -> models/rf3/configs/
# When installed: site-packages/rf3/cli.py -> site-packages/rf3/configs/
rf3_file_dir = Path(__file__).parent

# Check if we're in installed mode (configs are sibling to this file)
# or development mode (configs are ../../../configs)
if (rf3_file_dir / "configs").exists():
# Installed mode
config_path = str(rf3_file_dir / "configs")
else:
# Development mode
rf3_package_dir = rf3_file_dir.parent.parent # Go up to models/rf3/
config_path = str(rf3_package_dir / "configs")
Comment on lines +29 to +38

Copilot AI Dec 20, 2025

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The order of checking installed vs development mode is reversed compared to the RFD3 implementation pattern. This checks for installed mode first, which could cause issues if someone has the package installed and is also working in a development environment - it would use the potentially stale installed configs instead of the development ones.

Consider following the RFD3 pattern: check for the development path first, then fall back to the installed path. This ensures that when working in development mode, the development configs are always used.

Suggested change
# Check if we're in installed mode (configs are sibling to this file)
# or development mode (configs are ../../../configs)
if (rf3_file_dir / "configs").exists():
# Installed mode
config_path = str(rf3_file_dir / "configs")
else:
# Development mode
rf3_package_dir = rf3_file_dir.parent.parent # Go up to models/rf3/
config_path = str(rf3_package_dir / "configs")
rf3_package_dir = rf3_file_dir.parent.parent # Go up to models/rf3/ in development
# Check if we're in development mode (configs are ../../../configs)
# or installed mode (configs are sibling to this file)
if (rf3_package_dir / "configs").exists():
# Development mode
config_path = str(rf3_package_dir / "configs")
else:
# Installed mode
config_path = str(rf3_file_dir / "configs")

Copilot uses AI. Check for mistakes.

# Get all arguments
args = ctx.params.get("args", []) + ctx.args
Expand Down
4 changes: 3 additions & 1 deletion models/rf3/src/rf3/inference.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,9 @@

load_dotenv(override=True)

_config_path = os.path.join(os.environ["PROJECT_ROOT"], "models/rf3/configs")
_config_path = os.path.join(
os.path.dirname(os.path.dirname(os.path.dirname(__file__))), "configs"
)
Comment on lines +19 to +21

Copilot AI Dec 20, 2025

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The config path resolution differs from the cli.py pattern and doesn't properly handle both installed and development modes. While the primary CLI path (via cli.py) works because it initializes Hydra before calling run_inference, direct execution would only work in development mode.

For consistency and robustness, consider matching the cli.py pattern: check if configs exist as a sibling directory first (for installed mode), then fall back to the development path. This would make both entry points handle installation modes consistently.

Suggested change
_config_path = os.path.join(
os.path.dirname(os.path.dirname(os.path.dirname(__file__))), "configs"
)
# Prefer a sibling 'configs' directory (installed mode); fall back to the
# development layout where 'configs' lives three levels up.
_sibling_configs = os.path.join(os.path.dirname(__file__), "configs")
_dev_configs = os.path.join(
os.path.dirname(os.path.dirname(os.path.dirname(__file__))), "configs"
)
_config_path = _sibling_configs if os.path.isdir(_sibling_configs) else _dev_configs

Copilot uses AI. Check for mistakes.


@hydra.main(
Expand Down
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -99,11 +99,11 @@ build-backend = "hatchling.build"
[tool.hatch.version]
source = "vcs"
fallback-version = "0.0.0"
local-scheme = "no-local-version"

[tool.hatch.build.hooks.vcs]
version-file = "src/foundry/version.py"
tag-pattern = "^v(?P<version>.*)$"
local-scheme = "no-local-version"

[tool.hatch.metadata]
allow-direct-references = true
Expand Down
2 changes: 1 addition & 1 deletion src/foundry/utils/ddp.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

import torch
from beartype.typing import Any
from lightning_fabric.utilities import rank_zero_only
from lightning.fabric.utilities import rank_zero_only
from lightning_utilities.core.rank_zero import rank_prefixed_message
from omegaconf import DictConfig

Expand Down
2 changes: 1 addition & 1 deletion src/foundry/utils/logging.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

import pandas as pd
from beartype.typing import Any
from lightning_fabric.utilities import rank_zero_only
from lightning.fabric.utilities import rank_zero_only

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this is just a more modern import pattern for fabric which has been subsumed into lightning.

from omegaconf import DictConfig, OmegaConf
from rich.console import Console
from rich.syntax import Syntax
Expand Down