Skip to content

Capture ResourcePath transfer_from exception in copy_files_for_distribution#108

Open
zhaoyuyoung wants to merge 1 commit into
mainfrom
tickets/DM-54502
Open

Capture ResourcePath transfer_from exception in copy_files_for_distribution#108
zhaoyuyoung wants to merge 1 commit into
mainfrom
tickets/DM-54502

Conversation

@zhaoyuyoung
Copy link
Copy Markdown
Contributor

Checklist

  • ran Jenkins
  • added a release note for user-visible changes to doc/changes

@codecov
Copy link
Copy Markdown

codecov Bot commented May 15, 2026

Codecov Report

❌ Patch coverage is 92.59259% with 2 lines in your changes missing coverage. Please review.
✅ Project coverage is 37.06%. Comparing base (01a8ea7) to head (0893198).
✅ All tests successful. No failed tests found.

Files with missing lines Patch % Lines
python/lsst/ctrl/bps/panda/utils.py 60.00% 1 Missing and 1 partial ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main     #108      +/-   ##
==========================================
+ Coverage   34.88%   37.06%   +2.18%     
==========================================
  Files          13       13              
  Lines        1313     1330      +17     
  Branches      214      214              
==========================================
+ Hits          458      493      +35     
+ Misses        835      816      -19     
- Partials       20       21       +1     

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

Comment thread python/lsst/ctrl/bps/panda/utils.py Outdated
future_file_copy = {}
for src, trgt in files_to_copy.items():
_LOG.debug("Staging %s to %s", src, trgt)
future = copy_executor.submit(trgt.transfer_from, src, transfer="copy")
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

I think this code is more complicated than it needs to be. If trgt and src are ResourcePath objects then ResourcePath.mtransfer can do all of this itself so you can delete most of this code.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

I'll check ResourcePath.mtransfer. This is a piece of legacy codes that started with IDF, so I guess it exists for a reason.

At the same time, I've found the reason why w_2026_12 failed to copy the quantum graph with the wrong protocol http:/ at RAL. It turns out the uri is treated as a local file other than the WebDAV one. So it's not a silent failure, but a successful transfer_from to the wrong destination.

Copy link
Copy Markdown
Member

@timj timj May 15, 2026

Choose a reason for hiding this comment

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

It existed before ResourcePath.mtransfer was written and which does exactly what this legacy code does.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Thanks for showing me this very useful tool. I've changed to use ResourcePath.mtransfer and the exception it catches. Will ask for a review next week.

@zhaoyuyoung zhaoyuyoung force-pushed the tickets/DM-54502 branch 2 times, most recently from 9b46ccd to 3e517ff Compare May 16, 2026 02:05
Comment thread python/lsst/ctrl/bps/panda/utils.py Outdated
if future.result() is not None:
raise RuntimeError("Error of placing files to the distribution point")
_LOG.info("Staging %s to %s", src, trgt)
results = ResourcePath.mtransfer("copy", files_to_copy.items(), do_raise=False)
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Are you sure you don't want to let it raise? You end up with a combo exception with all the failures in it whereas the code below is only reporting a single failure.

raise RuntimeError(
f"Error of placing file to the distribution point: {trgt}"
) from result.exception
if not trgt.exists():
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

I'm not sure it's possible for the copy to succeed but the file to not be there.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

This was motivated by the initial "silent" failure we suspected. In w12 when the copy didn't show any exception, but pipetaskInit couldn't find the QG. If we don't need check the file exists, then we can turn ResourcePath.mtransfer raise to be true.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

If the copy succeeds the file will be there (unless something very strange has happened) so I don't think you need to explicitly need to check. Even if you want to explicitly check you should still let mtransfer raise.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Done. Now let ResourcePath.mtransfer raise the grouped exceptions. Only two files to be transferred, so I leave the existence check there.

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.

2 participants