feat: add pattern-filtered staging upload helper (#60)#64
Merged
Conversation
Add upload_source_files() for staging local source files into the upload bucket ahead of ingestion. - upload_source_files(local_dir, dest_prefix, pattern, session, on_file, overwrite): uploads only files whose posix path relative to local_dir matches the pattern (re.match, anchored — the same selection the Ingest API performs), writing each to dest_prefix + relative_path verbatim. It does NOT inject the local directory name into the key, so each file's path relative to its location is preserved and the spec's pattern still matches after the move to S3. An on_file(index, total, path) callback supports progress display without coupling the upload layer to a display library. - _split_s3_uri() parses an s3:// destination URI into (bucket, key_prefix). - Add optional prescient_upload_prefix setting for composing destination prefixes under the upload bucket. dest_prefix is a full s3:// URI so the same value can be reused as the rewritten location.path when staging an IngestSpec (#61). Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Factor the relative-key computation out of upload_source_files into _relative_posix() so the cross-platform separator handling is explicit and unit-testable, and route both the pattern match and the object key through it. Add tests asserting that a Windows source tree yields forward-slash S3 keys (keys never contain backslashes) and that a forward-slash spec pattern matches nested files regardless of local OS separator. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
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.
Summary
Implements #60 — the staging upload helper for the end-to-end ingest workflow (parent #56).
Adds
upload_source_files, which uploads only the local files a source file set'spatternselects, preserving each file's path relative to its location so the spec'spatternkeeps matching after the files move to S3.What's included
prescient_sdk/upload.py:upload_source_files(local_dir, dest_prefix, pattern, session, on_file=None, overwrite=True)— selects files whose posix path relative tolocal_dirmatchespattern(anchoredre.match, matching the Ingest API's own selection), and uploads each todest_prefix+ that relative path verbatim. It deliberately does not inject the local directory name into the key (that would shift relative paths and break pattern matching). Reuses the existingiter_filesand_upload. Theon_file(index, total, path)callback enables progress display without coupling the upload layer to Rich._split_s3_uri— parses ans3://bucket/key/prefixURI into(bucket, key_prefix).prescient_sdk/config.py— optionalprescient_upload_prefixsetting for composing destination prefixes under the upload bucket.dest_prefixis a fulls3://…URI so the same value can be reused as the rewrittenlocation.pathwhen staging anIngestSpec(#61) — one source of truth for where files land and where the spec points.Acceptance criteria
{dest_prefix}{relative_path}with no injected directory-name segmenton_filecallback fires once per uploaded file with(index, total, path)prescient_upload_prefixadded to settings (optional)re.matchsemanticsTesting
uv run pytest— 123 passeduv run ruff check prescient_sdk/ tests/— clean; files formatted withruff formatCloses #60
🤖 Generated with Claude Code