Skip to content

Add support for S3 Multi-Region Access Point (MRAP) URLs#557

Open
fedemengo wants to merge 6 commits intodrivendataorg:masterfrom
fedemengo:feat/support-s3-mrap
Open

Add support for S3 Multi-Region Access Point (MRAP) URLs#557
fedemengo wants to merge 6 commits intodrivendataorg:masterfrom
fedemengo:feat/support-s3-mrap

Conversation

@fedemengo
Copy link
Copy Markdown

@fedemengo fedemengo commented Apr 9, 2026

Closes #556

Changes

  • cloudpathlib/s3/s3path.py: added _MRAP_PATTERN regex and overridden bucket property on S3Path
  • tests/mock_clients/mock_s3.py: removed bucket name check from head_object (the mock never routes by bucket, only by key)
  • tests/test_s3_specific.py: added 3 tests covering bucket/key parsing, path manipulation, and end-to-end file operations via the
    mock backend

Note: using MRAP paths requires botocore[crt] for SigV4a signing:

pip install botocore[crt]


Contributor checklist:

  • I have read and understood CONTRIBUTING.md
  • Confirmed an issue exists for the PR, and the text Closes #issue appears in the PR summary (e.g., Closes #123).
  • Confirmed PR is rebased onto the latest base
  • Confirmed failure before change and success after change
  • Any generic new functionality is replicated across cloud providers if necessary
  • Tested manually against live server backend for at least one provider
  • Added tests for any new functionality
  • Linting passes locally
  • Tests pass locally
  • Updated HISTORY.md with the issue that is addressed and the PR you are submitting. If the top section is not `## UNRELEASED``, then you need to add a new section to the top of the document for your change.

@fedemengo
Copy link
Copy Markdown
Author

the changes were simple enough, @pjbull gentle ping for review

Copy link
Copy Markdown
Member

@pjbull pjbull left a comment

Choose a reason for hiding this comment

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

A couple comments.Also is it possible to update the tests to use s3_rig following the pattern of the existing tests rather than using S3Path directly (as in some tests) or using monkeypatch as in the others.

Comment thread cloudpathlib/s3/s3path.py Outdated
:type: :class:`str`
"""
if match := _MRAP_PATTERN.match(str(self)):
return match.group("arn")
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.

Let's cache this since it shouldn't change.

if (
not (self.root / Key).exists()
or (self.root / Key).is_dir()
or Bucket != DEFAULT_S3_BUCKET_NAME
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.

IIRC some of the tests use this check in some scenarios. Can we also just add a simple check that it doesn't have '.mrap' here

@fedemengo fedemengo force-pushed the feat/support-s3-mrap branch from 3106e54 to b86732d Compare April 17, 2026 15:52
@fedemengo fedemengo requested a review from pjbull April 17, 2026 15:56
@fedemengo
Copy link
Copy Markdown
Author

I replaced S3Path with rig_ops when tests is not purly path parsing

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 support for S3 Multi-Region Access Point (MRAP) URLs

2 participants