Skip to content

Commit 061ed90

Browse files
Revert "Revert "fix: use list for bundle analysis tasks (#565)" (#572)" (#576)
This reverts commit 507a065.
1 parent 6a32ed7 commit 061ed90

File tree

6 files changed

+142
-158
lines changed

6 files changed

+142
-158
lines changed

apps/worker/tasks/bundle_analysis_notify.py

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -21,9 +21,9 @@ class BundleAnalysisNotifyTask(BaseCodecovTask, name=bundle_analysis_notify_task
2121
def run_impl(
2222
self,
2323
db_session,
24-
# Celery `chain` injects this argument - it's the returned result
25-
# from the prior task in the chain
26-
previous_result: dict[str, Any],
24+
# Celery `chain` injects this argument - it's the list of processing results
25+
# from prior processor tasks in the chain
26+
previous_result: list[dict[str, Any]],
2727
*,
2828
repoid: int,
2929
commitid: str,
@@ -72,7 +72,7 @@ def process_impl_within_lock(
7272
repoid: int,
7373
commitid: str,
7474
commit_yaml: UserYaml,
75-
previous_result: dict[str, Any],
75+
previous_result: list[dict[str, Any]],
7676
**kwargs,
7777
):
7878
log.info(
@@ -90,9 +90,11 @@ def process_impl_within_lock(
9090
)
9191
assert commit, "commit not found"
9292

93-
# these are the task results from prior processor tasks in the chain
93+
# previous_result is the list of processing results from prior processor tasks
9494
# (they get accumulated as we execute each task in succession)
95-
processing_results = previous_result.get("results", [])
95+
processing_results = (
96+
previous_result if isinstance(previous_result, list) else []
97+
)
9698

9799
if all(result["error"] is not None for result in processing_results):
98100
# every processor errored, nothing to notify on

apps/worker/tasks/bundle_analysis_processor.py

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -31,9 +31,9 @@ class BundleAnalysisProcessorTask(
3131
def run_impl(
3232
self,
3333
db_session,
34-
# Celery `chain` injects this argument - it's the returned result
35-
# from the prior task in the chain
36-
previous_result: dict[str, Any],
34+
# Celery `chain` injects this argument - it's the list of processing results
35+
# from prior tasks in the chain (accumulated as each task executes)
36+
previous_result: list[dict[str, Any]],
3737
*args,
3838
repoid: int,
3939
commitid: str,
@@ -82,7 +82,7 @@ def process_impl_within_lock(
8282
commitid: str,
8383
commit_yaml: UserYaml,
8484
params: UploadArguments,
85-
previous_result: dict[str, Any],
85+
previous_result: list[dict[str, Any]],
8686
):
8787
log.info(
8888
"Running bundle analysis processor",
@@ -100,9 +100,11 @@ def process_impl_within_lock(
100100

101101
report_service = BundleAnalysisReportService(commit_yaml)
102102

103-
# these are the task results from prior processor tasks in the chain
103+
# previous_result is the list of processing results from prior processor tasks
104104
# (they get accumulated as we execute each task in succession)
105-
processing_results = previous_result.get("results", [])
105+
processing_results = (
106+
previous_result if isinstance(previous_result, list) else []
107+
)
106108

107109
# these are populated in the upload task
108110
# unless when this task is called on a non-BA upload then we have to create an empty upload
@@ -141,7 +143,7 @@ def process_impl_within_lock(
141143
"commit": commit.commitid,
142144
},
143145
)
144-
return {"results": processing_results}
146+
return processing_results
145147
else:
146148
# If the commit report does not exist, we will create a new one
147149
commit_report = report_service.initialize_and_save_report(commit)
@@ -240,7 +242,7 @@ def process_impl_within_lock(
240242
},
241243
)
242244

243-
return {"results": processing_results}
245+
return processing_results
244246

245247

246248
RegisteredBundleAnalysisProcessorTask = celery_app.register_task(

apps/worker/tasks/tests/unit/test_bundle_analysis_notify_task.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ def test_bundle_analysis_notify_task(
3030

3131
result = BundleAnalysisNotifyTask().run_impl(
3232
dbsession,
33-
{"results": [{"error": None}]},
33+
[{"error": None}],
3434
repoid=commit.repoid,
3535
commitid=commit.commitid,
3636
commit_yaml={},
@@ -47,7 +47,7 @@ def test_bundle_analysis_notify_skips_if_all_processing_fail(dbsession):
4747
dbsession.flush()
4848
result = BundleAnalysisNotifyTask().run_impl(
4949
dbsession,
50-
{"results": [{"error": True}]},
50+
[{"error": True}],
5151
repoid=commit.repoid,
5252
commitid=commit.commitid,
5353
commit_yaml={},

0 commit comments

Comments
 (0)