Skip to content

Conversation

@milanmlft
Copy link
Member

Description

Closes #606
Adds the SFTPUploader class to handle uploads to an SFTP server, such as the ARC TRE.

Type of change

Please delete options accordingly to the description.

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to not work as expected)
  • This change requires a documentation update

Suggested Checklist

  • I have performed a self-review of my own code.
  • I have made corresponding changes to the documentation.
  • My changes generate no new warnings.
  • I have commented my code, particularly in hard-to-understand areas.
  • I have passed on my local host device. (see further details at the CONTRIBUTING document)
  • Make sure your branch is up-to-date with main branch. See CONTRIBUTING for a general example to syncronise your branch with the main branch.
  • I have requested review to this PR.
  • I have addressed and marked as resolved all the review comments in my PR.
  • Finally, I have selected squash and merge

@milanmlft milanmlft requested review from Copilot and stefpiatek July 8, 2025 11:32
@milanmlft milanmlft linked an issue Jul 8, 2025 that may be closed by this pull request
1 task
# Get SFTP connection details from keyvault
self.host = self.keyvault.fetch_secret(f"{az_prefix}--sftp--host")
self.username = self.keyvault.fetch_secret(f"{az_prefix}--sftp--username")
self.password = self.keyvault.fetch_secret(f"{az_prefix}--sftp--password")
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Probably makes more sense to pass in a private SSH key here for authentication, instead of password.

@codecov
Copy link

codecov bot commented Jul 8, 2025

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 81.09%. Comparing base (5232e41) to head (5ed119c).
Report is 1 commits behind head on main.

❗ There is a different number of reports uploaded between BASE (5232e41) and HEAD (5ed119c). Click for more details.

HEAD has 1 upload less than BASE
Flag BASE (5232e41) HEAD (5ed119c)
7 6
Additional details and impacted files
@@            Coverage Diff             @@
##             main     #607      +/-   ##
==========================================
- Coverage   88.35%   81.09%   -7.27%     
==========================================
  Files          73       68       -5     
  Lines        3272     3210      -62     
==========================================
- Hits         2891     2603     -288     
- Misses        381      607     +226     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

Adds a new SFTPUploader strategy to upload DICOM archives and Parquet exports to an SFTP server, backed by integration tests using a Docker‐based test server.

  • Implements SFTPUploader with methods to send ZIP streams and upload nested Parquet files.
  • Introduces SFTPServer helper for spinning up a local Docker SFTP container in tests.
  • Updates dependencies (docker, paramiko) and pre‐commit config to include their type stubs.

Reviewed Changes

Copilot reviewed 5 out of 5 changed files in this pull request and generated 2 comments.

Show a summary per file
File Description
pixl_core/src/core/uploader/_sftp.py New SFTPUploader with _connect_client, send_via_sftp, and upload_parquet_files
pixl_core/tests/uploader/test_sftp.py Tests for sending DICOM ZIPs and Parquet exports via SFTP
pixl_core/tests/uploader/helpers/sftpserver.py SFTPServer Docker container helper for local SFTP testing
pixl_core/pyproject.toml Added docker and paramiko dependencies
.pre-commit-config.yaml Added types-docker and types-paramiko to linting hooks
Comments suppressed due to low confidence (2)

pixl_core/src/core/uploader/_sftp.py:78

  • The docstring mentions "FTPS" but this class implements SFTP. Update to "Upload Parquet via SFTP" for accuracy.
        Upload parquet to FTPS under <project name>/<extract datetime>/parquet.

pixl_core/tests/uploader/test_sftp.py:143

  • The path segment uses "test" but the directory in the repo is likely tests. Update to /"tests"/resources/omop so the fixture can find the sample files.
    parquet_export.copy_to_exports(Path(__file__).parents[3] / "test" / "resources" / "omop")

self.username = self.keyvault.fetch_secret(f"{az_prefix}--sftp--username")
self.password = self.keyvault.fetch_secret(f"{az_prefix}--sftp--password")
self.port = int(self.keyvault.fetch_secret(f"{az_prefix}--sftp--port"))
self.known_hosts_path = self.keyvault.fetch_secret(f"{az_prefix}--sftp--known-hosts-path")
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Might make more sense to pass in the host key itself, instead of a known_hosts file. On the other hand, the known_hosts file is what you get from the TRE.

milanmlft and others added 3 commits July 8, 2025 12:35
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
@milanmlft
Copy link
Member Author

Closing in favour of #608

@milanmlft milanmlft closed this Jul 9, 2025
@stefpiatek
Copy link
Contributor

Why not have both?

@milanmlft
Copy link
Member Author

Why not have both?

Not against it, but the tests on CI were running into permission errors which I'm not getting locally. So I decided not to open that can of worms 😅 But happy to pick this back up if we ever really need it/I have some more time.

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.

Add Uploader for ARC TRE

3 participants