The file original.py (in your working directory) exposes a single function
encode_decode(colors) that:
Constructs pd.Series(colors) from a list of category labels.
One-hot encodes it via pd.get_dummies(series, prefix="c", dtype=int),
producing a DataFrame whose columns are named c_<label> and whose values
are 0 / 1 (integer dtype).
Decodes the encoded frame back to labels via
pd.from_dummies(encoded, sep="_").iloc[:, 0].
Returns a JSON-friendly dict with two keys:
"encoded": list[dict[str, int]] — one row per element, mapping each
c_<label> column to its integer indicator (0 or 1).
"decoded": list[str] — the round-tripped labels, in input order.
What you need to build
Create /app/solution/modal_app.py that ports this workflow to Modal. The
verifier will import your module and call run_caseremote invocation (case) for several
test cases.
Required interface
Module-level app representing the Modal app.
Module-level Modal Function object named run_case (i.e. defined with
A module-level Modal Function object named run_case.
run_caseremote invocation (case) must accept a dict shaped like
{"colors": list[str]} and return the same canonicalized
{"encoded": [...], "decoded": [...]} dict that the original
encode_decode returns for that input.
Notes
Your Modal image must include pandas.
Encoded values must be Python int (0 or 1), not numpy bools / int64
scalars.
The column name set in "encoded" rows must exactly match what
pd.get_dummies produces (i.e. c_<label> per unique label).
Do not embed expected outputs; the verifier computes the expected result
from the original code at run time.
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).