Skip to content

Temporarily rename "TFT" resources for grepability#620

Merged
forstmeier merged 4 commits intomasterfrom
08-22-temporarily_rename_tft_resources_for_grepability
Aug 24, 2025
Merged

Temporarily rename "TFT" resources for grepability#620
forstmeier merged 4 commits intomasterfrom
08-22-temporarily_rename_tft_resources_for_grepability

Conversation

@forstmeier
Copy link
Copy Markdown
Collaborator

@forstmeier forstmeier commented Aug 22, 2025

Overview

Changes

  • minor file/variable renaming for grepability

Comments

Just a minor tweak I cut as a separate pull request for clarity. Eventually internal/ will just need submodules (e.g. tft/) but that's easy cleanup.

Summary by CodeRabbit

  • Refactor

    • Renamed public classes to shorter names: TemporalFusionTransformerDataset → TFTDataset; TemporalFusionTransformer → TFTModel.
    • Updated training, validation, and save flows to use the new names.
    • Breaking change: update your imports and usages to the new class names.
  • Documentation

    • Added a brief class description for the dataset.
  • Tests

    • Updated test cases to reference TFTDataset and align naming with the new API.

@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai Bot commented Aug 22, 2025

Note

Other AI code review bot(s) detected

CodeRabbit has detected other AI code review bot(s) in this pull request and will avoid duplicating their findings in the review comments. This may lead to a less comprehensive review.

Walkthrough

Renamed TemporalFusionTransformerDataset to TFTDataset and TemporalFusionTransformer to TFTModel across library, training script, and tests. Updated function signatures, imports, and references to use the new class names. Added a docstring to TFTDataset. No behavioral or logic changes.

Changes

Cohort / File(s) Summary
Training script API updates
applications/models/src/models/train_tft_model.py
Replaced type hints and usage from TemporalFusionTransformerDataset/TemporalFusionTransformer to TFTDataset/TFTModel; updated read_local_data, train_model, validate_model, save_model signatures; adjusted imports and instantiation.
Internal library renames
libraries/python/src/internal/tft_dataset.py, libraries/python/src/internal/tft_model.py
Renamed classes: TemporalFusionTransformerDataset → TFTDataset (added class docstring); TemporalFusionTransformer → TFTModel; method surfaces unchanged.
Tests alignment
libraries/python/tests/test_tft_dataset.py
Updated imports and test names/usages to TFTDataset; constructor and references switched accordingly; behavior unchanged.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~10 minutes

Poem

I twitched my ears at names anew,
TFT hops where “Temporal” grew.
Datasets nibble, Models glide,
Same old paths, just shorter stride.
With tidy tags and tests in queue,
Thump-thump—renames are crisp and true. 🐇✨

Tip

🔌 Remote MCP (Model Context Protocol) integration is now available!

Pro plan users can now connect to remote MCP servers from the Integrations page. Connect with popular remote MCPs such as Notion and Linear to add more context to your reviews and chats.

✨ Finishing Touches
  • 📝 Generate Docstrings
🧪 Generate unit tests
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch 08-22-temporarily_rename_tft_resources_for_grepability

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
🪧 Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>, please review it.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.

Support

Need help? Create a ticket on our support page for assistance with any issues or questions.

CodeRabbit Commands (Invoked using PR/Issue comments)

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

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

CodeRabbit Configuration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

Status, Documentation and Community

  • Visit our Status Page to check the current availability of CodeRabbit.
  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

Copy link
Copy Markdown
Collaborator Author

forstmeier commented Aug 22, 2025

Copy link
Copy Markdown
Contributor

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

This PR temporarily renames Temporal Fusion Transformer (TFT) related classes and functions to use abbreviated "TFT" naming for better code searchability and grepability.

  • Renames TemporalFusionTransformerDataset to TFTDataset across test and application files
  • Renames TemporalFusionTransformer model class to TFTModel
  • Updates all corresponding function names and import statements to use the new abbreviated naming

