bitter-ability-32190
10/04/2022, 6:07 PMbitter-ability-32190
10/04/2022, 6:11 PMlint and fmt to move the result streaming to be an implementation detail of the core goal, instead of making users pass in information that the core goal knows solely for streaming.
There's tradeoffs, but I really like the result in terms of plugin authors needing less boilerplate. And less room for error.
However there is one giant massive blocker. LintResult needs an exit_code which for formatters we use 1 if changed else 0. the new LintResult and FmtResult won't know if they changed because they won't have the input re-plumbed through. So converting from a FmtResult to a LintResult is naturally impossible š
There is a possible solution of completely abusing the type of exit_code though. technically we can just set exit_code = output_snapshot and then lint.py has a input_snpashot: Snapshot = request.exit_code (if formatter). It works but YIKES!
Thoughts?bitter-ability-32190
10/04/2022, 7:08 PMwitty-crayon-22786
10/04/2022, 7:13 PMIām changingiām not sure i understand what you mean here, so iām not understanding the tradeoffs in the rest of the questionandlintto move the result streaming to be an implementation detail of the core goal, instead of making users pass in information that the core goal knows solely for streaming.fmt
bitter-ability-32190
10/04/2022, 7:15 PM@dataclass(frozen=True)
-class LintResult(EngineAwareReturnType):
+class LintResult:
exit_code: int
stdout: str
stderr: str
- linter_name: str
- partition_description: str | None = None
report: Digest = EMPTY_DIGEST
(so plugin authors no longer pipe these through)
and then for that to work:
+
+@dataclass(frozen=True)
+class _StreamedLintRequest:
+ subpartition: LintRequest.SubPartition
+ linter_name: str
+ is_formatter: bool
+
+
+@dataclass(frozen=True)
+class _StreamedLintResult(EngineAwareReturnType):
+ result: LintResult
+ linter_name: str
+ is_formatter: bool
+ partition_description: str | None = Nonebitter-ability-32190
10/04/2022, 7:15 PMGet(
+ _StreamedLintResult,
+ _StreamedLintRequest(
and then:
+@rule(desc="Lint", level=LogLevel.DEBUG)
+async def stream_lint_result(request: _StreamedLintRequest) -> _StreamedLintResult:
+ result = await Get(LintResult, LintRequest.SubPartition, request.subpartition)witty-crayon-22786
10/04/2022, 7:17 PMbitter-ability-32190
10/04/2022, 7:17 PMfmt, where the input Snapshot is piped throughbitter-ability-32190
10/04/2022, 7:18 PMwitty-crayon-22786
10/04/2022, 7:18 PMEngineAwareReturnType works if we end up needing to do this to make things easier for plugin authors. it might be a sign that making this return type driven rather than callsite driven is a mistake, for example.witty-crayon-22786
10/04/2022, 7:18 PMEngineAwareReturnType)bitter-ability-32190
10/04/2022, 7:18 PMbitter-ability-32190
10/04/2022, 7:19 PMname aspect can be done via customized classtypes with the name as a classvar. The input snapshot, not so much šbitter-ability-32190
10/04/2022, 7:19 PMwitty-crayon-22786
10/04/2022, 7:20 PMawait Get(LintResult, Input(..), log_with=lambda x: ...)bitter-ability-32190
10/04/2022, 7:20 PMwitty-crayon-22786
10/04/2022, 7:21 PMMultiGet instead or something)witty-crayon-22786
10/04/2022, 7:27 PMEngineAwareReturnType driving cacheability continues to make sense.
itās just possible that the fact that weāre using EngineAwareReturnType to trigger side-effects for streaming might not be the best.witty-crayon-22786
10/04/2022, 7:28 PMbitter-ability-32190
10/04/2022, 7:28 PMbitter-ability-32190
10/04/2022, 7:29 PMwitty-crayon-22786
10/04/2022, 7:31 PMThis was going to be my solution to the streaming issue on 2.15 w.r.t. formatters double-streaming.is that one filed anywhere? i donāt remember what the issue was
bitter-ability-32190
10/04/2022, 7:32 PMbitter-ability-32190
10/04/2022, 8:31 PMrequest type that is the input (I know a rule has multiple inputs which is why this is funky)bitter-ability-32190
10/04/2022, 8:31 PMwitty-crayon-22786
10/04/2022, 8:52 PMEngineAwareReturnType take as an argument the params that were in scope?witty-crayon-22786
10/04/2022, 8:53 PMwitty-crayon-22786
10/04/2022, 8:53 PMbitter-ability-32190
10/04/2022, 8:54 PMwitty-crayon-22786
10/04/2022, 8:57 PMwitty-crayon-22786
10/04/2022, 8:58 PM@rule the EngineAwareReturnType was returned fromwitty-crayon-22786
10/04/2022, 8:59 PMwitty-crayon-22786
10/04/2022, 9:00 PMbitter-ability-32190
10/04/2022, 9:00 PMwitty-crayon-22786
10/04/2022, 9:00 PMengine_aware.py is consumed by <http://engine_aware.rs|engine_aware.rs>bitter-ability-32190
10/06/2022, 5:25 PMrequest.create_result(....)bitter-ability-32190
10/06/2022, 5:25 PM