Skip to content

UN-2476 [FEAT] Enhanced file deduplication in ETL/Task pipelines to ensure files with identical content but different names or folders are all processed#1369

Merged
chandrasekharan-zipstack merged 2 commits into
mainfrom
UN-2476-ensure-same-file-is-not-skipped-when-uploaded-with-different-names-by-default
Jun 18, 2025
Merged

UN-2476 [FEAT] Enhanced file deduplication in ETL/Task pipelines to ensure files with identical content but different names or folders are all processed#1369
chandrasekharan-zipstack merged 2 commits into
mainfrom
UN-2476-ensure-same-file-is-not-skipped-when-uploaded-with-different-names-by-default

Conversation

@muhammad-ali-e

@muhammad-ali-e muhammad-ali-e commented Jun 18, 2025

Copy link
Copy Markdown
Contributor

What

  • Refactors file processing logic to check both content hash and file path for new file detection (ETL/Task pipelines only).
  • Enhances file_history schema to store file path, adds unique constraints for combinations of hash/provider UUID and file path.
  • Implements backfilling of file path in legacy file history records using data from workflow_file_execution.
  • Updates helper methods and workflow logic to ensure accurate identification of new vs. previously processed files.
  • Adds migration to support new constraints and fields.
  • Note: This change only affects ETL and Task pipelines. API-based sources and destinations are excluded from the file path deduplication logic. The system maintains its legacy behavior for API connectors.

Why

  • The previous system could not always accurately identify new files, especially in cases where the same content appeared at different paths or in diffrent file names.
  • File path was missing from file_history for legacy/older records, resulting in potential duplicate processing and poor deduplication.

How

  • Updates the logic to:
    • First check file_history using both content hash/provider UUID and file path.
    • If not found, falls back to file_history without file path, and then attempts to backfill the file path from workflow_file_execution.
    • Updates legacy records with missing file paths as they are encountered.
    • Refactors helper and workflow methods to use the new logic and constraints.
  • Adds a database migration:
    • Adds file_path column to file_history.
    • Adds new and updated unique constraints for combinations including/excluding file path.

Can this PR break any existing features. If yes, please list possible items. If no, please explain why. (PS: Admins do not merge the PR without this section filled)

  • No
  • The logic is backward-compatible: legacy records are handled via fallback and are updated in-place as they are encountered.

Database Migrations

  • Adds file_path to file_history.
  • Alters and adds several unique constraints to support deduplication with/without file path.

Env Config

Relevant Docs

Related Issues or PRs

Dependencies Versions

Notes on Testing

Screenshots

Checklist

I have read and understood the Contribution Guidelines.

@muhammad-ali-e muhammad-ali-e changed the title UN-2476 [FEAT] Improved file deduplication to avoid skipping identical files with different names during ETL/TASK execution UN-2476 [FEAT] Improved file deduplication in ETL/Task pipelines to ensure all unique files are processed Jun 18, 2025
@muhammad-ali-e muhammad-ali-e marked this pull request as ready for review June 18, 2025 08:20
@muhammad-ali-e muhammad-ali-e requested review from a team, chandrasekharan-zipstack, hari-kuriakose, johnyrahul, pk-zipstack, ritwik-g and vishnuszipstack and removed request for a team June 18, 2025 08:20
Comment thread backend/workflow_manager/endpoint_v2/source.py

@chandrasekharan-zipstack chandrasekharan-zipstack 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.

LGTM - however try to address the minor comments

Comment thread backend/workflow_manager/endpoint_v2/source.py Outdated
Comment thread backend/workflow_manager/workflow_v2/models/file_history.py
@github-actions