Reviewed Changes

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

File Description
libraries/python/tests/test_tft_dataset.py Updates test imports and class instantiations to use TFTDataset instead of TemporalFusionTransformerDataset
libraries/python/src/internal/tft_model.py Renames main model class from TemporalFusionTransformer to TFTModel
libraries/python/src/internal/tft_dataset.py Renames dataset class from TemporalFusionTransformerDataset to TFTDataset and adds docstring
applications/models/src/models/train_tft_model.py Updates imports, type annotations, and function signatures to use new abbreviated class names

Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.

Comment thread libraries/python/src/internal/tft_dataset.py
@graphite-app
Copy link
Copy Markdown

graphite-app Bot commented Aug 22, 2025

Graphite Automations

"Assign author to pull request" took an action on this PR • (08/22/25)

1 assignee was added to this PR based on John Forstmeier's automation.

chrisaddy
chrisaddy previously approved these changes Aug 23, 2025
Base automatically changed from 08-21-implement_dataframe_validation_with_pandera to master August 24, 2025 01:09
@forstmeier forstmeier dismissed chrisaddy’s stale review August 24, 2025 01:09

The base branch was changed.

… of github.com:pocketsizefund/pocketsizefund into 08-22-temporarily_rename_tft_resources_for_grepability
Copy link
Copy Markdown
Contributor

@coderabbitai coderabbitai Bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 0

♻️ Duplicate comments (1)
libraries/python/src/internal/tft_dataset.py (1)

28-30: Docstring is too terse; expand with purpose, schema, and usage.

This mirrors a prior review asking for a meaningful docstring. Brief text hurts grepability and onboarding. Recommend a concise but informative block that captures expected columns, derived features, and what batching returns.

Apply this diff to enrich the docstring:

 class TFTDataset:
-    """Temporal fusion transformer dataset."""
+    """
+    Dataset for Temporal Fusion Transformer (TFT).
+
+    Responsibilities:
+    - Validate and preprocess structured time series data (one row per ticker × timestamp).
+    - Derive categorical time features, scale continuous features, and encode static categories.
+    - Produce train/validate/predict batches consumed by TFTModel.
+
+    Expected input columns (exact match):
+      - ticker, timestamp (ms since epoch), open_price, high_price, low_price,
+        close_price, volume, volume_weighted_average_price, sector, industry
+
+    Notable attributes:
+      - continuous_columns, categorical_columns, static_categorical_columns
+      - mappings: dict for categorical encodings
+      - data: preprocessed Polars DataFrame
+
+    Key methods:
+      - get_dimensions() -> shapes of encoder/decoder/static feature groups
+      - get_batches(data_type={"train","validate","predict"}, …) -> list[dict[str, Tensor]]
+    """
🧹 Nitpick comments (2)
libraries/python/src/internal/tft_dataset.py (1)

28-30: Introduce a temporary alias for backward compatibility (optional)

We ran a search for TemporalFusionTransformerDataset across the codebase and found no existing references. However, adding a one-line alias will protect any downstream consumers who may still be importing the old class name during the transition:

+# Temporary alias for backward compatibility during the rename window.
+TemporalFusionTransformerDataset = TFTDataset  # noqa: N816

No further verification is needed—this is purely an optional refactor to smooth migration.

libraries/python/tests/test_tft_dataset.py (1)

2-2: Test updates align with the rename; add a predict-mode invariant and consider parameterization.

  • Imports and test names reflect TFTDataset. Good.
  • In predict mode, batches shouldn’t include targets. Adding an assertion hardens the contract.
  • Consider pytest parameterization to reduce duplication across similar dataset constructions. Nice-to-have.

Apply this small assertion in the predict test:

     for batch in batches:
         assert "encoder_categorical_features" in batch
         assert "encoder_continuous_features" in batch
         assert "decoder_categorical_features" in batch
         assert "static_categorical_features" in batch
+        assert "targets" not in batch  # predict mode should not include targets

