Skip to content

refactor: collapse Files shim layer (0.0.18)#104

Closed
ypriverol wants to merge 1 commit into
feat/files-py-modular-architecturefrom
refactor/files-facade-cleanup
Closed

refactor: collapse Files shim layer (0.0.18)#104
ypriverol wants to merge 1 commit into
feat/files-py-modular-architecturefrom
refactor/files-facade-cleanup

Conversation

@ypriverol
Copy link
Copy Markdown
Contributor

Summary

Follow-up to #103. Collapses the backward-compat shim layer in pridepy/files/files.py so providers own their own logic and Files is a true thin facade.

files.py: 912 → 382 LOC. No behaviour change. No test assertion changes. Bumps to 0.0.18.

What changed

  1. Test patches migrated to canonical locations (17 sites across 5 test files):

    • PRIDE methods → patched on PrideProvider (_batch_download_by_protocol, _download_with_fallback, _globus_download_one, stream_all_files_by_project)
    • transport helpers → patched on pridepy.providers.transport (download_ftp_urls, download_http_urls)
    • util helpers → patched on pridepy.providers.util (validate_download)
    • by_url helpers → patched on pridepy.commands.by_url (_http_download_url, _download_single_url)
    • Only patch.object targets changed; assertions untouched.
  2. PRIDE protocol workers moved permanently into PrideProvider: download_files_from_aspera, get_output_file_name (the rest were already there). No shim left on Files.

  3. Every from pridepy.files.files import Files lazy import removed from providers/ and commands/. Providers now call self.X / transport.X / util.X directly. util._get_download_url reads URL-prefix constants from PrideProvider instead of Files. Zero back-into-Files coupling (verified: grep returns 0).

  4. ~60 shim methods deleted from Files. Kept as one-line @staticmethod shims for likely downstream imports: compute_md5, validate_download, read_checksum_file, download_ftp_urls, download_http_urls, plus the accession matchers (is_massive_accession etc., is_direct_download_accession, _repo_uses_tls). Class-attribute constant re-exports preserved.

What Files keeps

Public CLI methods only (each a thin registry dispatch): download_all_raw_files, download_all_category_files, get_all_raw_file_list, get_all_category_file_list, download_file_by_name, get_file_from_api, download_files_by_url, download_files_by_list, download_px_raw_files, stream_all_files_metadata, get_submitted_file_path_prefix — plus the constant re-exports and compat shims above.

Verification

  • Tests: 68 passed, 4 skipped (unchanged)
  • Flake8 (--select=E9,F63,F7,F82): 0 errors
  • pridepy --version: 0.0.18
  • Live smoke: download-file-by-name -a MSV000080175 -f params.xml → MD5 43d87368d705c3f380c1d030b14850c4
  • grep -rn "from pridepy.files.files import Files" pridepy/providers/ pridepy/commands/ → 0 results
  • grep -rn "patch.object(Files," pridepy/tests/ → 0 results

Base-branch note

Targets feat/files-py-modular-architecture (#103) so the diff is small. After #103 merges to dev, update this PR's base.

A follow-up (#105) will restructure the Provider base into a Template-Method shape (rich base class owns the download workflow; adapters fill in provider-specific holes).

Test plan

  • CI passes
  • wc -l pridepy/files/files.py reports < 400
  • Smoke: MD5 43d87368d705c3f380c1d030b14850c4
  • pridepy --version reports 0.0.18

Migrated ~17 patch.object(Files, "X") test targets to canonical locations:
- PRIDE methods now patched on PrideProvider
- transport/util helpers patched on transport / util modules
- by_url helpers patched on commands.by_url

Moved PRIDE protocol workers permanently into PrideProvider:
- download_files_from_{aspera,globus,s3,ftp}
- _batch_download_by_protocol, _download_with_fallback, _globus_download_one
- _protocol_sequence, download_private_file_name, stream_all_files_by_project
- get_submitted_file_path_prefix, save_checksum_file, get_ascp_binary,
  get_output_file_name

Eliminated every from pridepy.files.files import Files lazy import inside
providers/ and commands/. Providers call self.X / transport.X / util.X
directly. Zero back-into-Files coupling.

Files dropped from 912 to 382 LOC: only public CLI methods + class-attribute
constant re-exports. Kept ~5 one-line @staticmethod shims for likely
downstream imports (compute_md5, validate_download, read_checksum_file,
download_ftp_urls, download_http_urls) plus the accession-matcher helpers
(is_massive_accession etc. and is_direct_download_accession) as useful API.

No behaviour change. No test assertion changes. 68 passed, 4 skipped.
Flake8 (--select=E9,F63,F7,F82) clean.
@qodo-code-review
Copy link
Copy Markdown
Contributor

Qodo reviews are paused for this user.

Troubleshooting steps vary by plan Learn more →

On a Teams plan?
Reviews resume once this user has a paid seat and their Git account is linked in Qodo.
Link Git account →

Using GitHub Enterprise Server, GitLab Self-Managed, or Bitbucket Data Center?
These require an Enterprise plan - Contact us
Contact us →

@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai Bot commented May 28, 2026

Important

Review skipped

Auto reviews are disabled on base/target branches other than the default branch.

Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: b2e5acb9-0319-4d39-8346-c601f4cad9c7

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Use the checkbox below for a quick retry:

  • 🔍 Trigger review
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch refactor/files-facade-cleanup

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

ypriverol added a commit that referenced this pull request May 28, 2026
Consolidate the modular-download work (formerly split across PRs #103/#104/
#105) into a single release off master (0.0.15 -> 0.0.16).
@ypriverol
Copy link
Copy Markdown
Contributor Author

Superseded by #105, which now targets master and contains this branch's commits as part of the consolidated 0.0.16 release. Closing to keep a single PR. (Branch left intact.)

@ypriverol ypriverol closed this May 28, 2026
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.

1 participant