Skip to content

shell: defaults param, fix 3 rendering bugs, add bedtools example#1062

Merged
samhita-alla merged 3 commits into
flyteorg:bio-task-wrapperfrom
k1sauce:pr-1055
May 13, 2026
Merged

shell: defaults param, fix 3 rendering bugs, add bedtools example#1062
samhita-alla merged 3 commits into
flyteorg:bio-task-wrapperfrom
k1sauce:pr-1055

Conversation

@k1sauce
Copy link
Copy Markdown
Contributor

@k1sauce k1sauce commented May 13, 2026

Stacked on top of #1055 — depends on the shell extra introduced there.

Summary

  • New defaults={...} parameter on shell.create() — per-input fallback values applied when the caller omits an input, independent of T | None (which controls flag suppression).
  • Three rendering bugs found while building a bedtools intersect wrapper:
    • Positional indices ≥ 10 emitted as bare $10; bash parses that as $1 + literal "0". Tasks with 10+ scalar/bool inputs had values 10..N silently corrupted. Fixed by always-braced ${10}.
    • Optional File / Dir flags emitted unconditionally — the renderer hardcoded -flag /var/inputs/name regardless of whether the caller supplied the file. Now guarded with if [ -e <path> ]; then …; else <flag>=""; fi.
    • Inputs whose names differ only in case (e.g. c vs C, common in bio CLIs) collided on the same _VAL_*/_FLAG_* bash variable and silently overwrote each other. create() now rejects this at declaration time.
  • New examples/shell/12_bedtools_intersect_example.py + examples/shell/modules/bedtools_intersect.py demonstrating a wider-flag-surface bedtools wrapper as a reference. This should probably just go in your plugins but leaving for your reference.

Test plan

  • 146 unit tests pass (28 new across the four areas above)
  • Local Docker run of the bedtools example produces correct output for `wa`, `v`, `count_overlaps` against a small BED fixture
  • Remote run against demo cluster (needs the dev wheel to land on the cluster)

shell.create now accepts `defaults={name: value}` — per-input fallback
values applied when the caller omits an input. Works independently of
`T | None`: required + no default raises, optional + no default suppresses
the flag, either + default uses the default.

Three rendering bugs surfaced while building a bedtools intersect wrapper:

1. Positional-arg indices >= 10 were emitted as bare `$10`, which bash
   parses as `$1` followed by literal "0". Any task with 10+ scalar/bool
   inputs had its 10..N values silently corrupted. Fixed by always braced
   `${10}`.

2. Optional File / Dir flags emitted unconditionally — the renderer
   hardcoded `-flag /var/inputs/name` regardless of whether the caller
   supplied the file, so omitting an optional file flag pointed the tool
   at a missing path. Now guarded with
   `if [ -e <path> ]; then ...; else <flag>=""; fi`.

3. Inputs whose names differed only in case (e.g. `c` vs `C`, common in
   bio CLIs like bedtools / samtools) collided on the same `_VAL_*` /
   `_FLAG_*` bash variable and silently overwrote each other. create()
   now rejects this at declaration time with an error naming both
   offending inputs.

Adds 28 unit tests across the four-cell defaults matrix, optional
File/Dir flag emission, case-collision detection, and the positional-arg
brace regression.

New examples:
- examples/shell/12_bedtools_intersect_example.py — three intersect
  queries in parallel against a small BED fixture.
- examples/shell/modules/bedtools_intersect.py — typed wrapper around
  bedtools intersect; reference for bio-CLI shell-extra modules.

Signed-off-by: Kyle Hazen <kyle@union.ai>
Signed-off-by: Samhita Alla <aallasamhita@gmail.com>
Signed-off-by: Samhita Alla <aallasamhita@gmail.com>
@samhita-alla samhita-alla merged commit f53a8bc into flyteorg:bio-task-wrapper May 13, 2026
39 checks passed
samhita-alla added a commit that referenced this pull request May 13, 2026
)

Stacked on top of #1055 — depends on the shell extra introduced there.

## Summary

- New `defaults={...}` parameter on `shell.create()` — per-input
fallback values applied when the caller omits an input, independent of
`T | None` (which controls flag suppression).
- Three rendering bugs found while building a `bedtools intersect`
wrapper:
- Positional indices ≥ 10 emitted as bare `$10`; bash parses that as
`$1` + literal `"0"`. Tasks with 10+ scalar/bool inputs had values 10..N
silently corrupted. Fixed by always-braced `${10}`.
- Optional File / Dir flags emitted unconditionally — the renderer
hardcoded `-flag /var/inputs/name` regardless of whether the caller
supplied the file. Now guarded with `if [ -e <path> ]; then …; else
<flag>=""; fi`.
- Inputs whose names differ only in case (e.g. `c` vs `C`, common in bio
CLIs) collided on the same `_VAL_*`/`_FLAG_*` bash variable and silently
overwrote each other. `create()` now rejects this at declaration time.
- New `examples/shell/12_bedtools_intersect_example.py` +
`examples/shell/modules/bedtools_intersect.py` demonstrating a
wider-flag-surface bedtools wrapper as a reference. This should probably
just go in your plugins but leaving for your reference.

## Test plan

- [x] 146 unit tests pass (28 new across the four areas above)
- [x] Local Docker run of the bedtools example produces correct output
for \`wa\`, \`v\`, \`count_overlaps\` against a small BED fixture
- [ ] Remote run against demo cluster (needs the dev wheel to land on
the cluster)

---------

Signed-off-by: Kyle Hazen <kyle@union.ai>
Signed-off-by: Samhita Alla <aallasamhita@gmail.com>
Co-authored-by: Samhita Alla <aallasamhita@gmail.com>
Signed-off-by: Samhita Alla <aallasamhita@gmail.com>
samhita-alla added a commit that referenced this pull request May 13, 2026
)

Stacked on top of #1055 — depends on the shell extra introduced there.

## Summary

- New `defaults={...}` parameter on `shell.create()` — per-input
fallback values applied when the caller omits an input, independent of
`T | None` (which controls flag suppression).
- Three rendering bugs found while building a `bedtools intersect`
wrapper:
- Positional indices ≥ 10 emitted as bare `$10`; bash parses that as
`$1` + literal `"0"`. Tasks with 10+ scalar/bool inputs had values 10..N
silently corrupted. Fixed by always-braced `${10}`.
- Optional File / Dir flags emitted unconditionally — the renderer
hardcoded `-flag /var/inputs/name` regardless of whether the caller
supplied the file. Now guarded with `if [ -e <path> ]; then …; else
<flag>=""; fi`.
- Inputs whose names differ only in case (e.g. `c` vs `C`, common in bio
CLIs) collided on the same `_VAL_*`/`_FLAG_*` bash variable and silently
overwrote each other. `create()` now rejects this at declaration time.
- New `examples/shell/12_bedtools_intersect_example.py` +
`examples/shell/modules/bedtools_intersect.py` demonstrating a
wider-flag-surface bedtools wrapper as a reference. This should probably
just go in your plugins but leaving for your reference.

## Test plan

- [x] 146 unit tests pass (28 new across the four areas above)
- [x] Local Docker run of the bedtools example produces correct output
for \`wa\`, \`v\`, \`count_overlaps\` against a small BED fixture
- [ ] Remote run against demo cluster (needs the dev wheel to land on
the cluster)

---------

Signed-off-by: Kyle Hazen <kyle@union.ai>
Signed-off-by: Samhita Alla <aallasamhita@gmail.com>
Co-authored-by: Samhita Alla <aallasamhita@gmail.com>
(cherry picked from commit f53a8bc)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants