Skip to content

File transfer and sublattice enhancements #1981

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 16 commits into
base: develop
Choose a base branch
from

Conversation

cjao
Copy link
Contributor

@cjao cjao commented Mar 24, 2025

Introduce file transfer and sublattice enhancements to decentralize asset handling

File Transfers

Improve automatic file transfer strategy selection by automatically
handling the following cases:

  • Local-Remote
  • Remote-Local
  • Local-Local

Allow registering new file transfer strategies to handle custom URL schemes

Enhance HTTP strategy to support uploads

Centralize and abstract file transfers in SDK. Dispatch submission and
retrieval now use FileTransfers to upload and download assets

Compute Result.error client side to avoid needless server-side writes
to object store

For asset uploads/downloads, decouple the steps of

  1. Obtaining the upload/download URL
  2. Performing the file transfer

Sublattices

Add endpoint to link sublattice with parent. Link sublattice dispatch with parent electron in _build_sublattice_graph. The dedicated sublattice registration endpoint POST /dispatches/{dispatch_id}/sublattices is no longer used.

Adjust server-side handling of sublattice dispatches in update_node_result. Since the sublattice dispatch_id is now linked to the parent electron during _build_sublattice_graph, the server no longer needs to read the sublattice manifest from object storage if it can see the link in the DB.

Improve handling of sublattices built using executors that can't reach the control plane (e.g. AWS Batch -|-> Covalent running on local workstation).

  • When _build_sublattice_graph is unable to submit the sublattice directly, it tars up the staging directory returns the tarball to the control plane.
  • Add a new importer to 1) extract the tarball, 2) import the sublattice manifest, 3) transfer assets to object storage.
  • Replace legacy sublattice importer. Future improvements will reduce the server memory footprint from handling these sublattices (see code comments about streaming the tarball to the extractor)
  • Remove obsolete endpoint POST /dispatches/{dispatch_id}/sublattices

Misc improvements

Sublattices: Only copy db references when copying assets

Sublattice result -> parent electron output
Final electron output -> Dispatch result
Original electron attributes -> redispatched electron attributes

Sublattice: Back up manifest asset record before overwriting it

Cleanup: remember to hold refs to background tasks

Cleanup: refactor URI filtering

Cleanup: remove unused APIs

  • I have added the tests to cover my changes.
  • I have updated the documentation and CHANGELOG accordingly.
  • I have read the CONTRIBUTING document.

@cjao cjao marked this pull request as ready for review March 24, 2025 20:40
@cjao cjao requested a review from a team as a code owner March 24, 2025 20:40
@cjao cjao mentioned this pull request Mar 24, 2025
3 tasks
@cjao cjao force-pushed the file-transfer-enhancements branch 6 times, most recently from 19905ce to 73e9ef5 Compare March 30, 2025 22:26
cjao and others added 15 commits March 31, 2025 18:50
*** File Transfers ***

Improve automatic file transfer strategy selection by automatically
handling the following cases:

- Local-Remote
- Remote-Local
- Local-Local

Allow registering new file transfer strategies

Enhance HTTP strategy to support uploads

Centralize and abstract file transfers in SDK. Dispatch submission and
retrieval now use FileTransfers to upload and download assets

Compute Result.error client side to avoid needless server-side writes
to object store

*** Sublattices ***

Add endpoint to link sublattice with parent. Link sublattice dispatch
with parent electron in `_build_sublattice_graph`. The dedicated
sublattice registration endpoint `POST
/dispatches/{dispatch_id}/sublattices` is no longer used.

Adjust server-side handling of sublattice dispatches in `update_node_result`

Introduce new sublattice tarball importer:

- Replace json sublattice importer. Future improvements will allow the
server to avoid loading all (serialized) sublattice assets in memory
- Remove obsolete endpoint `POST /dispatches/{dispatch_id}/sublattices`

** Misc improvements **

Sublattices: Only copy db references when copying assets

Sublattice result -> parent electron output
Final electron output -> Dispatch result
Original electron attributes -> redispatched electron attributes

Sublattice: Back up manifest asset record before overwriting it

Cleanup: remember to hold refs to background tasks
These changes pave the way for more general object storage backends (e.g. s3)

To upload the output of an electron:
1. Send POST `/dispatches/{dispatch_id}/electrons/{node_id}/assets/output`
2. PUT contents to the returned `remote_uri`. In the future, one can
use a file transfer to handle more general destination URLs.

To download the output of an electron:
1. Send GET `/dispatches/{dispatch_id}/electrons/{node_id}/assets/output`
2. Send GET request `remote_uri`. In the future, one can
use a file transfer to handle more general source URLs.

Cleanup: remove unused asset endpoints
Also demo file transfers in local executor
@cjao cjao force-pushed the file-transfer-enhancements branch from 73e9ef5 to 821e942 Compare March 31, 2025 22:51
@cjao
Copy link
Contributor Author

cjao commented Apr 8, 2025

Gentle reminder @wjcunningham7 @FyzHsn : )

@cjao cjao force-pushed the file-transfer-enhancements branch from 821e942 to 6e1144f Compare April 15, 2025 23:02
@cjao cjao force-pushed the file-transfer-enhancements branch from 6e1144f to ea02034 Compare April 15, 2025 23:11
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