Skip to content

fix: export all Argo manifests (cron workflow, sensor) in --only-json#3095

Open
npow wants to merge 4 commits into
masterfrom
npow/fix-argo-only-json-export
Open

fix: export all Argo manifests (cron workflow, sensor) in --only-json#3095
npow wants to merge 4 commits into
masterfrom
npow/fix-argo-only-json-export

Conversation

@npow

@npow npow commented Apr 13, 2026

Copy link
Copy Markdown
Collaborator

Summary

  • argo-workflows create --only-json now exports all Argo manifests, not just the WorkflowTemplate
  • Output is a JSON object with up to three keys: workflow_template (always), cron_workflow (when @schedule is used), and sensor (when @trigger/@trigger_on_finish is used)
  • Previously the CronWorkflow and Sensor configs were silently dropped
  • _cron_workflow_json() now mirrors ARGO_WORKFLOWS_USE_SCHEDULES — uses "schedules": [...] (list) when the flag is True, matching what ArgoClient.schedule_workflow_template actually deploys

Fixes #1730, fixes #1940.

⚠️ Breaking change: output format

The output of --only-json has changed from a bare WorkflowTemplate JSON object to a wrapper envelope:

Before:

{"apiVersion": "argoproj.io/v1alpha1", "kind": "WorkflowTemplate", ...}

After:

{"workflow_template": {...}, "cron_workflow": {...}}

If you have scripts parsing the old output, update them to add .workflow_template:

# old
python flow.py argo-workflows create --only-json | jq '.spec.templates'

# new
python flow.py argo-workflows create --only-json | jq '.workflow_template.spec.templates'

Test plan

  • Added test/ux/core/test_argo_manifests.py with tests for all manifest export scenarios
  • Added mock.patch tests for both ARGO_WORKFLOWS_USE_SCHEDULES=True and False paths in TestCronWorkflowJson

🤖 Generated with Claude Code

@npow npow requested a review from saikonen April 13, 2026 21:31
@greptile-apps

greptile-apps Bot commented Apr 13, 2026

Copy link
Copy Markdown
Contributor

Greptile Summary

This PR expands Argo --only-json output to include all generated manifests. The main changes are:

  • Adds CronWorkflow JSON export alongside the WorkflowTemplate.
  • Adds Sensor JSON export when trigger manifests are present.
  • Switches the CLI output to a wrapper object with manifest-specific keys.
  • Adds tests for plain, scheduled, triggered, and combined manifest export cases.

Confidence Score: 5/5

This looks safe to merge.

  • No blocking issue tied to the prior review threads remains in the changed code.
  • The CronWorkflow schedule field now follows the same config switch as the deployment path.

Important Files Changed

Filename Overview
metaflow/plugins/argo/argo_workflows.py Adds helpers to export WorkflowTemplate, CronWorkflow, and Sensor manifests as one JSON object.
metaflow/plugins/argo/argo_workflows_cli.py Updates --only-json to print the combined manifest export while preserving deployer metadata.
test/ux/core/test_argo_manifests.py Adds coverage for the new manifest wrapper shape and CronWorkflow schedule field variants.

Reviews (5): Last reviewed commit: "fix: mirror ARGO_WORKFLOWS_USE_SCHEDULES..." | Re-trigger Greptile

Comment thread metaflow/plugins/argo/argo_workflows.py
@dallinstevens

Copy link
Copy Markdown

@npow This is exactly what my team needs with our implementation of metaflow/argocd. Anything we can do to help get this over the line? Happy to carry it forward: rebase on master, get CI green, add tests while keeping your authorship to this if you're open to it.

Nissan Pow and others added 3 commits July 14, 2026 21:19
Previously, `argo-workflows create --only-json` only exported the
WorkflowTemplate JSON, silently dropping CronWorkflow config (for
@schedule flows) and Sensor config (for @trigger flows).

Now the output is a JSON object with up to three keys:
- "workflow_template": always present
- "cron_workflow": present when @schedule is used
- "sensor": present when @trigger/@trigger_on_finish is used

Fixes #1730, fixes #1940.
Add subprocess-based tests that run the actual CLI with --only-json
against both a plain flow and a @schedule flow, verifying the output
JSON contains the expected manifest keys (workflow_template,
cron_workflow). Tests skip gracefully outside the devstack.

Co-Authored-By: Claude Opus 4.6 (1M context) <[email protected]>
--only-json requires s3/azure/gs datastore. Keep METAFLOW_HOME/PROFILE
so devstack config is used when available, and skip gracefully when no
cloud datastore is configured.

Co-Authored-By: Claude Opus 4.6 (1M context) <[email protected]>
@npow npow force-pushed the npow/fix-argo-only-json-export branch from 8a1f532 to c416489 Compare July 14, 2026 21:19
Comment thread metaflow/plugins/argo/argo_workflows.py Outdated
When ARGO_WORKFLOWS_USE_SCHEDULES=True, ArgoClient.schedule_workflow_template
builds a CronWorkflow spec with "schedules" (list) instead of "schedule" (scalar).
_cron_workflow_json() was hardcoding the legacy scalar form, causing exported
manifests to diverge from what ArgoClient would actually deploy on clusters with
the flag enabled.

- Import ARGO_WORKFLOWS_USE_SCHEDULES in argo_workflows.py
- Branch on the flag in _cron_workflow_json() to match ArgoClient's behavior
- Add unit tests (mock.patch both True/False paths) in TestCronWorkflowJson
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

2 participants