Skip to content

Conversation

@verdhanyash
Copy link
Contributor

@verdhanyash verdhanyash commented Jan 25, 2026

Summary

Implements a tqdm progress bar for training using a Rust-to-Python callback mechanism. This preserves performance by keeping the training loop entirely in Rust while providing live progress updates to Python.

Closes #25

Changes

Rust Core

  • lib.rs: Added optional progress_callback parameter to train()
  • model.rs: Added train_with_callback() method that calls the provided closure after each epoch
  • Architecture: Training loop remains in Rust; no Python-Rust boundary crossing per epoch

Python API

  • api.py: Creates a tqdm progress bar and passes a callback function to Rust
  • Training runs in a single Rust call (epochs=100 passed directly)

Dependencies

  • Added tqdm>=4.64.0 to requirements

Testing

  • Updated unit test confirms train() is called once for all epochs
  • Progress bar updates correctly with loss value.

ScreenShot

image image

)

- Add tqdm>=4.64.0 to dependencies

- Implement Rust-side progress reporting via callback

- Modify Model.train() to single Rust call with callback

- Add unit test for callback integration
Copilot AI review requested due to automatic review settings January 25, 2026 03:23
@github-actions
Copy link

Validation Successful!

This pull request has been verified and linked to issue #25. The system is now synchronizing metadata from the referenced issue. Kindly await maintainer review of your changes.

@github-actions
Copy link

Thank you for opening this PR! Our automated system is currently verifying the PR requirements.
Internal Discussion: Discord

@github-actions github-actions bot added area: python-api The user-facing Python library, Model class, and top-level CLI. dx Developer Experience; tasks that improve the workflow or output for users and contributors. Easy Simple fixes for beginners. labels Jan 25, 2026
@github-actions
Copy link

Validation Successful!

This pull request has been verified and linked to issue #25. The system is now synchronizing metadata from the referenced issue. Kindly await maintainer review of your changes.

1 similar comment
@github-actions
Copy link

Validation Successful!

This pull request has been verified and linked to issue #25. The system is now synchronizing metadata from the referenced issue. Kindly await maintainer review of your changes.

- Allow deprecated with_gil (temporary fix)

- Allow unused train method in model.rs
Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Adds a tqdm-based training progress bar by introducing a Rust→Python progress callback, keeping the epoch loop in Rust while updating progress display in Python.

Changes:

  • Extend the PyO3 EtnaModel.train() binding to accept an optional progress_callback.
  • Add SimpleNN::train_with_callback() to invoke a callback after each epoch.
  • Update Python Model.train() to use tqdm + callback, add tqdm dependency, and add a mock-based test.

Reviewed changes

Copilot reviewed 6 out of 7 changed files in this pull request and generated 9 comments.

Show a summary per file
File Description
etna_core/src/lib.rs Adds progress_callback parameter to the PyO3 train() binding and invokes a Python callback from Rust.
etna_core/src/model.rs Introduces train_with_callback() to run training while reporting per-epoch progress.
etna/api.py Wraps training with a tqdm progress bar and passes a callback into Rust.
tests/test_tqdm_progress.py Adds a mock-based test ensuring train() is called once and a callback is passed.
setup.py Adds tqdm to install requirements.
requirements.txt Adds tqdm dependency.
pyproject.toml Adds tqdm to project dependencies.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
@github-actions
Copy link

Validation Successful!

This pull request has been verified and linked to issue #25. The system is now synchronizing metadata from the referenced issue. Kindly await maintainer review of your changes.

Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
@github-actions
Copy link

Validation Successful!

This pull request has been verified and linked to issue #25. The system is now synchronizing metadata from the referenced issue. Kindly await maintainer review of your changes.

Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
@github-actions
Copy link

Validation Successful!

This pull request has been verified and linked to issue #25. The system is now synchronizing metadata from the referenced issue. Kindly await maintainer review of your changes.

Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
@github-actions
Copy link

