codeant-ai-for-open-source[bot] commented on code in PR #41966:
URL: https://github.com/apache/superset/pull/41966#discussion_r3565339273
##########
superset/commands/report/execute.py:
##########
@@ -223,22 +223,47 @@ def update_report_schedule_slack_v2(self) -> None:
def create_log(self, error_message: Optional[str] = None) -> None:
"""
Creates a Report execution log, uses the current computed last_value
for Alerts
+
+ A single execution transitions through the WORKING state before
reaching a
+ terminal state (SUCCESS/ERROR/NOOP/GRACE). To avoid duplicated rows in
the
+ execution-log view (see issue #29857), the terminal result is written
onto
+ the WORKING "trigger" row created earlier in the same execution rather
than
+ inserting a second row. The WORKING row is only used as a placeholder
while
+ the execution is in flight (``find_last_entered_working_log`` relies
on it
+ for working-timeout detection), so promoting it in place keeps one row
per
+ execution ``uuid`` without losing that behavior. The intentional
+ error-notification marker row is a terminal-to-terminal transition, so
it is
+ still recorded as a distinct row.
"""
from sqlalchemy.orm.exc import StaleDataError
try:
- log = ReportExecutionLog(
- scheduled_dttm=self._scheduled_dttm,
- start_dttm=self._start_dttm,
- end_dttm=datetime.utcnow(),
- value=self._report_schedule.last_value,
- value_row_json=self._report_schedule.last_value_row_json,
- state=self._report_schedule.last_state,
- error_message=error_message,
- report_schedule=self._report_schedule,
- uuid=self._execution_id,
+ # Reuse the in-flight WORKING trigger row for this execution, if
any,
+ # so a single execution surfaces as a single log entry.
+ log = (
+ db.session.query(ReportExecutionLog)
+ .filter(
+ ReportExecutionLog.uuid == self._execution_id,
+ ReportExecutionLog.state == ReportState.WORKING,
+ ReportExecutionLog.error_message.is_(None),
+ )
+ .first()
+ if self._report_schedule.last_state != ReportState.WORKING
+ else None
)
Review Comment:
**Suggestion:** Add an explicit type annotation for the `log` variable to
satisfy the type-hint requirement for newly introduced relevant variables.
[custom_rule]
**Severity Level:** Minor ๐งน
<details>
<summary><b>Why it matters? โญ </b></summary>
This is a newly introduced local variable in modified Python code, and it is
assignable to a model instance or None. Under the type-hint rule, such relevant
variables should be explicitly annotated, but this code leaves `log` untyped.
</details>
<details>
<summary><b>Rule source ๐ </b></summary>
.cursor/rules/dev-standard.mdc (line 28)
</details>
[](https://app.codeant.ai/fix-in-ide?tool=cursor&prompt_id=c4afc83bc80a49a59ca855171a90fc84&service=github&base_url=https%3A%2F%2Fgithub.com&org=apache&repo=apache%2Fsuperset)
[](https://app.codeant.ai/fix-in-ide?tool=vscode-claude&prompt_id=c4afc83bc80a49a59ca855171a90fc84&service=github&base_url=https%3A%2F%2Fgithub.com&org=apache&repo=apache%2Fsuperset)
*(Use Cmd/Ctrl + Click for best experience)*
<details>
<summary><b>Prompt for AI Agent ๐ค </b></summary>
```mdx
This is a comment left during a code review.
**Path:** superset/commands/report/execute.py
**Line:** 243:253
**Comment:**
*Custom Rule: Add an explicit type annotation for the `log` variable to
satisfy the type-hint requirement for newly introduced relevant variables.
Validate the correctness of the flagged issue. If correct, How can I resolve
this? If you propose a fix, implement it and please make it concise.
Once fix is implemented, also check other comments on the same PR, and ask
user if the user wants to fix the rest of the comments as well. if said yes,
then fetch all the comments validate the correctness and implement a minimal fix
```
</details>
<a
href='https://app.codeant.ai/feedback?pr_url=https%3A%2F%2Fgithub.com%2Fapache%2Fsuperset%2Fpull%2F41966&comment_hash=a5130290efd3e641cd478f44b740c7f6aa752466318eaeacd508987ab9c0b75e&reaction=like'>๐</a>
| <a
href='https://app.codeant.ai/feedback?pr_url=https%3A%2F%2Fgithub.com%2Fapache%2Fsuperset%2Fpull%2F41966&comment_hash=a5130290efd3e641cd478f44b740c7f6aa752466318eaeacd508987ab9c0b75e&reaction=dislike'>๐</a>
##########
tests/integration_tests/reports/commands_tests.py:
##########
@@ -772,6 +778,45 @@ def test_email_chart_report_schedule(
assert_log(ReportState.SUCCESS)
[email protected](
+ "load_birth_names_dashboard_with_slices", "create_report_email_chart"
+)
+@patch("superset.reports.notifications.email.send_email_smtp")
+@patch("superset.utils.screenshots.ChartScreenshot.get_screenshot")
+def test_email_chart_report_schedule_single_log_per_execution(
+ screenshot_mock,
+ email_mock,
+ create_report_email_chart,
+):
Review Comment:
**Suggestion:** Add type annotations to the new test function parameters and
include an explicit return type to satisfy the type-hint requirement.
[custom_rule]
**Severity Level:** Minor ๐งน
<details>
<summary><b>Why it matters? โญ </b></summary>
The added test function is new Python code and its parameters and return
value are unannotated. This matches the type-hint rule, so the suggestion
identifies a real violation.
</details>
<details>
<summary><b>Rule source ๐ </b></summary>
.cursor/rules/dev-standard.mdc (line 28)
</details>
[](https://app.codeant.ai/fix-in-ide?tool=cursor&prompt_id=23bdba8d6a9a418db586774b7d186c80&service=github&base_url=https%3A%2F%2Fgithub.com&org=apache&repo=apache%2Fsuperset)
[](https://app.codeant.ai/fix-in-ide?tool=vscode-claude&prompt_id=23bdba8d6a9a418db586774b7d186c80&service=github&base_url=https%3A%2F%2Fgithub.com&org=apache&repo=apache%2Fsuperset)
*(Use Cmd/Ctrl + Click for best experience)*
<details>
<summary><b>Prompt for AI Agent ๐ค </b></summary>
```mdx
This is a comment left during a code review.
**Path:** tests/integration_tests/reports/commands_tests.py
**Line:** 786:790
**Comment:**
*Custom Rule: Add type annotations to the new test function parameters
and include an explicit return type to satisfy the type-hint requirement.
Validate the correctness of the flagged issue. If correct, How can I resolve
this? If you propose a fix, implement it and please make it concise.
Once fix is implemented, also check other comments on the same PR, and ask
user if the user wants to fix the rest of the comments as well. if said yes,
then fetch all the comments validate the correctness and implement a minimal fix
```
</details>
<a
href='https://app.codeant.ai/feedback?pr_url=https%3A%2F%2Fgithub.com%2Fapache%2Fsuperset%2Fpull%2F41966&comment_hash=8bb9e51823eb5e2d96818305fd440078141b73202cbc7441b9cc113f6db6a7ab&reaction=like'>๐</a>
| <a
href='https://app.codeant.ai/feedback?pr_url=https%3A%2F%2Fgithub.com%2Fapache%2Fsuperset%2Fpull%2F41966&comment_hash=8bb9e51823eb5e2d96818305fd440078141b73202cbc7441b9cc113f6db6a7ab&reaction=dislike'>๐</a>
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]