Skip to content

Refactor imports to support package-based usage and improve project structure#204

Open
AdamAdham wants to merge 6 commits intomicrosoft:mainfrom
AdamAdham:refactor/imports-and-docs
Open

Refactor imports to support package-based usage and improve project structure#204
AdamAdham wants to merge 6 commits intomicrosoft:mainfrom
AdamAdham:refactor/imports-and-docs

Conversation

@AdamAdham
Copy link

Summary

This PR refactors the import structure across the codebase to enable clean package-based usage of table-transformer. The changes remove reliance on runtime path manipulation and ensure modules can be imported consistently when the project is installed as a package.

Changes

  • Refactored imports across src/, detr/, detr/datasets/, and detr/models/ to use explicit relative imports
  • Added missing __init__.py files to ensure proper package recognition
  • Updated documentation (README.md, inference.md) and added a new guide describing how to install and use the project as a local Python package

Motivation

The previous import structure assumed execution from specific working directories and relied on runtime path modification. This pattern makes it difficult to integrate the project into larger systems, such as data pipelines or services where the code is consumed as a Python package.

These changes improve:

  • Compatibility with standard Python packaging workflows
  • Reusability of the project as a library
  • Clarity and maintainability of the import structure

Scope and Impact

  • No changes to model architecture, training logic, or inference behavior
  • No functional changes to outputs or APIs
  • ⚠️ Breaking change: Scripts must now be run as modules (e.g., python -m table_transformer.src.inference) rather than direct execution

Testing

  • Verified evaluation and inference scripts run correctly after refactoring
  • Verified usage when imported as a package within a larger data processing and inference pipeline

See updated README.md and INFERENCE.md for correct command usage.

@AdamAdham
Copy link
Author

@microsoft-github-policy-service agree

AdamAdham added a commit to AdamAdham/pdf-tables-extraction that referenced this pull request Jan 25, 2026
This is microsoft's Table-Transformer repo with modification in import structure. For a better understanding of the changes done to the repo check this PR microsoft/table-transformer#204
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.

1 participant