Validation Successful!

This pull request has been verified and linked to issue #25. The system is now synchronizing metadata from the referenced issue. Kindly await maintainer review of your changes.

Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
@github-actions
Copy link

Validation Successful!

This pull request has been verified and linked to issue #25. The system is now synchronizing metadata from the referenced issue. Kindly await maintainer review of your changes.

- Use py argument directly instead of with_gil (fixes deprecation and syntax error)

- Ensure closure captures py correctly for safe callback execution
@github-actions
Copy link

Validation Successful!

This pull request has been verified and linked to issue #25. The system is now synchronizing metadata from the referenced issue. Kindly await maintainer review of your changes.

1 similar comment
@github-actions
Copy link

Validation Successful!

This pull request has been verified and linked to issue #25. The system is now synchronizing metadata from the referenced issue. Kindly await maintainer review of your changes.

@github-actions
Copy link

Validation Successful!

This pull request has been verified and linked to issue #25. The system is now synchronizing metadata from the referenced issue. Kindly await maintainer review of your changes.

Copy link
Contributor

@debug-soham debug-soham left a comment

Choose a reason for hiding this comment

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

@verdhanyash

Suggested Actions:

  • Update api.py to include the actual tqdm logic (imports and progress bar handling).
  • Restore the hidden_layers: list architecture in api.py to prevent system crashes.
  • Clean up model.rs by refactoring the train method to reuse the callback logic.

The test_tqdm_progress.py script is a great addition. Once the api.py regressions are fixed, re-submit for approval.

@github-actions
Copy link

github-actions bot commented Feb 1, 2026

Validation Successful!

This pull request has been verified and linked to issue #25. The system is now synchronizing metadata from the referenced issue. Kindly await maintainer review of your changes.

@github-actions github-actions bot requested a review from debug-soham February 1, 2026 11:59
@verdhanyash
Copy link
Contributor Author

@debug-soham
Thankyou for the feedback!!

Summary

Addresses all suggested actions from the previous review.

Closes #25

Suggested Actions Addressed

  1. ✅ Update api.py with tqdm logic
    Added from tqdm import tqdm import
    Created progress bar with callback: pbar = tqdm(total=epochs, desc="Training")
    Callback updates bar on each epoch with loss value
  2. ✅ Restore hidden_layers: list architecture
    hidden_layers: list = [16] parameter in
    init
    Stored as self.hidden_layers and passed to Rust core
    Prevents system crashes with dynamic layer configuration
  3. ✅ Clean up model.rs - refactor train method
    train()
    now delegates to
    train_with_callback()
    with a default print callback
    Eliminated 84 lines of duplicated code
    Single source of truth for training logic
  4. ✅ test_tqdm_progress.py script
    Already present and passing
    Validates single Rust call for all epochs
    Confirms callback-based progress reporting works

Testing

38/38 Python tests passed
28/28 Rust tests passed

Screenshot

Screenshot 2026-02-01 172647 Screenshot 2026-02-01 172522

@debug-soham debug-soham added the SWoC26 Contributions specifically for the Social Winter of Code program. label Feb 3, 2026
Copy link
Collaborator

@Aamod007 Aamod007 left a comment

Choose a reason for hiding this comment

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

@verdhanyash Good work, Approved!

@debug-soham debug-soham merged commit 2b7ab28 into etsi-ai:main Feb 9, 2026
2 checks passed
@github-actions
Copy link

github-actions bot commented Feb 9, 2026

This PR has been successfully merged. We appreciate your effort in improving the library and look forward to your future contributions to the Etsi AI ecosystem.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area: python-api The user-facing Python library, Model class, and top-level CLI. dx Developer Experience; tasks that improve the workflow or output for users and contributors. Easy Simple fixes for beginners. SWoC26 Contributions specifically for the Social Winter of Code program.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Python] Progress Bar (tqdm) for Training

3 participants