The file original_workflow.py in your workspace implements polyfit_trend_analysis(seed, n_months, n_lat, trend_per_month).
The workflow:
Creates a synthetic Dataset with n_months monthly timesteps and n_lat latitude points.
Injects a known linear trend (trend_per_month * t) plus small noise into the temperature field.
Fits a degree-1 polynomial to each latitude's time series using xarray.DataArray.polyfit.
Extracts slopes (degree=1 coefficients) and intercepts (degree=0 coefficients) from the result.
Returns a dict with "slopes" (list per lat), "intercepts" (list per lat), "mean_slope" (float), and "expected_slope" (the injected trend value).
Note: polyfit returns a Dataset with a polyfit_coefficients variable that has a degree dimension in descending order. Selecting degree=1 gives the linear slope.
Your task: port this workflow to Modal so it runs remotely.
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.
The case dict has keys: "seed" (int), "n_months" (int), "n_lat" (int), "trend_per_month" (float).
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).