You are given a Python log parsing pipeline using Polars string operations.
Each log line follows the format:
text
YYYY-MM-DD LEVEL code=NNN msg=message_text
The pipeline processes a batch of log lines and for each one extracts:
date: the first 10 characters (YYYY-MM-DD)
level: the log level token (ERROR, WARN, INFO, DEBUG)
code: the integer status code extracted via regex code=(\d+) — None if absent
status: "error" if code >= 400, else "ok"
The extraction uses vectorized Polars string operations (no row-by-row Python loops): str.slice, str.extract with regex capture groups, cast, and when/then/otherwise.
Your Task
Port this batch log-parsing function to Modal so that multiple independent log batches can be processed concurrently by remote workers.
The original workflow is in workflow.py. The function parse_log_batch(log_lines: list) -> list is the core computation to port.
Required Output
Write /app/solution/modal_app.py. It must:
Define a module-level app object
Define a module-level Modal Function named run_case
run_caseremote invocation (case) accepts a dict with key "log_lines" (a list of strings)
Returns a list of dicts with keys date, level, code (int or None), status
The remote environment needs polars installed.
Capability contract
Expose the workflow as a single Modal remote function: define run_case as an @app.function so the harness can invoke it with run_case.remote(case).