fix(warehouses/accelerator/electricity_sharepoint): Set an upper limit for max_workers on extract and load.#157
Conversation
WalkthroughThis pull request refactors concurrent worker thread management in the electricity SharePoint data extraction module. It introduces a centralised Changes
Estimated code review effort🎯 2 (Simple) | ⏱️ ~12 minutes The changes are straightforward and homogeneous: a single-file modification introducing a constant, a parameter rename, and simple min-based logic for worker capping. The refactoring follows a clear pattern with no branching complexity or multi-file coordination required. Poem
Pre-merge checks and finishing touches❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✨ Finishing touches
🧪 Generate unit tests (beta)
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. Comment |
There was a problem hiding this comment.
Actionable comments posted: 3
📜 Review details
Configuration used: Path: .coderabbit.yaml
Review profile: CHILL
Plan: Pro
Cache: Disabled due to data retention organization setting
Knowledge base: Disabled due to data retention organization setting
📒 Files selected for processing (2)
warehouses/accelerator/extract_load/electricity_sharepoint/.dlt/config.toml(1 hunks)warehouses/accelerator/extract_load/electricity_sharepoint/extract_and_load.py(3 hunks)
🔇 Additional comments (2)
warehouses/accelerator/extract_load/electricity_sharepoint/extract_and_load.py (2)
77-81: Good refactor: parameter rename aligns with ThreadPoolExecutor API.The rename from
max_threadstomax_workerscorrectly aligns with theThreadPoolExecutorparameter name, improving consistency and clarity.
76-124: AI summary contradicts PR objective.The AI-generated summary states this change "enables increased parallelism", but the PR objectives clearly indicate the purpose is to limit parallelism to fix failures that occurred when max_workers was set to 20 on a 16-CPU machine.
It was observed that on a machine with 16 cpus, max_workers=20 and some files would fail when extracting content. It is assumed that reading too many files from sharepoint causes issues.
e3a8680 to
11fcb6a
Compare
|
@coderabbitai full review |
✅ Actions performedFull review triggered. |
There was a problem hiding this comment.
Actionable comments posted: 0
🧹 Nitpick comments (1)
warehouses/accelerator/extract_load/electricity_sharepoint/extract_and_load.py (1)
94-95: Clarify the default and upper limit behaviour in the docstring.The current wording "Defaults to a maximum of MAX_WORKERS_DEFAULT" is ambiguous. Consider clarifying that
max_workersdefaults toMAX_WORKERS_DEFAULT(currently 10) and also acts as an upper limit if a larger value is provided.Apply this diff to improve clarity:
- :param max_workers (optional): How many threads to use to process the files. - Defaults to a maximum of MAX_WORKERS_DEFAULT. + :param max_workers (optional): How many threads to use to process the files. + Defaults to MAX_WORKERS_DEFAULT (10), which also serves + as an upper limit.
📜 Review details
Configuration used: Path: .coderabbit.yaml
Review profile: CHILL
Plan: Pro
Cache: Disabled due to data retention organization setting
Knowledge base: Disabled due to data retention organization setting
📒 Files selected for processing (1)
warehouses/accelerator/extract_load/electricity_sharepoint/extract_and_load.py(5 hunks)
🔇 Additional comments (5)
warehouses/accelerator/extract_load/electricity_sharepoint/extract_and_load.py (5)
14-14: LGTM!The
osimport is required foros.cpu_count()used in theMAX_WORKERS_DEFAULTcalculation.
41-44: LGTM!The constant definition addresses the PR objective by capping concurrent workers at 10. The formula sensibly scales with CPU count for machines with fewer processors whilst preventing the over-parallelism that caused SharePoint failures on the 16-CPU machine.
85-85: LGTM!Renaming to
max_workersimproves consistency withThreadPoolExecutor's parameter naming.
120-120: LGTM! Upper limit logic correctly implemented.The calculation correctly enforces the upper limit: when
max_workersis None, it defaults toMAX_WORKERS_DEFAULT; when provided, it's capped atMAX_WORKERS_DEFAULT. This addresses the past review comment about implementing a true upper limit.
121-123: LGTM!The
ThreadPoolExecutorcorrectly useseffective_max_workers, ensuring the concurrent worker count never exceeds the intended upper limit of 10, which should prevent the SharePoint content extraction failures.
Summary
It was observed that on a machine with 16 cpus (max_workers=20) and some files would fail when extracting content. It is assumed that reading too many files from sharepoint causes issues.
Fixes #156
Summary by CodeRabbit