Copy link
Copy Markdown
Contributor
filepath function $$\textcolor{#23d18b}{\tt{passed}}$$ SUBTOTAL
$$\textcolor{#23d18b}{\tt{runner/src/unstract/runner/clients/test\_docker.py}}$$ $$\textcolor{#23d18b}{\tt{test\_logs}}$$ $$\textcolor{#23d18b}{\tt{1}}$$ $$\textcolor{#23d18b}{\tt{1}}$$
$$\textcolor{#23d18b}{\tt{runner/src/unstract/runner/clients/test\_docker.py}}$$ $$\textcolor{#23d18b}{\tt{test\_cleanup}}$$ $$\textcolor{#23d18b}{\tt{1}}$$ $$\textcolor{#23d18b}{\tt{1}}$$
$$\textcolor{#23d18b}{\tt{runner/src/unstract/runner/clients/test\_docker.py}}$$ $$\textcolor{#23d18b}{\tt{test\_cleanup\_skip}}$$ $$\textcolor{#23d18b}{\tt{1}}$$ $$\textcolor{#23d18b}{\tt{1}}$$
$$\textcolor{#23d18b}{\tt{runner/src/unstract/runner/clients/test\_docker.py}}$$ $$\textcolor{#23d18b}{\tt{test\_client\_init}}$$ $$\textcolor{#23d18b}{\tt{1}}$$ $$\textcolor{#23d18b}{\tt{1}}$$
$$\textcolor{#23d18b}{\tt{runner/src/unstract/runner/clients/test\_docker.py}}$$ $$\textcolor{#23d18b}{\tt{test\_get\_image\_exists}}$$ $$\textcolor{#23d18b}{\tt{1}}$$ $$\textcolor{#23d18b}{\tt{1}}$$
$$\textcolor{#23d18b}{\tt{runner/src/unstract/runner/clients/test\_docker.py}}$$ $$\textcolor{#23d18b}{\tt{test\_get\_image}}$$ $$\textcolor{#23d18b}{\tt{1}}$$ $$\textcolor{#23d18b}{\tt{1}}$$
$$\textcolor{#23d18b}{\tt{runner/src/unstract/runner/clients/test\_docker.py}}$$ $$\textcolor{#23d18b}{\tt{test\_get\_container\_run\_config}}$$ $$\textcolor{#23d18b}{\tt{1}}$$ $$\textcolor{#23d18b}{\tt{1}}$$
$$\textcolor{#23d18b}{\tt{runner/src/unstract/runner/clients/test\_docker.py}}$$ $$\textcolor{#23d18b}{\tt{test\_get\_container\_run\_config\_without\_mount}}$$ $$\textcolor{#23d18b}{\tt{1}}$$ $$\textcolor{#23d18b}{\tt{1}}$$
$$\textcolor{#23d18b}{\tt{runner/src/unstract/runner/clients/test\_docker.py}}$$ $$\textcolor{#23d18b}{\tt{test\_run\_container}}$$ $$\textcolor{#23d18b}{\tt{1}}$$ $$\textcolor{#23d18b}{\tt{1}}$$
$$\textcolor{#23d18b}{\tt{runner/src/unstract/runner/clients/test\_docker.py}}$$ $$\textcolor{#23d18b}{\tt{test\_get\_image\_for\_sidecar}}$$ $$\textcolor{#23d18b}{\tt{1}}$$ $$\textcolor{#23d18b}{\tt{1}}$$
$$\textcolor{#23d18b}{\tt{runner/src/unstract/runner/clients/test\_docker.py}}$$ $$\textcolor{#23d18b}{\tt{test\_sidecar\_container}}$$ $$\textcolor{#23d18b}{\tt{1}}$$ $$\textcolor{#23d18b}{\tt{1}}$$
$$\textcolor{#23d18b}{\tt{TOTAL}}$$ $$\textcolor{#23d18b}{\tt{11}}$$ $$\textcolor{#23d18b}{\tt{11}}$$

@sonarqubecloud

Copy link
Copy Markdown

@chandrasekharan-zipstack chandrasekharan-zipstack merged commit 36d7e82 into main Jun 18, 2025
5 checks passed
@chandrasekharan-zipstack chandrasekharan-zipstack deleted the UN-2476-ensure-same-file-is-not-skipped-when-uploaded-with-different-names-by-default branch June 18, 2025 11:43
@muhammad-ali-e muhammad-ali-e changed the title UN-2476 [FEAT] Improved file deduplication in ETL/Task pipelines to ensure all unique files are processed UN-2476 [FEAT] Enhanced file deduplication in ETL/Task pipelines to ensure files with identical content but different names or folders are all processed Jun 19, 2025
pk-zipstack pushed a commit that referenced this pull request Aug 20, 2025
…nsure all unique files are processed (#1369)

* logic change for deduplication from contenthash to file

* Removed unused  flag; added comments for future reference
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