Skip to content

102 separate linting workflow in ci - #103

Open
cpaniaguam wants to merge 43 commits into
mainfrom
102-separate-linting-workflow-in-ci
Open

102 separate linting workflow in ci#103
cpaniaguam wants to merge 43 commits into
mainfrom
102-separate-linting-workflow-in-ci

Conversation

@cpaniaguam

@cpaniaguam cpaniaguam commented Jul 31, 2026

Copy link
Copy Markdown
Collaborator

Summary by CodeRabbit

  • Improvements

    • Improved reliability when saving and loading training configurations, metadata, and model outputs.
    • Enhanced training workflows with clearer validation, controlled logging, and more consistent output handling.
    • Improved error messages when requested models or configurations are unavailable.
  • Quality

    • Expanded automated formatting, linting, and test checks for more dependable releases.
    • Improved test isolation with dedicated temporary directories.
    • Refined package organization and configuration handling for greater consistency.

@cpaniaguam cpaniaguam linked an issue Jul 31, 2026 that may be closed by this pull request
@coderabbitai

coderabbitai Bot commented Jul 31, 2026

Copy link
Copy Markdown

Review Change Stack

📝 Walkthrough

Walkthrough

The PR adds a dedicated Ruff workflow, updates test workflow tooling, standardizes imports and file I/O, adjusts JAX and Torch trainer logic, and improves temporary test isolation.

Changes

LANfactory maintenance updates

