Skip to content

[DCP Ingestion] Namespace support in preprocessor#686

Open
gmechali wants to merge 36 commits into
datacommonsorg:masterfrom
gmechali:namespace
Open

[DCP Ingestion] Namespace support in preprocessor#686
gmechali wants to merge 36 commits into
datacommonsorg:masterfrom
gmechali:namespace

Conversation

@gmechali

Copy link
Copy Markdown
Contributor

No description provided.

@codacy-production

codacy-production Bot commented Jul 24, 2026

Copy link
Copy Markdown

Not up to standards ⛔

🔴 Issues 5 medium · 2 minor

Alerts:
⚠ 7 issues (≤ 0 issues of at least minor severity)

Results:
7 new issues

Category Results
UnusedCode 2 minor
Security 3 medium
Complexity 2 medium

View in Codacy

🟢 Metrics 44 complexity

Metric Results
Complexity 44

View in Codacy

NEW Get contextual insights on your PRs based on Codacy's metrics, along with PR and Jira context, without leaving GitHub. Enable AI reviewer
TIP This summary will be updated as you push new changes.

@gemini-code-assist gemini-code-assist Bot 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.

Code Review

This pull request introduces parallel processing for CSV imports using a ProcessPoolExecutor in the Runner, along with changes to prevent file collisions by incorporating the file name into observation shard names. It also adds GCS upload retry logic, improves custom namespace handling across importers and validators, and optimizes custom dimension serialization. Feedback on these changes highlights a fragile design pattern in _write_observation_shard where the first parameter is overloaded to accept either a list or a tuple, and warns of a potential collision risk for node shards similar to the one resolved for observation shards.

Comment on lines +198 to +202
if file_name:
sanitized_stem = file_name.replace("/", "_").rsplit(".", 1)[0]
shard_name = f"observation-{sanitized_stem}-{shard_index:05d}.jsonld"
else:
shard_name = f"observation-{shard_index:05d}.jsonld"

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.

high

While adding file_name to the observation shard name successfully prevents file collisions during parallel processing of multiple CSV files, a similar collision risk exists for node shards (which are written by MCF and Events CSV files).

Since _write_node_shard is not modified in this PR, please ensure that a follow-up change or a refactor is done to also pass and include the file_name in the node shard names (e.g., node-{sanitized_stem}-{shard_index:05d}.jsonld) to prevent them from overwriting each other when multiple MCF/Event files are processed in parallel.

Comment on lines +112 to +119
if isinstance(chunk_or_args, tuple):
chunk = chunk_or_args[0]
shard_index = chunk_or_args[1]
jsonld_dir_path = chunk_or_args[2]
ns_map = chunk_or_args[3]
prov_urls = chunk_or_args[4]
else:
chunk = chunk_or_args

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.

medium

Overloading the first parameter chunk_or_args to accept either a list of rows or a tuple of arguments is a fragile design pattern. If chunk is ever represented as a tuple of rows (e.g., from certain pandas/numpy operations or serialization), isinstance(chunk_or_args, tuple) will evaluate to True, leading to incorrect unpacking and silent failures or crashes.

Since _write_observation_shard is always called with individual arguments in this codebase, this tuple-unpacking branch appears to be dead/speculative code. It is highly recommended to remove this branch and keep the function signature clean and explicit.

  chunk = chunk_or_args

@gmechali
gmechali requested a review from clincoln8 July 25, 2026 15:44
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