Skip to content

Commit e3a8680

Browse files
committed
Set an upper limit for max_workers on electricity extract and load.
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.
1 parent 9267a79 commit e3a8680

2 files changed

Lines changed: 4 additions & 3 deletions

File tree

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
11
[electricity_sharepoint.sources.m365]
22
files_per_page = 200
33
skip_rows = 7
4+
max_workers = 10

warehouses/accelerator/extract_load/electricity_sharepoint/extract_and_load.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,7 @@ def read_power_consumption_excel(
7777
def extract_content_and_read(
7878
items: Iterator[M365DriveItem],
7979
skip_rows: int = dlt.config.value,
80-
max_threads: Optional[int] = dlt.config.value,
80+
max_workers: Optional[int] = dlt.config.value,
8181
) -> Iterator[TDataItems]:
8282
"""Extracts the file content and reads it assuming it is a .csv or a .xlsx file
8383
@@ -86,7 +86,7 @@ def extract_content_and_read(
8686
8787
:param items: An iterator of dicts describing the file content
8888
:param skip_rows: Number of rows in the csv/xlsx files to skip
89-
:param max_threads (optional): How many threads to use to process the files. Defaults to concurrent.futures.ThreadPoolExecutor default value.
89+
:param max_workers (optional): How many threads to use to process the files. Defaults to concurrent.futures.ThreadPoolExecutor default value.
9090
"""
9191

9292
# The files are all independent. Process them in parallel and combine for a single yield
@@ -111,7 +111,7 @@ def read_as_dataframe(file_obj: M365DriveItem) -> pd.DataFrame | None:
111111
return df
112112

113113
df_batch = None
114-
with concurrent.futures.ThreadPoolExecutor(max_workers=max_threads) as executor:
114+
with concurrent.futures.ThreadPoolExecutor(max_workers=max_workers) as executor:
115115
future_to_file_item = {
116116
executor.submit(read_as_dataframe, file_obj): file_obj for file_obj in items
117117
}

0 commit comments

Comments
 (0)