Layer / File(s) Summary
CI linting and test workflow updates
.github/workflows/*, pyproject.toml, .gitignore
Adds pull-request formatting and lint checks. Updates uv setup and Python matrix handling in test workflows.
Package imports and export ordering
src/lanfactory/**/__init__.py, src/lanfactory/hf/*, src/lanfactory/network_inspectors/*, tests/*
Reorders imports and public exports without changing exported symbol sets.
Serialization and temporary test data
src/lanfactory/cli/*, src/lanfactory/utils/*, tests/test_cli_utils.py, tests/conftest.py
Uses Path-based or context-managed file I/O. Tests use temporary YAML, pickle, and output paths.
JAX trainer validation and persistence
src/lanfactory/trainers/jax_mlp.py, tests/test_jax_mlp.py
Updates exception types, activation handling, training bookkeeping, MLflow error reporting, metadata persistence, and related tests.
Torch trainer loading and loop cleanup
src/lanfactory/trainers/torch_mlp.py, tests/test_torch_mlp.py
Updates pickle loading, scheduler defaults, superclass initialization, logging, batch enumeration, and unused test values.
Test isolation and helper behavior
tests/conftest.py, tests/constants.py, tests/test_mlflow_integration.py, tests/utils.py
Uses unique temporary fixture directories, adds MLflow cleanup fallback behavior, and avoids mutable default state in print_tree.

Estimated code review effort: 3 (Moderate) | ~25 minutes

Possibly related PRs

Suggested reviewers: alexanderfengler

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly identifies the main change: separating the linting workflow in CI.
Docstring Coverage ✅ Passed Docstring coverage is 85.94% which is sufficient. The required threshold is 80.00%.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch 102-separate-linting-workflow-in-ci

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@codecov

codecov Bot commented Jul 31, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 96.36364% with 2 lines in your changes missing coverage. Please review.

Files with missing lines Patch % Lines
src/lanfactory/trainers/jax_mlp.py 90.90% 1 Missing and 1 partial ⚠️
Files with missing lines Coverage Δ
src/lanfactory/cli/utils.py 100.00% <100.00%> (ø)
src/lanfactory/hf/download.py 100.00% <ø> (ø)
src/lanfactory/hf/upload.py 100.00% <ø> (ø)
src/lanfactory/network_inspectors/api.py 62.50% <100.00%> (ø)
src/lanfactory/network_inspectors/config.py 100.00% <ø> (ø)
src/lanfactory/network_inspectors/loaders.py 75.00% <100.00%> (ø)
src/lanfactory/trainers/torch_mlp.py 94.13% <100.00%> (-0.05%) ⬇️
src/lanfactory/utils/mlflow_utils.py 94.23% <100.00%> (ø)
src/lanfactory/utils/util_funs.py 100.00% <100.00%> (ø)
src/lanfactory/trainers/jax_mlp.py 93.29% <90.90%> (+0.26%) ⬆️
🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Copilot was unable to review this pull request because the user who requested the review has reached their quota limit.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Actionable comments posted: 6

Caution

Some comments are outside the diff and can’t be posted inline due to platform limitations.

⚠️ Outside diff range comments (1)
src/lanfactory/trainers/jax_mlp.py (1)

272-279: 🎯 Functional Correctness | 🟠 Major | ⚡ Quick win

Assign custom lr_dict values.

When train_config contains "lr_dict", this branch skips the only assignment to self.lr_dict. create_train_state() then raises AttributeError at self.lr_dict["init_value"]. Add an else branch that assigns train_config["lr_dict"], and cover this configuration with a test.

Suggested fix
         if "lr_dict" not in train_config:
             self.lr_dict: dict[str, float] = {
                 "init_value": 0.0002,
                 "peak_value": 0.02,
                 "end_value": 0.0,
                 "exponent": 1.0,
             }
+        else:
+            self.lr_dict = train_config["lr_dict"]
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@src/lanfactory/trainers/jax_mlp.py` around lines 272 - 279, Update the
learning-rate configuration logic near the existing self.lr_dict initialization:
add an else branch that assigns train_config["lr_dict"] to self.lr_dict when a
custom configuration is provided, preserving the current defaults otherwise. Add
a test covering custom lr_dict input and verifying create_train_state() uses it
without raising AttributeError.
🧹 Nitpick comments (3)
.github/workflows/run_tests.yml (1)

26-34: 🚀 Performance & Scalability | 🔵 Trivial | ⚡ Quick win

Do not delete the uv cache after setup-uv restores it.

setup-uv@v7 defaults to cache restoration and saving. uv uses ~/.cache/uv on Ubuntu by default. This step deletes the restored cache before uv sync, so each run loses the cache benefit and may redownload dependencies. Remove the uv cache deletion, or set enable-cache: false explicitly when a clean cache is required. (raw.githubusercontent.com)

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In @.github/workflows/run_tests.yml around lines 26 - 34, Remove the ~/.cache/uv
deletion from the “Clear all caches” workflow step so the cache restored by
setup-uv remains available to uv sync; leave the other cache cleanup commands
unchanged.
pyproject.toml (1)

123-129: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick win

Remove the global BLE001 suppression.

BLE001 covers catch-all handlers like except Exception; removing pyproject.toml's global ignore will surface these in each module that needs them. Add local # noqa: BLE001 comments only where the broad handler is intentional, or narrow the handler if possible.

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@pyproject.toml` around lines 123 - 129, Remove "BLE001" from the global
ignore list in the [tool.ruff.lint] configuration. Then address each newly
reported broad exception handler by narrowing the caught exception where
feasible, or adding a local # noqa: BLE001 only at intentionally broad handlers;
do not retain the global suppression.

Source: Coding guidelines

.github/workflows/linting_formatting.yml (1)

20-24: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick win

Pin Ruff in CI or use the project tool path.

uvx ruff runs in a transient environment and does not use pyproject.toml’s ruff>=0.14.4 constraint. Use uv run ruff after installing the dev group, or pin the CLI explicitly with uvx ruff@<version> so lint results cannot change on a fresh runner.

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In @.github/workflows/linting_formatting.yml around lines 20 - 24, Update the
“Check styling” and “Check linting” workflow steps to invoke Ruff through the
project-managed tool path with `uv run ruff`, ensuring the dev dependencies are
installed beforehand; alternatively, pin both `uvx ruff` invocations to the
project’s required Ruff version.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In @.github/workflows/run_tests.yml:
- Around line 22-25: Update the run_tests job’s astral-sh/setup-uv@v7
configuration to pass the matrix value through its python-version input, using
matrix.python-version for uv sync and uv run pytest. Add an explicit Python 3.12
version to the test_notebooks job if it does not currently define one.

In `@src/lanfactory/trainers/jax_mlp.py`:
- Around line 123-127: Update the activation-function initialization and the
forward loop around self.activation_funs so the list retains one entry per
layer, storing None for "linear" activations. In the loop, invoke
self.activation_funs[i] only when that entry is non-None while preserving the
existing final-layer/linear skip behavior.
- Around line 126-127: Update the evaluation branch in the trainer method
containing the self.train and train_output_type check to use JAX’s numerically
stable log-sigmoid transform instead of manually computing -log(1 + exp(-x)).
Preserve the existing logits condition and assignment behavior while ensuring
finite log probabilities for large negative logits.

In `@src/lanfactory/trainers/torch_mlp.py`:
- Around line 91-92: The pickle deserialization paths in the trainer, including
the loading flow around self.file_ids[file_index] and the additional sites near
lines 106, 338, and 501, must not deserialize user-controlled files directly.
Replace pickle-based data/config loading with a safe format, or validate trusted
producer signatures and permitted paths before every pickle.load or pickle.loads
call, including inputs derived from training_data_folder and model/network/train
configuration paths.
- Around line 452-454: Update the logits branch in the relevant trainer method
around the final-layer expression to use a numerically stable log-sigmoid
operation, such as F.logsigmoid(logits) or -F.softplus(-logits), instead of
manually computing -torch.log(1 + torch.exp(-logits)). Preserve the existing
behavior and output for train_output_type == "logits".

In `@tests/test_jax_mlp.py`:
- Around line 46-48: Update the docstring of
test_mlp_jax_factory_raises_type_error to state that JaxMLPFactory raises
TypeError for an invalid network_config type, matching the pytest.raises
assertion.

---

Outside diff comments:
In `@src/lanfactory/trainers/jax_mlp.py`:
- Around line 272-279: Update the learning-rate configuration logic near the
existing self.lr_dict initialization: add an else branch that assigns
train_config["lr_dict"] to self.lr_dict when a custom configuration is provided,
preserving the current defaults otherwise. Add a test covering custom lr_dict
input and verifying create_train_state() uses it without raising AttributeError.

---

Nitpick comments:
In @.github/workflows/linting_formatting.yml:
- Around line 20-24: Update the “Check styling” and “Check linting” workflow
steps to invoke Ruff through the project-managed tool path with `uv run ruff`,
ensuring the dev dependencies are installed beforehand; alternatively, pin both
`uvx ruff` invocations to the project’s required Ruff version.

In @.github/workflows/run_tests.yml:
- Around line 26-34: Remove the ~/.cache/uv deletion from the “Clear all caches”
workflow step so the cache restored by setup-uv remains available to uv sync;
leave the other cache cleanup commands unchanged.

In `@pyproject.toml`:
- Around line 123-129: Remove "BLE001" from the global ignore list in the
[tool.ruff.lint] configuration. Then address each newly reported broad exception
handler by narrowing the caught exception where feasible, or adding a local #
noqa: BLE001 only at intentionally broad handlers; do not retain the global
suppression.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro Plus

Run ID: eb1bc6fe-8321-42a1-aee1-a00e202bb286

📥 Commits

Reviewing files that changed from the base of the PR and between d725ae3 and a0157e6.

📒 Files selected for processing (30)
  • .github/workflows/linting_formatting.yml
  • .github/workflows/run_tests.yml
  • .gitignore
  • pyproject.toml
  • src/lanfactory/__init__.py
  • src/lanfactory/cli/download_hf.py
  • src/lanfactory/cli/jax_train.py
  • src/lanfactory/cli/torch_train.py
  • src/lanfactory/cli/upload_hf.py
  • src/lanfactory/cli/utils.py
  • src/lanfactory/config/__init__.py
  • src/lanfactory/hf/__init__.py
  • src/lanfactory/hf/download.py
  • src/lanfactory/hf/upload.py
  • src/lanfactory/network_inspectors/__init__.py
  • src/lanfactory/network_inspectors/api.py
  • src/lanfactory/network_inspectors/config.py
  • src/lanfactory/network_inspectors/loaders.py
  • src/lanfactory/onnx/__init__.py
  • src/lanfactory/trainers/__init__.py
  • src/lanfactory/trainers/jax_mlp.py
  • src/lanfactory/trainers/torch_mlp.py
  • src/lanfactory/utils/__init__.py
  • src/lanfactory/utils/mlflow_utils.py
  • src/lanfactory/utils/util_funs.py
  • tests/conftest.py
  • tests/constants.py
  • tests/test_cli_utils.py
  • tests/test_end_to_end_jax.py
  • tests/test_jax_mlp.py
💤 Files with no reviewable changes (4)
  • tests/constants.py
  • src/lanfactory/network_inspectors/config.py
  • src/lanfactory/cli/download_hf.py
  • src/lanfactory/cli/upload_hf.py

Comment thread .github/workflows/run_tests.yml
Comment thread src/lanfactory/trainers/jax_mlp.py
Comment thread src/lanfactory/trainers/jax_mlp.py
Comment thread src/lanfactory/trainers/torch_mlp.py
Comment thread src/lanfactory/trainers/torch_mlp.py
Comment thread tests/test_jax_mlp.py
Copilot AI review requested due to automatic review settings July 31, 2026 21:10

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Copilot was unable to review this pull request because the user who requested the review has reached their quota limit.

Bumps [actions/setup-python](https://github.com/actions/setup-python) from 6 to 7.
- [Release notes](https://github.com/actions/setup-python/releases)
- [Commits](actions/setup-python@v6...v7)

---
updated-dependencies:
- dependency-name: actions/setup-python
  dependency-version: '7'
  dependency-type: direct:production
  update-type: version-update:semver-major
...

Signed-off-by: dependabot[bot] <support@github.com>

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Pull request overview

Copilot reviewed 29 out of 30 changed files in this pull request and generated no new comments.

Suppressed comments (3)

tests/test_jax_mlp.py:47

  • The docstring still says the factory raises ValueError, but the test now asserts a TypeError. Update the docstring to match the actual exception type to avoid misleading documentation.
    """Test JaxMLPFactory raises ValueError for invalid network_config type."""

.github/workflows/run_tests.yml:64

  • The test_notebooks job no longer pins a Python version. This makes the job sensitive to GitHub runner defaults/changes and can break if the default Python is outside the supported range. Configure the Python version via setup-uv (as done in the matrix test job).
      - name: Install uv
        uses: astral-sh/setup-uv@v7
        with:
          version: "0.12.0"

.github/workflows/linting_formatting.yml:18

  • This workflow also relies on the runner’s default Python. Pinning the Python version via setup-uv improves reproducibility and avoids CI breakage when runner defaults change.
      - name: Install uv
        uses: astral-sh/setup-uv@v7
        with:
          version: "0.12.0"

Copilot AI review requested due to automatic review settings August 3, 2026 16:07

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Pull request overview

Copilot reviewed 29 out of 30 changed files in this pull request and generated no new comments.

Suppressed comments (3)

src/lanfactory/hf/init.py:11

  • Module-level imports come after assignments (DEFAULT_REPO_ID, VALID_NETWORK_TYPES), which will trigger Ruff E402 (imports not at top of file) in a default ruff configuration. Reorder so imports come immediately after the module docstring.
DEFAULT_REPO_ID = "franklab/HSSM"
VALID_NETWORK_TYPES = ("lan", "cpn", "opn")

from lanfactory.hf.download import download_model
from lanfactory.hf.model_card import (

tests/test_jax_mlp.py:47

  • The test name and assertion expect a TypeError, but the docstring still says ValueError, which is misleading when reading failures.
    """Test JaxMLPFactory raises ValueError for invalid network_config type."""

src/lanfactory/trainers/jax_mlp.py:451

  • If MLflow logging fails once, this will print an error every 100 steps for the rest of training, which can spam CI logs and slow runs. Consider disabling MLflow logging after the first failure (or gating the message behind verbose).
                    except Exception as e:
                        print(f"Failed to log metric to MLflow: {e}")

Copilot AI review requested due to automatic review settings August 4, 2026 20:11

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Pull request overview

Copilot reviewed 48 out of 49 changed files in this pull request and generated no new comments.

Suppressed comments (3)

.github/workflows/linting_formatting.yml:19

  • The lint job doesn’t pin a Python version. Since the project requires Python >=3.12 (pyproject.toml:19), this job can become non-deterministic (or fail) depending on the runner’s default Python. Pin a supported Python version the same way the test workflow does.
      - name: Install uv
        uses: astral-sh/setup-uv@v7
        with:
          version: "0.12.0"

tests/test_mlflow_integration.py:55

  • In teardown, the exception handler calls mlflow.set_tracking_uri(...) again without guarding it. If resetting the tracking URI ever fails, this can cause teardown to raise and mask the actual test failure; prefer a best-effort reset that cannot raise from teardown.
    src/lanfactory/cli/utils.py:104
  • yaml.safe_load() is being given raw bytes from Path(...).read_bytes(). PyYAML’s primary interface is text / file-like streams; decoding explicitly avoids cross-version quirks and makes the expected encoding clear.
def _get_train_network_config(yaml_config_path: str | Path | None = None, net_index=0):
    if yaml_config_path is not None:
        basic_config = yaml.safe_load(Path(yaml_config_path).read_bytes())
        network_type = basic_config["NETWORK_TYPE"]

Copilot AI review requested due to automatic review settings August 4, 2026 20:16

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Pull request overview

Copilot reviewed 48 out of 49 changed files in this pull request and generated no new comments.

Suppressed comments (4)

src/lanfactory/trainers/jax_mlp.py:128

  • -jnp.log(1 + jnp.exp(-x)) can overflow for large-magnitude logits, which can introduce inf/nan during inference. JAX exposes a numerically stable log_sigmoid for this transformation.
            if i != (len(self.layers) - 1) or self.activations[i] != "linear":
                x = self.activation_funs[i](x)

        if (not self.train) and (self.train_output_type == "logits"):
            x = -jnp.log(1 + jnp.exp(-x))

.github/workflows/linting_formatting.yml:19

  • This workflow doesn't set a Python version. Since the project targets Python >=3.12, relying on ubuntu-latest's default Python risks CI breakage when GitHub updates the runner image. Consider explicitly setting python-version in setup-uv.
      - name: Install uv
        uses: astral-sh/setup-uv@v7
        with:
          version: "0.12.0"

src/lanfactory/trainers/torch_mlp.py:455

  • -torch.log(1 + torch.exp(-x)) can overflow for large-magnitude logits (e.g., float32 when x is very negative), producing inf/nan. PyTorch provides a numerically stable implementation for log(sigmoid(x)).
        if self.training or self.train_output_type == "logprob":
            return self.layers[-1](x)
        elif self.train_output_type == "logits":
            return -torch.log(
                1 + torch.exp(-self.layers[-1](x))
            )  # log ( 1 / (1 + exp(-x))), where x = log(p / (1 - p))
        else:

.github/workflows/run_tests.yml:64

  • test_notebooks no longer sets python-version after removing actions/setup-python. If ubuntu-latest's default Python drifts below the supported range, this job can start failing unexpectedly. Pinning a Python version here would make the job deterministic.
      - name: Install uv
        uses: astral-sh/setup-uv@v7
        with:
          version: "0.12.0"

…ons/setup-python-7

chore(deps): bump actions/setup-python from 6 to 7
Copilot AI review requested due to automatic review settings August 6, 2026 02:35

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Actionable comments posted: 1

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In @.github/workflows/run_tests.yml:
- Line 64: Update the Python setup step for the test_notebooks job to use the
explicitly defined Python version "3.12" instead of the undefined
matrix.python-version reference; do not add a matrix unless this job is intended
to run across multiple versions.
🪄 Autofix

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro Plus

Run ID: 60970c9d-ac41-4bae-9034-249a9a6484ee

📥 Commits

Reviewing files that changed from the base of the PR and between bbaa34d and 26df33e.

📒 Files selected for processing (2)
  • .github/workflows/run_tests.yml
  • tests/test_bayesflow_nle_export.py
💤 Files with no reviewable changes (1)
  • tests/test_bayesflow_nle_export.py

with:
version: "0.6.5"
version: "0.12.0"
python-version: ${{ matrix.python-version }}

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

🎯 Functional Correctness | 🟠 Major | ⚡ Quick win

Use a defined Python version for test_notebooks.

test_notebooks does not define a strategy.matrix, so ${{ matrix.python-version }} is undefined. This causes the workflow validation error reported by actionlint and prevents the notebook job from selecting its intended interpreter. Set this to "3.12" or add a matrix to this job.

Proposed fix
-          python-version: ${{ matrix.python-version }}
+          python-version: "3.12"
🧰 Tools
🪛 actionlint (1.7.12)

[error] 64-64: property "python-version" is not defined in object type {}

(expression)

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In @.github/workflows/run_tests.yml at line 64, Update the Python setup step for
the test_notebooks job to use the explicitly defined Python version "3.12"
instead of the undefined matrix.python-version reference; do not add a matrix
unless this job is intended to run across multiple versions.

Source: Linters/SAST tools

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Pull request overview

Copilot reviewed 48 out of 49 changed files in this pull request and generated 1 comment.

Suppressed comments (4)

src/lanfactory/trainers/torch_mlp.py:454

  • Computing log-sigmoid via -torch.log(1 + torch.exp(-x)) is numerically unstable for large-magnitude inputs and can overflow/underflow to inf/nan. PyTorch provides a stable implementation.
        elif self.train_output_type == "logits":
            return -torch.log(
                1 + torch.exp(-self.layers[-1](x))
            )  # log ( 1 / (1 + exp(-x))), where x = log(p / (1 - p))

.github/workflows/linting_formatting.yml:18

  • The linting workflow doesn't pin a Python version. Since the project targets Python >=3.12, relying on whatever happens to be preinstalled on ubuntu-latest can cause CI to start failing when the runner image changes.
        uses: astral-sh/setup-uv@v7
        with:
          version: "0.12.0"

tests/test_mlflow_integration.py:55

  • If resetting MLflow's tracking URI fails during cleanup, the fallback mlflow.set_tracking_uri("file:./mlruns") can also raise and fail the test teardown. Teardown should not introduce new failures; swallow errors if both resets fail.
    src/lanfactory/trainers/jax_mlp.py:128
  • Computing log-sigmoid via -jnp.log(1 + jnp.exp(-x)) is numerically unstable for large-magnitude inputs and can overflow/underflow. Use JAX's stable log_sigmoid.
        if (not self.train) and (self.train_output_type == "logits"):
            x = -jnp.log(1 + jnp.exp(-x))

with:
version: "0.6.5"
version: "0.12.0"
python-version: ${{ matrix.python-version }}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Separate linting workflow in CI

3 participants