Deploying to MAAP

From a MAAP account to a processed day: staging ~142 GiB of static data, publishing the images, registering four algorithms, and launching the first job.

This is the procedure. For how any of it works — the CWL model, the manifest fan-in, promotion, the catalogue split — see Running on MAAP.

The order is a dependency chain, not a preference. Step 3's fast path gates the smoke test in step 6, and step 6 gates writing any client code.

0. Ask MAAP ops first

Does any DPS queue offer 64 GiB and 16 cores? MRVA is the only module that needs a large instance — landice, iQUAM and L2P all fit on small ones. If no queue reaches it, that is a blocking finding for the whole migration, and it costs one email now versus discovering it after three algorithms are already registered.

Three more worth putting in the same message:

  • Ephemeral disk on the worker. L2P materializes every granule to scratch before MATLAB runs — a MODIS day is roughly 288 granules at ~20 MB, and a worst case exceeds 20 GB. outdir_max does not reserve scratch.
  • Outbound internet from workers. landice fetches OSI-SAF sea ice; iQUAM fetches NOAA STAR.
  • Queue names available to you.

1. Start an OGC workspace

The image choice gates OGC entirely. The default ADE and standard Hub images ship the non-OGC v4 stack; only custom images carry maap-py ≥ 5, Algorithm Registration ≥ v1 and Jobs ≥ v2. The published workspace table has blank image-path cells, so the container registry is the only authoritative source.

At hub.maap-project.org, log in with NASA Earthdata, choose Other from the Environment dropdown, and paste:

mas.maap-project.org/root/maap-workspaces/2i2c/pangeo:v6.0.0

Then once, in the workspace terminal. The home directory persists across sessions and across workspaces, so this survives restarts:

git clone <mur repo> ~/mur
cd ~/mur && pip install -e . --no-deps
pip install 'boto3>=1.34' earthaccess

python -c "import mur_maap, maap; print('ok')"

--no-deps is deliberate: the image already pins numpy, netCDF4 and matplotlib, and the orchestrator needs only stdlib plus boto3, maap-py and earthaccess.

2. Get a token that works off-platform

Inside a workspace, authentication is ambient — MAAP() just works. Anywhere else, maap-py needs MAAP_PGT. It is not an AWS profile: maap-py exchanges that token for temporary AWS credentials itself.

# in the workspace, confirm what the environment already has
printf %s "$MAAP_PGT" | wc -c
printf %s "$MAAP_PGT" | sha256sum

If that is empty, generate one at console.maap-project.org/profile/tokens, which exists for off-platform automation.

Do not assume a token's shape. A workspace's MAAP_PGT is jwt: followed by a JWT, but a token generated at the console is not necessarily — an earlier version of cron_mur_maap.sh required the first shape and rejected a valid instance of the second. Nothing in this repo checks the format any more, and nothing should: only an authenticated call can tell a good token from a bad one, which is what upload_static_resources.py --check does.

What is still worth checking is that the value arrived intact. Selecting a wrapped value with the mouse in a browser terminal can clip the leading character, and the server then answers only {"message": "Invalid session or insufficient permissions."}. Compare length and hash at both ends rather than eyeballing it.

On the target host, store the raw token value and nothing else in ~/.maap-token — no export, no quoting. A file of shell syntax is only sourceable from the shell that wrote it, and a raw value is read identically from bash, tcsh and Python. utils/cron_mur_maap.sh reads this file, strips any whitespace a paste introduced, and still honours the older export MAAP_PGT=… form.

Type it into a prompt rather than a command, so it reaches neither shell history nor ps. From bash:

umask 077
read -rsp 'MAAP_PGT: ' T && echo
printf %s "$T" > ~/.maap-token && chmod 600 ~/.maap-token && unset T

From tcsh, which has no read, borrow bash for the one step:

bash -c 'umask 077; read -rsp "MAAP_PGT: " T && echo && \
    printf %s "$T" > ~/.maap-token && chmod 600 ~/.maap-token'

Then verify the paste survived, comparing both numbers against the source host. This is the step that catches a clipped prefix:

wc -c < ~/.maap-token
tr -d '[:space:]' < ~/.maap-token | shasum -a 256

To use it interactively in the shell — needed for backfill_mur_maap.py and the --check runs below, though not for the cron wrapper, which reads the file itself:

# bash
export MAAP_PGT="$(tr -d '[:space:]' < ~/.maap-token)"

# tcsh
setenv MAAP_PGT "`tr -d '[:space:]' < ~/.maap-token`"

cron does not use your login shell. cronie runs each entry under /bin/sh unless the crontab sets SHELL=, and cron_mur_maap.sh carries a #!/usr/bin/env bash shebang regardless — so a tcsh login shell changes nothing about the scheduled run. It only changes how you set the variable by hand.

