<#7534 feat(copilot): add NAMED_DIR file input lay...
# flyte-github
a
#7534 feat(copilot): add NAMED_DIR file input layout to preserve filenames Pull request opened by k1sauce CoPilot stages File and list[File] inputs at extensionless paths (/var/inputs/ for a single File, /var/inputs// for list elements), which breaks tools that sniff format by extension — e.g. salmon rejects a gzipped FASTQ staged as "0". Add an opt-in DataLoadingConfig.file_input_layout enum {DIRECT=0 (default) | NAMED_DIR=1}. DIRECT is the existing behavior, so raw ContainerTasks are unaffected. Under NAMED_DIR the downloader stages each File input into a per-input directory under its ORIGINAL basename (recovered from the blob URI, which the SDK preserves on upload), so names and extensions round-trip end-to-end: fasta : File -> /var/inputs/fasta/genome.fasta reads : list[File] -> /var/inputs/reads/sample_R1.fastq.gz /var/inputs/reads/sample_R2.fastq.gz list[File] elements that share a basename are de-duplicated with an index prefix (1_reads.fastq.gz) so colliding names never clobber. Dir inputs are multipart blobs and are untouched by the flag. Consumers glob /var/inputs//* to read File/list[File] inputs. • flyteidl2/core/tasks.proto: add FileInputLayout enum + DataLoadingConfig.file_input_layout field; regenerate Go bindings • flytecopilot/data/download.go: per-input-dir staging under NAMED_DIR for single File and list[File], with basename collision dedup • flytecopilot/cmd/download.go: --file-input-layout flag (empty=DIRECT) • flyteplugins/.../flytek8s/copilot.go: thread pilot.GetFileInputLayout() into the downloader's --file-input-layout arg • tests updated across data/, cmd/, and flytek8s/ for the new behavior Tracking issue Related to the shell-task / file-staging native-feel work in the flyte SDK (companion
file_input_layout=NAMED_DIR
emit lands in the SDK side). Why are the changes needed? CoPilot stages
File
and
list[File]
inputs at extensionless paths: • a single
File
→
/var/inputs/<var>
(a file with no extension) •
list[File]
elements →
/var/inputs/<var>/0
,
/var/inputs/<var>/1
, … (bare indices) Many bioinformatics tools (and others) detect a file's format from its extension, so an extensionless input is rejected outright. Concretely, salmon refuses a gzipped FASTQ staged as `0`:
Copy code
has extension , …neither a fasta nor a fastq
There is no way for a task author to fix this from the task side — the staged paths are chosen by CoPilot — and the only workarounds (per-input symlinks, renaming inside the command) leak staging details into every wrapper and defeat the goal of a "file input just works" experience. The fix has to live in CoPilot. What changes were proposed in this pull request? Add an opt-in
DataLoadingConfig.file_input_layout
enum with two values: •
DIRECT = 0
— the existing behavior. Default, so raw `ContainerTask`s and every current caller are unaffected (zero behavior change unless explicitly opted in). •
NAMED_DIR = 1
— stage each `File`/`list[File]` input into a per-input directory under its original basename, recovered from the blob URI (the SDK already preserves the original filename in the URI on upload). Names and extensions round-trip end-to-end:
Copy code
fasta : File        -> /var/inputs/fasta/genome.fasta
reads : list[File]  -> /var/inputs/reads/sample_R1.fastq.gz
                       /var/inputs/reads/sample_R2.fastq.gz
index : Dir         -> /var/inputs/index/...        (unchanged — multipart blob)
Details: • Single
File
under
NAMED_DIR
is placed inside
/var/inputs/<var>/<basename>
(a per-input dir), mirroring
list[File]
, so a glob over
/var/inputs/<var>/*
finds it. •
list[File]
elements keep their original basename instead of a bare index. Elements that share a basename (e.g. same filename from two source directories) are de-duplicated with an index prefix (
reads.fastq.gz
, then
1_reads.fastq.gz
) so colliding names never clobber. •
Dir
inputs are multipart blobs and flow through the existing recursive-download path; they are not affected by the flag (a directory already carries its own internal filenames). • Consumers reference `File`/`list[File]` inputs by globbing `/var/inputs/<var>/*`;
Dir
inputs stay referenced as
/var/inputs/<var>
directly. Wiring: • `flyteidl2/core/tasks.proto`: add the
FileInputLayout
enum and
DataLoadingConfig.file_input_layout
field; regenerate Go bindings. • `flytecopilot/data/download.go`: per-input-dir staging under
NAMED_DIR
for single
File
and
list[File]
, with basename collision dedup;
DIRECT
path unchanged. • `flytecopilot/cmd/download.go`:
--file-input-layout
flag (empty value defaults to
DIRECT
for backward compatibility). • `flyteplugins/go/tasks/pluginmachinery/flytek8s/copilot.go`: thread
pilot.GetFileInputLayout()
into the downloader's
--file-input-layout
arg. How was this patch tested? Unit tests added/updated, all passing: •
flytecopilot/data/download_test.go
•
TestNamedDirLayoutPreservesExtensions
— single
File
and
list[File]
stage under their original basenames (
fasta/genome.fasta
,
reads/sample_R1.fastq.gz
,
reads/sample_R2.fastq.gz
). •
TestNamedDirLayoutDedupesCollidingBasenames
— two list elements sharing a basename stage as
reads/reads.fastq.gz
and
reads/1_reads.fastq.gz
(no clobber). •
TestDirectLayoutIsUnchanged
— under
DIRECT
,
list[File]
elements stay at bare indices (
0
,
1
) and a single
File
stays a file directly at
/var/inputs/<var>
(backward compatibility). •
flyteplugins/.../flytek8s/copilot_test.go
—
TestDownloadCommandArgs
updated for the new signature and the expected
--file-input-layout NAMED_DIR
arg. •
flytecopilot/cmd/download.go
— flag parsing covered, including empty →
DIRECT
default. Commands:
Copy code
cd flytecopilot && go build ./... && go test ./data/ ./cmd/
cd flyteplugins && go test ./go/tasks/pluginmachinery/flytek8s/
Labels • added Setup process N/A — no setup changes.
NAMED_DIR
is opt-in via `DataLoadingConfig.file_input_layout`; existing tasks default to
DIRECT
and behave exactly as before. Screenshots N/A Check all the applicable boxes • I updated the documentation accordingly. • All new and existing tests passed. • All commits are signed-off. Related PRs Companion SDK change emits
file_input_layout=NAMED_DIR
for shell tasks and globs `/var/inputs/<var>/*`; it depends on
flyteidl2
(Python) being republished with the new field. Stack Docs link flyteorg/flyte