Skip to content

Commit 11e7c27

Browse files
committed
fix dataset part dowload
1 parent 26a5a75 commit 11e7c27

File tree

3 files changed

+9
-7
lines changed

3 files changed

+9
-7
lines changed

cosmotech/coal/cosmotech_api/dataset/download/file.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -118,7 +118,7 @@ def process_txt(target_file) -> Dict[str, Any]:
118118
LOGGER.debug(T("coal.services.dataset.processing_text").format(file_name=target_file))
119119
with open(target_file, "r") as _file:
120120
current_filename = os.path.basename(target_file)
121-
content[current_filename] = "\n".join(line for line in _file)
121+
content[current_filename] = "".join(line for line in _file)
122122

123123
line_count = content[current_filename].count("\n") + 1
124124
LOGGER.debug(
@@ -128,7 +128,7 @@ def process_txt(target_file) -> Dict[str, Any]:
128128

129129

130130
def read_file(file_name, file):
131-
@timed(f"process{file_name}", debug=True)
131+
@timed(f"process {file_name}", debug=True)
132132
def timed_read_file(file_name, file):
133133
content = {}
134134
if ".xls" in file_name:

cosmotech/coal/cosmotech_api/runner/datasets.py

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -63,9 +63,9 @@ def download_dataset(
6363

6464
csm_version = semver_of("cosmotech_api")
6565
if csm_version.major >= 5:
66-
download_dataset_v5(organization_id, workspace_id, dataset_id, read_files)
66+
return download_dataset_v5(organization_id, workspace_id, dataset_id, read_files)
6767
else:
68-
download_dataset_v4(organization_id, workspace_id, dataset_id, read_files)
68+
return download_dataset_v4(organization_id, workspace_id, dataset_id, read_files)
6969

7070

7171
def download_dataset_v5(
@@ -94,6 +94,7 @@ def download_dataset_v5(
9494
workspace_id=workspace_id,
9595
dataset_id=dataset_id)
9696

97+
content = dict()
9798
tmp_dataset_dir = tempfile.mkdtemp()
9899
tmp_dataset_dir_path = Path(tmp_dataset_dir)
99100
for part in dataset.parts:
@@ -103,10 +104,10 @@ def download_dataset_v5(
103104
binary_file.write(data_part)
104105

105106
if read_files:
106-
content = file.read_file(part_file_path)
107+
content.update(file.read_file(part.source_name, part_file_path))
107108

108109
return {
109-
"type": "twincache",
110+
"type": "csm_dataset",
110111
"content": content,
111112
"name": dataset.name,
112113
"folder_path": str(part_file_path),

cosmotech/coal/utils/decorator.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,12 +11,13 @@ def decorator(func):
1111
@wraps(func)
1212
def wrapper(*args, **kwargs):
1313
process_start = time.time()
14-
func(*args, **kwargs)
14+
r = func(*args, **kwargs)
1515
process_time = time.time() - process_start
1616
msg = T("coal.common.timing.operation_completed").format(operation=operation, time=process_time)
1717
if debug:
1818
LOGGER.debug(msg)
1919
else:
2020
LOGGER.info(msg)
21+
return r
2122
return wrapper
2223
return decorator

0 commit comments

Comments
 (0)