3. Stage the static data

377 objects, ~142 GiB. Run the environment check first — it proves the things that otherwise fail late:

python utils/upload_static_resources.py --check

It reports whether MAAP_PGT is set and well-formed, whether maap-py is ≥ 5, which bucket and prefix your credentials grant, when they expire, and — the one a HEAD cannot tell you — whether a real write succeeds, by doing a put/get/delete round-trip on a probe key. It finishes by printing the config values it discovered.

GetBucketLocation returning AccessDenied is expected and harmless. The workspace session policy scopes you to your own prefix rather than bucket metadata; uploads are unaffected.

Pick the right source mode

The static tree exists in two shapes, and choosing wrongly produces a plan full of missing files rather than an error that explains itself.

FlagUse when
--from-config <config>The tree is assembled under one root — the usual case. Reads landice.static_resources_dir, so the upload reads exactly the tree the local pipeline reads.
--source-root <dir>Same shape, path given explicitly.
--from-prod-layoutThe files are still scattered across their original NAS locations (GRIDS_DIR, ICE_DIR, SEASONAL_DIR, POLARCAP_FILE).

Run it where the data is

Uploading from the host that holds the data moves the bytes once and needs no scratch disk. Going via an intermediate machine moves twice that and needs 142 GiB free. Do not tar first — that produces a single 142 GiB archive which then has to be unpacked somewhere to become objects again.

# look before moving anything: prints every resolved source path,
# and flags whatever is missing
python utils/upload_static_resources.py \
    --from-config config.container.json --include-optional \
    --dest s3://maap-ops-workspace/<user>/mur/static-resources --dry-run

# then, under nohup so a dropped connection does not kill it
nohup python utils/upload_static_resources.py \
    --from-config config.container.json --include-optional \
    --dest s3://maap-ops-workspace/<user>/mur/static-resources \
    --ledger ~/mur_static_ledger.jsonl > ~/mur_upload.log 2>&1 &

If that host cannot install maap-py or reach the MAAP API, credentials can come from elsewhere. --credentials-command is re-run on every refresh, so anything that mints fresh credentials works — including an ssh back to a workspace. Copying a credential set across by hand cannot work: they expire in about an hour and the upload takes several.

Resuming

Re-run the identical command. A ledger records each completed file and is fsync'd per line, so a killed run loses at most the file in flight; anything not in the ledger is checked with a HEAD. There is no risk of a truncated object — S3 only materializes one when the multipart upload completes, so a resume finds either a whole file or nothing.

A killed run does leave the parts it had already uploaded. They are invisible to a normal listing and billed as storage:

python utils/upload_static_resources.py ... --abort-stale-multiparts

Verify from the workspace

python utils/upload_static_resources.py --verify-only --include-optional

Three layers, of which the second is the one that matters: it calls the orchestrator's own resolve_landice_static_hrefs() and resolve_mrva_static_hrefs() against the real bucket for all 366 days, including the 366 → 365 fold. If that passes, the orchestrator cannot fail on a missing static input, because the question was answered by the same code that will ask it.

4. Build and publish the images

Two builds. The base images carry the MATLAB Runtime and need a Linux x86-64 host with licence access. The -dps variants are metadata only and take about a second each.

# an explicit tag, not the default branch-and-hash: the CWL pins
# dockerPull to an exact tag and algorithm_version must match it
./utils/build_and_push.sh --push --tag 2.0.0 --with-dps

--with-dps chains build_dps_images.sh onto the same run, passing the tag and --push --verify through. The two can still be run separately, but they should not be: a -dps variant captures the scripts of the image beneath it, so rebuilding a base without rebuilding its variant leaves MAAP running whatever the previous layer captured. Chaining removes the chance of doing one and forgetting the other.

A CWL DockerRequirement carries no registry credentials, so DPS cannot pull a private package. --verify checks anonymous pull; if it fails, make each package public in the registry's settings.

5. Generate, validate, deploy

Run this in the workspace, not on the build machine. deploy_algorithm_from_cwl_file() takes a file_path on the local filesystem, so the CWL has to exist on the machine that deploys it. Generating it anywhere else means committing and pulling before you can deploy — an extra round trip, and a chance to deploy a CWL that does not match the configs beside it. Nothing here needs Docker or MATLAB; it is config in, YAML out.

pip install cwltool ogc_ap_validator pyyaml
./utils/generate_cwl.sh

That generates each workflow from maap/<module>/algorithm_config.yml, cross-checks that dockerPull is your image rather than a placeholder and that NetworkAccess is present, then runs cwltool --validate --strict and ap-validator. The generated CWL is committed, because it is the deployment artifact and the generator expects hand-edits.