Also applies to: 5-5, 42-42, 48-48, 67-67, 79-79, 103-103

📜 Review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

💡 Knowledge Base configuration:

  • MCP integration is disabled by default for public repositories
  • Jira integration is disabled by default for public repositories
  • Linear integration is disabled by default for public repositories

You can enable these sources in your CodeRabbit configuration.

📥 Commits

Reviewing files that changed from the base of the PR and between c67ffc1 and fd74550.

📒 Files selected for processing (4)
  • applications/models/src/models/train_tft_model.py (6 hunks)
  • libraries/python/src/internal/tft_dataset.py (1 hunks)
  • libraries/python/src/internal/tft_model.py (1 hunks)
  • libraries/python/tests/test_tft_dataset.py (5 hunks)
🧰 Additional context used
🧬 Code graph analysis (3)
libraries/python/src/internal/tft_dataset.py (1)
libraries/python/src/internal/dataset.py (1)
  • TemporalFusionTransformerDataset (28-321)
libraries/python/tests/test_tft_dataset.py (2)
libraries/python/src/internal/tft_dataset.py (1)
  • TFTDataset (28-323)
libraries/python/src/internal/dataset.py (1)
  • TemporalFusionTransformerDataset (28-321)
applications/models/src/models/train_tft_model.py (2)
libraries/python/src/internal/tft_dataset.py (1)
  • TFTDataset (28-323)
libraries/python/src/internal/tft_model.py (2)
  • Parameters (19-33)
  • TFTModel (37-273)
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (1)
  • GitHub Check: Run Python tests
🔇 Additional comments (2)
libraries/python/src/internal/tft_model.py (1)

36-37: Alias and docstring added for backward compatibility

The alias and minimal docstring have been applied as suggested, and a search for remaining references to the old class name returned no matches, so no further churn is expected.

• File affected: libraries/python/src/internal/tft_model.py (around lines 36–37)
• Verified remaining references with rg -nP '\bTemporalFusionTransformer\b(?!Dataset)' (no hits)

 # https://arxiv.org/pdf/1912.09363
 class TFTModel:
     """Temporal Fusion Transformer (TFT) model (temporarily renamed for grepability)."""
@@
         self.parameters = get_parameters(self)

 # Backward-compat alias during the rename window.
 TemporalFusionTransformer = TFTModel  # noqa: N816
applications/models/src/models/train_tft_model.py (1)

10-11: Patch loss logging & confirm W&B run lifecycle

The renames to TFTDataset/TFTModel look correct. Please apply the loss‐logging fix and verify whether ending the W&B run inside train_tft_model.py is intended—otherwise, move the wandb.finish() call to after validation/save so all metrics log under one run.

• Loss logging

-    losses = model.train(
+    train_stats = model.train(
         inputs_list=batches,
         epoch_count=epoch_count,
         learning_rate=learning_rate,
     )
 
-    for loss in losses:
-        wandb_run.log({"loss": loss})
+    for loss in train_stats["losses"]:
+        wandb_run.log({"loss": loss})

• Optional logger message tweaks for consistency

-    logger.info("Training temporal fusion transformer model")
+    logger.info("Training TFT model")
@@
-    logger.info("Validating temporal fusion transformer model")
+    logger.info("Validating TFT model")
@@
-    logger.info("Saving temporal fusion transformer model")
+    logger.info("Saving TFT model")

• W&B lifecycle (in applications/models/src/models/train_tft_model.py)

  • Line 136: wandb.finish() # close active run if it exists
  • Line 138: wandb_run = wandb.init(
    Confirm whether you want to close the run before validation/save (current behavior), or defer wandb.finish() until all steps complete.

@forstmeier forstmeier merged commit 987a519 into master Aug 24, 2025
4 checks passed
@forstmeier forstmeier deleted the 08-22-temporarily_rename_tft_resources_for_grepability branch August 24, 2025 02:00
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.

3 participants