Port: Ensemble Simulation with Parallel Members and Concat Statistics
The file original_workflow.py in your workspace implements two functions:
run_ensemble_member(member_id, seed_base, n_time, n_lat, trend) — simulates one ensemble member with a deterministic linear trend plus seeded random noise. Each member has a unique seed derived from member_id.
concat_ensemble_stats(seed, n_members, n_time, n_lat, trend) — runs all members (sequentially in the original), concatenates them along a new member dimension, and computes ensemble statistics (mean, std, quantiles).
Each member's simulation is completely independent of other members.
Your task: port this workflow to Modal so each ensemble member runs as an independent remote task, and the results are concatenated and analyzed.
Write /app/solution/modal_app.py. It must define:
A module-level app.
A module-level Modal Function object named run_case that accepts a case dict and returns the same result dict as concat_ensemble_stats.
The case dict has keys: "seed" (int), "n_members" (int), "n_time" (int), "n_lat" (int), "trend" (float).
The returned dict must have: "n_members", "ensemble_mean_global", "ensemble_std_global", "spread_per_lat", "q10_mean", "q90_mean", "shape".
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).