If it fails on the build machine. Two preconditions are easy to miss outside the workspace: the script clones ogc-app-pack-generator from GitHub on first run, so it needs outbound network; and the generator itself needs pyyaml installed for whichever interpreter PYTHON= selects (default python3, not a virtualenv unless you say so). A missing cwltool or ap-validator is not a failure — those are reported as SKIPPED and the CWL is still written.

Deploy from the workspace, cheapest first:

python utils/deploy_algorithms.py --dry-run   # see what would happen
python utils/deploy_algorithms.py

That cross-checks each CWL against its config, registers all four in that order, and reports the processID MAAP assigns to each. Use the script rather than a hand-written deploy_algorithm_from_cwl_file() loop: deployment is asynchronous, and MAAP answers 202 Accepted with a deploymentJobID before the process is registered. Listing the algorithms straight away shows only the previous version, so treating the 202 as done reports success for a deployment that has not happened yet. The script polls until each one appears and says plainly if it does not.

That order is not arbitrary. Each step proves exactly one new mechanism: iQUAM has no static inputs and no S3 reads, so it proves registration and stage-out; landice proves S3 static localization; L2P proves the manifest fan-in and the scratch-disk assumption; MRVA proves the large queue.

6. One landice job, by hand

Stop here before writing client code. get_job_result()'s return shape is undocumented — it may be a directory prefix, per-file hrefs, or a dict keyed by CWL output id — and three later pieces depend on which. Run one job, record the response verbatim, then build against what it actually returns.

The id submit_job takes is the numeric processID from the catalogue — not the id field ("mur-landice"), and not a tag-like name:version. Re-registering at a new version mints a new processID, so look it up rather than pinning one.

root = "s3://maap-ops-workspace/<user>/mur/static-resources"

resp = maap.submit_job(
    process_id=LANDICE_PROCESS_ID,   # the numeric processID, e.g. 65
    queue="<queue from MAAP ops>",
    tag="mur.smoke.landice",            # also organises dps_output/
    inputs={
        "year": "2026", "doy": "164",
        "landmask-p01-file":         f"{root}/grids/maskGLOBp01deg.gds",
        "gridindex-north-p01-file":  f"{root}/mat/p01/saf2north.mat",
        "gridindex-south-p01-file":  f"{root}/mat/p01/saf2south.mat",
        "landmask-p011-file":        f"{root}/grids/maskGlob1km.gds",
        "gridindex-north-p011-file": f"{root}/mat/p011/saf2north.mat",
        "gridindex-south-p011-file": f"{root}/mat/p011/saf2south.mat",
    })
job_id = resp.json()["id"]

maap.get_job_status(job_id).json()

import json; print(json.dumps(maap.get_job_result(job_id).json(), indent=2))

Three things to confirm from that output: that output/ contains p01/ and p011/ with real files — if it is empty, stage-out is wrong and nothing downstream can work; the real names behind landice_ice_p011, landice_grid_p01 and landice_icefiles_p011; and which subdirectory icefiles_YYYY_DDD.txt lands in.

Stage-out can be rehearsed locally first, without touching MAAP. Note the -w and the absence of any -v …:/output — that deliberately emulates CWL's “working directory is the output directory” contract:

mkdir -p /tmp/cwl-smoke
docker run --rm --platform linux/amd64 --user "$(id -u):$(id -g)" --group-add 0 \
  -v /tmp/cwl-smoke:/tmp/cwl-smoke -w /tmp/cwl-smoke \
  ghcr.io/podaac/mur/landice-dps:2.0.0 --year 2026 --doy 164 --landmask-p01-file ...

ls -R /tmp/cwl-smoke/output      # empty here means empty on DPS

7. A full day

One analysis day is 28 jobs: landice, iQUAM, 25 L2P jobs across five sensors and their day windows, then MRVA. Far longer than any idle timeout, which is why the run is checkpointed rather than blocking.

# offline, no credentials needed: exercises every decision, path builder
# and argument dict, and prints the full job table
mur-maap run --config config.maap.json -p -1 --dry-run

# --once does one non-blocking sweep and exits; exit code 2 means
# "still running", so watch or cron drives it trivially
mur-maap run --config config.maap.json -p -1 --preprocess-only --once
mur-maap status --latest
mur-maap resume --latest --once        # after each cull

The mur-maap CLI is designed but not yet implemented — see Current state. Until it exists, MAAPOrchestrator can be driven directly from a notebook once MAAPClient is real.

Outputs accumulate under ~/my-private-bucket/dps_output/<algorithm>/<tag>/…, which is a real path in the workspace filesystem — so the existing viewer reads them with no changes:

