Repository navigation
feat(workflow): pull and clear as functions for Workflow pipelines - #206
Merged
Merged
Conversation
dtcli.workflow.pull_dataset and clear_dataset run `datatrail pull`/`clear` in the calling process, so a Workflow step's logs show their output, then check what they did and raise if they failed: pull reports some failures (no CADC certificate, minoc down, unknown scope, no files) only on the console and exits 0, and ctx.exit(1) is returned rather than raised under standalone_mode=False. Both create the configuration for `site` when there's none, and return (results, products, plots) as Workflow expects. Clearing a dataset with no local copy succeeds. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #206 +/- ##
==========================================
- Coverage 87.91% 83.48% -4.44%
==========================================
Files 33 35 +2
Lines 4493 4655 +162
==========================================
- Hits 3950 3886 -64
- Misses 543 769 +226 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
masonng-astro
approved these changes
Nov 1, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Why
Workflow pipelines (e.g. baseband localization on CANFAR, CHIMEFRB/baseband-analysis#661) stage and clear data with
datatrail pull/datatrail clear. Run as commands, the runner captures their output into the Work's results in MongoDB, and it doesn't show in the step's logs. Run as functions, the output goes to the session's logs, but the click commands can't be called correctly:pullreports several failures only on the console and exits 0: no valid CADC certificate, minoc down, an unknown scope, no files found at minoc. A step that pulled nothing is marked a success, and the next step runs on missing data. This also affects the CLI used as a command today.ctx.exit(1)is returned, not raised, when a click command is called withstandalone_mode=False(as Workflow does), so those failures are successes too.[ -f ~/.datatrail/config.yaml ] || datatrail config init --site canfar) can't be expressed in a function step.-vis a counted option, which Workflow can't pass to a click command.What
dtcli/workflow.py, without changing the CLI:pull_dataset(scope, dataset, cores=1, site=None, verbose=1)runspull --force, then checks withfind_missing_dataset_filesthat every file is here. It raises if the command returned an exit code, the dataset can't be checked, files are missing, or there are none.clear_dataset(scope, dataset, site=None, clear_parents=False, verbose=1)finds the dataset's path ascleardoes, runsclear --force, and raises if the path is still there. A dataset with no local copy is left alone and isn't a failure, so it can clean up after a failed pull.sitewhen there's none (likeconfig init --site <site>), and raise if it's set up for another site.(results, products, plots), the shape Workflow expects of a function. Results:scope,dataset, plusfiles/directory(pull) orpath/cleared(clear).Use in a pipeline step:
docs/workflow.mddocuments both, linked frommkdocs.ymlunder User Guide.Tests
tests/test_workflow.py(14 tests): the outcome shape and arguments passed; creating the configuration; refusing another site's; raising for an exit code, an unknown scope, missing files, no files and click errors; clearing and checking; no local copy; files left behind; the dataset's path not found or the server unreachable.I didn't set up this repo's uv environment locally; I ran them in the
baseband-analysis:v1.12.0image with this branch in place of its installeddtcli(all 14 pass). Pre-commit passes. Please check CI.🤖 Generated with Claude Code