mur-viewer ~/my-private-bucket/dps_output/mur-mrva/<tag>/.../*.nc --info
mur-web-viewer                          # Streamlit on :8501

Re-releasing a new version

Steps 0–7 are the first time. Afterwards, shipping a code change is a shorter loop — but it is not "rebuild the tag", and the step people skip fails silently.

Use a new version; never rebuild a tag in place. cwltool runs docker pull only when docker inspect <dockerPull> fails. A DPS worker that has already run l2p-dps:2.0.3 keeps its cached copy of that tag for good, while a freshly scaled-up worker pulls the new bits — so which code a job runs depends on which worker takes it, and nothing in the output says which.

And MAAP keeps every version ever registered, so asking for a version that is merely old is not an error: it resolves, it submits, the job runs, and it runs the previous image. A half-finished version change produces a pipeline that looks entirely healthy while running last week's code.

Do the image on the build machine and everything else in the workspace — both on the same commit. The build machine has Docker and the MATLAB base image; the workspace is where deploy_algorithm_from_cwl_file() needs the CWL to exist. So the split is forced. What is not forced, and is the whole discipline of a release, is that both halves sit on the same source.

A version number is a string you type in two places. It does not certify that the image and the CWL describe the same code, and the failure mode is silent: on 2026-09-24 an image built from a commit three behind the fix was tagged 2.0.4, registered as 2.0.4, and ran — reproducing a bug that had already been fixed, under a version number that said otherwise. Nothing in the tag, the registration or the CWL disagreed. Only the build stamp did.

On the build machine — the image, and nothing else

git pull
git rev-parse --short HEAD              # note this; the image records it

./utils/build_and_push.sh --push --tag 2.0.5 --with-dps

No config edits here. The build reads its tag from the command line and never opens algorithm_config.yml, so editing configs on this machine buys nothing and gives the two checkouts a way to drift.

--with-dps chains build_dps_images.sh onto the same run. Do not split them: a -dps variant captures the scripts of the image beneath it, so rebuilding a base and forgetting its variant publishes a new tag carrying the old entrypoint — which looks exactly like the bug you just fixed failing to be fixed.

In the workspace — same commit, then everything else

The version lives in five places — algorithm_version and the image tag inside algorithm_container_url in each of the four maap/<module>/algorithm_config.yml files, plus ALGORITHM_VERSION in mur_maap/version.py, which is what the orchestrator asks MAAP to resolve. One script edits all five, and it runs here rather than on the build machine so that the configs, the CWL and the deployment are all produced from one checkout:

git pull
git rev-parse --short HEAD              # MUST match the build machine

./utils/set_algorithm_version.sh 2.0.5           # --dry-run to preview
./utils/generate_cwl.sh                           # optionally --pin-digest
python -m pytest tests/test_algorithm_configs.py

python utils/deploy_algorithms.py --dry-run
python utils/deploy_algorithms.py

git commit -am "chore(maap): application packages 2.0.5"
git push                                          # the CWL, if you want it tracked

The tag passed to the build and the version set here must be the same string. Nothing checks that for you.

Confirm the stamp on the first job of every new version. Every module entrypoint prints its source commit to stderr before doing anything:

MUR image build: 3d47aaa-20260924T154617Z (module: mrva)

That short hash is the only end-to-end evidence that the image running on DPS was built from the source you believe you shipped. Read it before reading anything else in a failure log. A -dirty suffix means the build machine had uncommitted changes, so the stamp names a commit the image does not actually match — treat that as unreleasable.

Why the tests run after generation, not before. tests/test_algorithm_configs.py asserts all five places agree and that a CWL exists for the current version. Between setting the version and the regenerate, that last one fails by design — the configs say 2.0.4 and maap/cwl_workflows/ still holds only 2.0.3. That is the failure telling you the release is half-finished, so run the suite on the side of the split where it can pass.

Old CWLs are deliberately kept rather than deleted: they are how you redeploy a previous version after a bad one (python utils/deploy_algorithms.py --version 2.0.3). That stays safe only because nothing picks a CWL up by globbing the directory — the path is built from an explicit version and must exist at that exact name.

When a tag may have been rebuilt anyway

./utils/generate_cwl.sh --pin-digest rewrites dockerPull to an immutable @sha256: digest instead of a tag. A digest cannot be served from a stale cache — docker inspect repo@sha256:new fails on a host holding only the old bits, so the pull happens. It resolves the digest over HTTPS against the registry rather than through Docker, so it works in the workspace, and it requires the images to have been pushed first.

Redeploy afterwards either way: a registration holds its own frozen copy of the CWL, so editing the file changes nothing already deployed.