panpath 0.4.12__tar.gz → 0.4.13__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- {panpath-0.4.12 → panpath-0.4.13}/.coveragerc +5 -0
- {panpath-0.4.12 → panpath-0.4.13}/.github/workflows/build.yml +28 -13
- {panpath-0.4.12 → panpath-0.4.13}/.gitignore +1 -0
- {panpath-0.4.12 → panpath-0.4.13}/PKG-INFO +21 -14
- {panpath-0.4.12 → panpath-0.4.13}/README.md +15 -9
- {panpath-0.4.12 → panpath-0.4.13}/docs/about/changelog.md +32 -0
- {panpath-0.4.12 → panpath-0.4.13}/docs/about/cloudpathlib-compat.md +2 -1
- {panpath-0.4.12 → panpath-0.4.13}/docs/advanced/configuration.md +7 -7
- panpath-0.4.13/docs/advanced/custom-clients.md +56 -0
- panpath-0.4.13/docs/advanced/testing.md +61 -0
- {panpath-0.4.12 → panpath-0.4.13}/docs/getting-started/concepts.md +6 -7
- {panpath-0.4.12 → panpath-0.4.13}/docs/getting-started/quick-start.md +6 -6
- {panpath-0.4.12 → panpath-0.4.13}/docs/guide/bulk-operations.md +3 -4
- {panpath-0.4.12 → panpath-0.4.13}/docs/guide/error-handling.md +6 -7
- {panpath-0.4.12 → panpath-0.4.13}/docs/migration/from-cloudpathlib.md +13 -12
- {panpath-0.4.12 → panpath-0.4.13}/docs/providers/s3.md +13 -17
- {panpath-0.4.12 → panpath-0.4.13}/panpath/__init__.py +7 -18
- {panpath-0.4.12 → panpath-0.4.13}/panpath/azure_async_client.py +50 -130
- {panpath-0.4.12 → panpath-0.4.13}/panpath/azure_client.py +33 -27
- {panpath-0.4.12 → panpath-0.4.13}/panpath/base.py +46 -24
- {panpath-0.4.12 → panpath-0.4.13}/panpath/clients.py +303 -14
- {panpath-0.4.12 → panpath-0.4.13}/panpath/cloud.py +85 -57
- {panpath-0.4.12 → panpath-0.4.13}/panpath/gs_async_client.py +54 -112
- {panpath-0.4.12 → panpath-0.4.13}/panpath/gs_client.py +15 -8
- {panpath-0.4.12 → panpath-0.4.13}/panpath/local_path.py +404 -112
- {panpath-0.4.12 → panpath-0.4.13}/panpath/s3_async_client.py +127 -143
- {panpath-0.4.12 → panpath-0.4.13}/panpath/s3_client.py +79 -17
- {panpath-0.4.12 → panpath-0.4.13}/panpath/s3_path.py +2 -2
- {panpath-0.4.12 → panpath-0.4.13}/pyproject.toml +11 -17
- panpath-0.4.13/tests/conftest.py +455 -0
- panpath-0.4.13/tests/test_audit_fixes.py +1498 -0
- {panpath-0.4.12 → panpath-0.4.13}/tests/test_azure_async_client.py +43 -7
- {panpath-0.4.12 → panpath-0.4.13}/tests/test_azure_client.py +40 -6
- {panpath-0.4.12 → panpath-0.4.13}/tests/test_cloudpath.py +59 -5
- {panpath-0.4.12 → panpath-0.4.13}/tests/test_cloudpath_compat.py +1 -2
- {panpath-0.4.12 → panpath-0.4.13}/tests/test_exceptions.py +0 -1
- {panpath-0.4.12 → panpath-0.4.13}/tests/test_gs_async_client.py +218 -14
- {panpath-0.4.12 → panpath-0.4.13}/tests/test_gs_client.py +46 -5
- panpath-0.4.13/tests/test_gs_cross_storage.py +242 -0
- {panpath-0.4.12 → panpath-0.4.13}/tests/test_local.py +0 -236
- {panpath-0.4.12 → panpath-0.4.13}/tests/test_router.py +0 -2
- {panpath-0.4.12 → panpath-0.4.13}/tests/test_s3_async_client.py +278 -10
- {panpath-0.4.12 → panpath-0.4.13}/tests/test_s3_client.py +300 -8
- panpath-0.4.13/uv.lock +8027 -0
- panpath-0.4.12/docs/advanced/custom-clients.md +0 -43
- panpath-0.4.12/docs/advanced/testing.md +0 -50
- panpath-0.4.12/tests/conftest.py +0 -4
- panpath-0.4.12/uv.lock +0 -4430
- {panpath-0.4.12 → panpath-0.4.13}/.github/workflows/docs.yml +0 -0
- {panpath-0.4.12 → panpath-0.4.13}/CLAUDE.md +0 -0
- {panpath-0.4.12 → panpath-0.4.13}/LICENSE +0 -0
- {panpath-0.4.12 → panpath-0.4.13}/docs/README.md +0 -0
- {panpath-0.4.12 → panpath-0.4.13}/docs/about/license.md +0 -0
- {panpath-0.4.12 → panpath-0.4.13}/docs/advanced/performance.md +0 -0
- {panpath-0.4.12 → panpath-0.4.13}/docs/getting-started/installation.md +0 -0
- {panpath-0.4.12 → panpath-0.4.13}/docs/guide/async-operations.md +0 -0
- {panpath-0.4.12 → panpath-0.4.13}/docs/guide/cloud-storage.md +0 -0
- {panpath-0.4.12 → panpath-0.4.13}/docs/guide/cross-storage.md +0 -0
- {panpath-0.4.12 → panpath-0.4.13}/docs/guide/local-paths.md +0 -0
- {panpath-0.4.12 → panpath-0.4.13}/docs/guide/path-operations.md +0 -0
- {panpath-0.4.12 → panpath-0.4.13}/docs/index.md +0 -0
- {panpath-0.4.12 → panpath-0.4.13}/docs/migration/from-pathlib.md +0 -0
- {panpath-0.4.12 → panpath-0.4.13}/docs/providers/azure.md +0 -0
- {panpath-0.4.12 → panpath-0.4.13}/docs/providers/gcs.md +0 -0
- {panpath-0.4.12 → panpath-0.4.13}/docs/style.css +0 -0
- {panpath-0.4.12 → panpath-0.4.13}/logo.png +0 -0
- {panpath-0.4.12 → panpath-0.4.13}/mkdocs.yml +0 -0
- {panpath-0.4.12 → panpath-0.4.13}/panpath/azure_path.py +0 -0
- {panpath-0.4.12 → panpath-0.4.13}/panpath/exceptions.py +0 -0
- {panpath-0.4.12 → panpath-0.4.13}/panpath/gs_path.py +0 -0
- {panpath-0.4.12 → panpath-0.4.13}/panpath/py.typed +0 -0
- {panpath-0.4.12 → panpath-0.4.13}/panpath/registry.py +0 -0
- {panpath-0.4.12 → panpath-0.4.13}/tests/__init__.py +0 -0
- {panpath-0.4.12 → panpath-0.4.13}/tests/test_azure.py +0 -0
- {panpath-0.4.12 → panpath-0.4.13}/tests/test_base.py +0 -0
- {panpath-0.4.12 → panpath-0.4.13}/tests/test_gs.py +0 -0
- {panpath-0.4.12 → panpath-0.4.13}/tests/test_registry.py +0 -0
- {panpath-0.4.12 → panpath-0.4.13}/tests/test_s3.py +0 -0
- {panpath-0.4.12 → panpath-0.4.13}/tests/utils.py +0 -0
- {panpath-0.4.12 → panpath-0.4.13}/tox.ini +0 -0
|
@@ -16,3 +16,8 @@ exclude_lines =
|
|
|
16
16
|
if not HAS_BOTO3:
|
|
17
17
|
except ImportError:
|
|
18
18
|
except NameError:
|
|
19
|
+
# API stubs on the base classes; every concrete path class overrides them
|
|
20
|
+
raise NotImplementedError
|
|
21
|
+
# Version-conditional branches: each arm is unreachable on some CI
|
|
22
|
+
# interpreter, and coverage is measured per interpreter.
|
|
23
|
+
(?:el)?if sys\.version_info
|
|
@@ -6,10 +6,10 @@ jobs:
|
|
|
6
6
|
|
|
7
7
|
build:
|
|
8
8
|
runs-on: ubuntu-24.04
|
|
9
|
-
if: "
|
|
9
|
+
if: "startsWith(github.ref, 'refs/tags/') || ! contains(github.event.head_commit.message, 'wip')"
|
|
10
10
|
strategy:
|
|
11
11
|
matrix:
|
|
12
|
-
python-version: ["3.9", "3.10", "3.11", "3.12", "3.13"]
|
|
12
|
+
python-version: ["3.9", "3.10", "3.11", "3.12", "3.13", "3.14"]
|
|
13
13
|
|
|
14
14
|
steps:
|
|
15
15
|
- uses: actions/checkout@v6
|
|
@@ -20,16 +20,15 @@ jobs:
|
|
|
20
20
|
- name: Install dependencies
|
|
21
21
|
run: |
|
|
22
22
|
uv sync --all-extras
|
|
23
|
-
-
|
|
24
|
-
|
|
25
|
-
|
|
23
|
+
- name: Type check with mypy
|
|
24
|
+
if: matrix.python-version == '3.12'
|
|
25
|
+
run: uv run mypy panpath
|
|
26
26
|
- name: Test with pytest
|
|
27
27
|
run: uv run pytest tests/ --junitxml=junit/test-results-${{ matrix.python-version }}.xml
|
|
28
28
|
env:
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
AWS_DEFAULT_REGION: us-east-2
|
|
29
|
+
# Tests run against local emulators by default; set PANPATH_LIVE=1
|
|
30
|
+
# with real credentials to exercise the cloud services instead.
|
|
31
|
+
AWS_DEFAULT_REGION: us-east-1
|
|
33
32
|
- name: Upload pytest test results
|
|
34
33
|
uses: actions/upload-artifact@v7
|
|
35
34
|
with:
|
|
@@ -39,9 +38,9 @@ jobs:
|
|
|
39
38
|
if: ${{ always() }}
|
|
40
39
|
|
|
41
40
|
deploy:
|
|
42
|
-
|
|
41
|
+
needs: build
|
|
43
42
|
runs-on: ubuntu-24.04
|
|
44
|
-
if: github.event_name == 'push' && startsWith(github.ref, 'refs/tags')
|
|
43
|
+
if: github.event_name == 'push' && startsWith(github.ref, 'refs/tags/')
|
|
45
44
|
strategy:
|
|
46
45
|
matrix:
|
|
47
46
|
python-version: ["3.12"]
|
|
@@ -51,8 +50,24 @@ jobs:
|
|
|
51
50
|
uses: astral-sh/setup-uv@v8.0.0
|
|
52
51
|
with:
|
|
53
52
|
python-version: ${{ matrix.python-version }}
|
|
54
|
-
- name:
|
|
53
|
+
- name: Build and verify tag version
|
|
55
54
|
run: |
|
|
56
55
|
uv build
|
|
57
|
-
|
|
56
|
+
tag_version="${GITHUB_REF_NAME#v}"
|
|
57
|
+
pkg_version="$(uv run --no-project python -c 'import panpath; print(panpath.__version__)')"
|
|
58
|
+
if [ "$tag_version" != "$pkg_version" ]; then
|
|
59
|
+
echo "Tag version ($tag_version) does not match panpath/__init__.py ($pkg_version)" >&2
|
|
60
|
+
exit 1
|
|
61
|
+
fi
|
|
62
|
+
wheel="dist/panpath-${tag_version}-py3-none-any.whl"
|
|
63
|
+
if [ ! -f "$wheel" ]; then
|
|
64
|
+
echo "Expected wheel not found: $wheel" >&2
|
|
65
|
+
ls -la dist/ >&2
|
|
66
|
+
exit 1
|
|
67
|
+
fi
|
|
68
|
+
- name: Publish to PyPI
|
|
69
|
+
env:
|
|
70
|
+
UV_PUBLISH_USERNAME: ${{ secrets.PYPI_USER }}
|
|
71
|
+
UV_PUBLISH_PASSWORD: ${{ secrets.PYPI_PASSWORD }}
|
|
72
|
+
run: uv publish
|
|
58
73
|
if: success()
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.5
|
|
2
2
|
Name: panpath
|
|
3
|
-
Version: 0.4.
|
|
3
|
+
Version: 0.4.13
|
|
4
4
|
Summary: Universal sync/async local/cloud path library with pathlib-compatible interface
|
|
5
5
|
Project-URL: Homepage, https://github.com/pwwang/panpath
|
|
6
6
|
Project-URL: Repository, https://github.com/pwwang/panpath
|
|
@@ -17,21 +17,22 @@ Classifier: Programming Language :: Python :: 3.9
|
|
|
17
17
|
Classifier: Programming Language :: Python :: 3.10
|
|
18
18
|
Classifier: Programming Language :: Python :: 3.11
|
|
19
19
|
Classifier: Programming Language :: Python :: 3.12
|
|
20
|
+
Classifier: Programming Language :: Python :: 3.13
|
|
21
|
+
Classifier: Programming Language :: Python :: 3.14
|
|
20
22
|
Classifier: Topic :: Software Development :: Libraries :: Python Modules
|
|
21
23
|
Classifier: Topic :: System :: Filesystems
|
|
22
24
|
Requires-Python: <4.0,>=3.9
|
|
23
|
-
Requires-Dist: typing-extensions>=4.0.0
|
|
24
25
|
Provides-Extra: all
|
|
25
26
|
Requires-Dist: aioboto3>=11.0.0; extra == 'all'
|
|
26
27
|
Requires-Dist: aiofiles>=23.0.0; extra == 'all'
|
|
27
|
-
Requires-Dist: azure-storage-blob>=12.0.0; extra == 'all'
|
|
28
|
+
Requires-Dist: azure-storage-blob[aio]>=12.0.0; extra == 'all'
|
|
28
29
|
Requires-Dist: boto3>=1.20.0; extra == 'all'
|
|
29
30
|
Requires-Dist: gcloud-aio-storage>=9.5; extra == 'all'
|
|
30
31
|
Requires-Dist: google-cloud-storage>=2.0.0; extra == 'all'
|
|
31
32
|
Provides-Extra: all-async
|
|
32
33
|
Requires-Dist: aioboto3>=11.0.0; extra == 'all-async'
|
|
33
34
|
Requires-Dist: aiofiles>=23.0.0; extra == 'all-async'
|
|
34
|
-
Requires-Dist: azure-storage-blob>=12.0.0; extra == 'all-async'
|
|
35
|
+
Requires-Dist: azure-storage-blob[aio]>=12.0.0; extra == 'all-async'
|
|
35
36
|
Requires-Dist: gcloud-aio-storage>=9.5; extra == 'all-async'
|
|
36
37
|
Provides-Extra: all-sync
|
|
37
38
|
Requires-Dist: azure-storage-blob>=12.0.0; extra == 'all-sync'
|
|
@@ -39,7 +40,7 @@ Requires-Dist: boto3>=1.20.0; extra == 'all-sync'
|
|
|
39
40
|
Requires-Dist: google-cloud-storage>=2.0.0; extra == 'all-sync'
|
|
40
41
|
Provides-Extra: async-azure
|
|
41
42
|
Requires-Dist: aiofiles>=23.0.0; extra == 'async-azure'
|
|
42
|
-
Requires-Dist: azure-storage-blob>=12.0.0; extra == 'async-azure'
|
|
43
|
+
Requires-Dist: azure-storage-blob[aio]>=12.0.0; extra == 'async-azure'
|
|
43
44
|
Provides-Extra: async-gs
|
|
44
45
|
Requires-Dist: aiofiles>=23.0.0; extra == 'async-gs'
|
|
45
46
|
Requires-Dist: gcloud-aio-storage>=9.5; extra == 'async-gs'
|
|
@@ -212,19 +213,25 @@ path: S3Path = PanPath("s3://bucket/key")
|
|
|
212
213
|
|
|
213
214
|
## Testing
|
|
214
215
|
|
|
215
|
-
Use local
|
|
216
|
+
Tests need no cloud credentials. Use local paths, or point the provider SDK at
|
|
217
|
+
a local emulator (e.g. `moto` for S3, `gcp-storage-emulator` for GCS, Azurite
|
|
218
|
+
for Azure) by configuring the client, e.g.:
|
|
216
219
|
|
|
217
220
|
```python
|
|
218
|
-
import
|
|
219
|
-
from panpath.
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
221
|
+
from panpath.s3_client import S3Client
|
|
222
|
+
from panpath.s3_path import S3Path
|
|
223
|
+
|
|
224
|
+
client = S3Client(endpoint_url="http://localhost:5000") # moto server
|
|
225
|
+
S3Path._default_client = client
|
|
226
|
+
|
|
227
|
+
path = S3Path("s3://test-bucket/file.txt")
|
|
228
|
+
path.write_text("test content")
|
|
229
|
+
assert path.read_text() == "test content"
|
|
226
230
|
```
|
|
227
231
|
|
|
232
|
+
The project's own test suite does the equivalent via the `AWS_ENDPOINT_URL` /
|
|
233
|
+
emulator env vars — see `tests/conftest.py`.
|
|
234
|
+
|
|
228
235
|
## Migration Guide
|
|
229
236
|
|
|
230
237
|
### From pathlib
|
|
@@ -156,19 +156,25 @@ path: S3Path = PanPath("s3://bucket/key")
|
|
|
156
156
|
|
|
157
157
|
## Testing
|
|
158
158
|
|
|
159
|
-
Use local
|
|
159
|
+
Tests need no cloud credentials. Use local paths, or point the provider SDK at
|
|
160
|
+
a local emulator (e.g. `moto` for S3, `gcp-storage-emulator` for GCS, Azurite
|
|
161
|
+
for Azure) by configuring the client, e.g.:
|
|
160
162
|
|
|
161
163
|
```python
|
|
162
|
-
import
|
|
163
|
-
from panpath.
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
164
|
+
from panpath.s3_client import S3Client
|
|
165
|
+
from panpath.s3_path import S3Path
|
|
166
|
+
|
|
167
|
+
client = S3Client(endpoint_url="http://localhost:5000") # moto server
|
|
168
|
+
S3Path._default_client = client
|
|
169
|
+
|
|
170
|
+
path = S3Path("s3://test-bucket/file.txt")
|
|
171
|
+
path.write_text("test content")
|
|
172
|
+
assert path.read_text() == "test content"
|
|
170
173
|
```
|
|
171
174
|
|
|
175
|
+
The project's own test suite does the equivalent via the `AWS_ENDPOINT_URL` /
|
|
176
|
+
emulator env vars — see `tests/conftest.py`.
|
|
177
|
+
|
|
172
178
|
## Migration Guide
|
|
173
179
|
|
|
174
180
|
### From pathlib
|
|
@@ -1,5 +1,37 @@
|
|
|
1
1
|
# Changelog
|
|
2
2
|
|
|
3
|
+
## [0.4.13]
|
|
4
|
+
|
|
5
|
+
- fix: preserve existing cloud object content and metadata on `touch(exist_ok=True)` across all sync/async cloud clients
|
|
6
|
+
- fix: avoid yielding subdirectories twice in `LocalPath.a_glob("**")` and `a_rglob("**")` on Python 3.13+
|
|
7
|
+
- fix: match `pathlib.Path.walk()` semantics and parameters in `LocalPath.walk()` backport on Python < 3.12
|
|
8
|
+
- fix: drop `aiofiles` gate from `LocalPath.a_rmtree()` and delegate local `a_copytree()` to `copytree()`
|
|
9
|
+
- fix: preserve directory symlinks in `LocalPath.copytree()` when `follow_symlinks=False`
|
|
10
|
+
- fix: raise `PermissionError` when S3 `read_bytes()` is access-denied
|
|
11
|
+
- fix: map GCS async HTTP errors (`404` -> `FileNotFoundError`, `401`/`403` -> `PermissionError`) instead of raising `FileNotFoundError` for all errors
|
|
12
|
+
- fix: raise `FileNotFoundError` instead of `google.cloud.exceptions.NotFound` from `GSSyncFileHandle`
|
|
13
|
+
- fix: use hyphenated `symlink-target` S3 user metadata key with backward-compatible read fallback and dual-key writes
|
|
14
|
+
- fix: fix `CloudPath.rename()` for directories, markerless cloud directories, string targets, missing sources, and denied existence probes
|
|
15
|
+
- fix: fix `LocalPath.a_walk()` top-down ordering and avoid recursing into symlinked directories
|
|
16
|
+
- fix: fix `LocalPath.a_resolve()`, `a_copy()`, `rmtree()`, and `a_rmtree()` semantics and symlink handling
|
|
17
|
+
- fix: fix `LocalPath.__init__` on Python 3.12+ and preserve legacy `_expception_as_filenotfound` file handle hook spelling
|
|
18
|
+
- fix: deduplicate and cache async SDK clients per event loop in `AsyncClient`, preventing closed-loop retention and `close()` races
|
|
19
|
+
- perf: stream `LocalPath.a_glob()` and `a_rglob()` lazily via `os.scandir` with constant memory and remove unnecessary `aiofiles` gates from `a_resolve`/`a_copy`/`a_glob`/`a_rglob`
|
|
20
|
+
- build: require `azure-storage-blob[aio]` for `async-azure`, `all-async`, and `all` extras and add Python 3.13/3.14 classifiers
|
|
21
|
+
- build: drop unused `typing-extensions` runtime dependency and run strict `mypy` in CI
|
|
22
|
+
- ci: add Python 3.14 to build matrix, gate PyPI deploy on build matrix, verify tag version against package/wheel version, and pass PyPI credentials via environment variables
|
|
23
|
+
- test: run cloud storage tests against local emulators (moto, gcp-storage-emulator, Azurite) by default with `PANPATH_LIVE=1` opt-in
|
|
24
|
+
- docs: update client configuration, exception handling, and local emulator endpoint documentation
|
|
25
|
+
|
|
26
|
+
## [0.4.12]
|
|
27
|
+
|
|
28
|
+
- fix: ensure `CloudPath.relative_to()` returns a local path
|
|
29
|
+
- fix: raise `NotFound` when blob does not exist in `GSSyncFileHandle`
|
|
30
|
+
- refactor: remove unsupported `mode` parameter from `touch()` methods in cloud clients
|
|
31
|
+
- build: switch build backend to `hatchling` with dynamic version from `panpath/__init__.py`
|
|
32
|
+
- chore: update locked dependencies
|
|
33
|
+
- docs: add project logo
|
|
34
|
+
|
|
3
35
|
## [0.4.11]
|
|
4
36
|
|
|
5
37
|
- chore: migrate from poetry to uv
|
|
@@ -137,7 +137,8 @@ for item in items:
|
|
|
137
137
|
|
|
138
138
|
### Methods Added for Compatibility
|
|
139
139
|
|
|
140
|
-
To ensure cloudpathlib compatibility, we added these methods to `CloudPath`
|
|
140
|
+
To ensure cloudpathlib compatibility, we added these methods to `CloudPath`
|
|
141
|
+
(and the `a_`-prefixed async variants):
|
|
141
142
|
|
|
142
143
|
- `absolute()` - Returns self (cloud paths are always absolute)
|
|
143
144
|
- `is_absolute()` - Always returns True
|
|
@@ -27,18 +27,18 @@ export AZURE_STORAGE_CONNECTION_STRING=your_connection_string
|
|
|
27
27
|
## Custom Clients
|
|
28
28
|
|
|
29
29
|
```python
|
|
30
|
-
from panpath import
|
|
31
|
-
from panpath.
|
|
30
|
+
from panpath.s3_client import S3Client
|
|
31
|
+
from panpath.s3_path import S3Path
|
|
32
32
|
|
|
33
|
-
# Configure S3 client
|
|
34
|
-
|
|
33
|
+
# Configure a shared S3 client
|
|
34
|
+
S3Path._default_client = S3Client(
|
|
35
35
|
aws_access_key_id="key",
|
|
36
36
|
aws_secret_access_key="secret",
|
|
37
|
-
region_name="us-west-2"
|
|
37
|
+
region_name="us-west-2",
|
|
38
38
|
)
|
|
39
39
|
|
|
40
|
-
#
|
|
41
|
-
path =
|
|
40
|
+
# Every S3Path now uses it
|
|
41
|
+
path = S3Path("s3://bucket/file.txt")
|
|
42
42
|
```
|
|
43
43
|
|
|
44
44
|
## See Also
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
# Custom Clients
|
|
2
|
+
|
|
3
|
+
Advanced client management and customization.
|
|
4
|
+
|
|
5
|
+
## Getting Clients
|
|
6
|
+
|
|
7
|
+
Clients are created lazily on first I/O. Pass one explicitly to a path, or set
|
|
8
|
+
it as the class default so every path for that provider shares it:
|
|
9
|
+
|
|
10
|
+
```python
|
|
11
|
+
from panpath.s3_path import S3Path
|
|
12
|
+
from panpath.s3_client import S3Client
|
|
13
|
+
from panpath.gs_path import GSPath
|
|
14
|
+
from panpath.gs_client import GSClient
|
|
15
|
+
from panpath.azure_path import AzurePath
|
|
16
|
+
from panpath.azure_client import AzureBlobClient
|
|
17
|
+
|
|
18
|
+
# Explicit client on a single path
|
|
19
|
+
s3_path = S3Path(
|
|
20
|
+
"s3://bucket/key",
|
|
21
|
+
client=S3Client(aws_access_key_id="key", aws_secret_access_key="secret"),
|
|
22
|
+
)
|
|
23
|
+
|
|
24
|
+
# Shared default for all GSPaths
|
|
25
|
+
GSPath._default_client = GSClient()
|
|
26
|
+
|
|
27
|
+
# Azure Blob
|
|
28
|
+
azure_path = AzurePath(
|
|
29
|
+
"azure://container/blob",
|
|
30
|
+
client=AzureBlobClient(connection_string="connection_string"),
|
|
31
|
+
)
|
|
32
|
+
```
|
|
33
|
+
|
|
34
|
+
Keyword arguments are passed straight to the provider SDK, so anything the SDK
|
|
35
|
+
accepts works here too.
|
|
36
|
+
|
|
37
|
+
## Custom Endpoints
|
|
38
|
+
|
|
39
|
+
For S3-compatible services:
|
|
40
|
+
|
|
41
|
+
```python
|
|
42
|
+
from panpath.s3_client import S3Client
|
|
43
|
+
from panpath.s3_path import S3Path
|
|
44
|
+
|
|
45
|
+
# MinIO
|
|
46
|
+
S3Path._default_client = S3Client(
|
|
47
|
+
endpoint_url="http://localhost:9000",
|
|
48
|
+
aws_access_key_id="minioadmin",
|
|
49
|
+
aws_secret_access_key="minioadmin",
|
|
50
|
+
)
|
|
51
|
+
```
|
|
52
|
+
|
|
53
|
+
## See Also
|
|
54
|
+
|
|
55
|
+
- [Configuration](configuration.md) - Basic configuration
|
|
56
|
+
- [Provider Documentation](../providers/s3.md) - Provider specifics
|
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
# Testing
|
|
2
|
+
|
|
3
|
+
Testing applications that use PanPath.
|
|
4
|
+
|
|
5
|
+
## Using Local Paths for Tests
|
|
6
|
+
|
|
7
|
+
The simplest approach is to use local paths during testing:
|
|
8
|
+
|
|
9
|
+
```python
|
|
10
|
+
import pytest
|
|
11
|
+
from panpath import PanPath
|
|
12
|
+
|
|
13
|
+
def test_file_processing():
|
|
14
|
+
# Use local path instead of cloud
|
|
15
|
+
path = PanPath("/tmp/test-file.txt")
|
|
16
|
+
path.write_text("test content")
|
|
17
|
+
|
|
18
|
+
# Your processing logic
|
|
19
|
+
result = process_file(path)
|
|
20
|
+
|
|
21
|
+
assert result == expected
|
|
22
|
+
|
|
23
|
+
def process_file(path: PanPath) -> str:
|
|
24
|
+
"""Works with both local and cloud paths."""
|
|
25
|
+
content = path.read_text()
|
|
26
|
+
return content.upper()
|
|
27
|
+
```
|
|
28
|
+
|
|
29
|
+
## Mocking Cloud Clients
|
|
30
|
+
|
|
31
|
+
Swap the client for a mock by passing it to the path:
|
|
32
|
+
|
|
33
|
+
```python
|
|
34
|
+
from unittest.mock import Mock
|
|
35
|
+
from panpath.s3_path import S3Path
|
|
36
|
+
|
|
37
|
+
def test_s3_operation():
|
|
38
|
+
mock_client = Mock()
|
|
39
|
+
path = S3Path("s3://bucket/file.txt", client=mock_client)
|
|
40
|
+
|
|
41
|
+
path.read_text()
|
|
42
|
+
mock_client.read_text.assert_called_once_with(
|
|
43
|
+
"s3://bucket/file.txt", encoding="utf-8"
|
|
44
|
+
)
|
|
45
|
+
```
|
|
46
|
+
|
|
47
|
+
For a more realistic setup, run a local emulator and configure each provider using
|
|
48
|
+
the mechanism its SDK supports — see `tests/conftest.py` for a working example.
|
|
49
|
+
`endpoint_url` is S3-only (`S3Client` only; `AsyncS3Client` forwards kwargs to
|
|
50
|
+
`aioboto3.Session`, not `.client()`):
|
|
51
|
+
|
|
52
|
+
| Provider | Emulator | Configuration |
|
|
53
|
+
|---|---|---|
|
|
54
|
+
| S3 | `moto` (`moto[server]`) | `AWS_ENDPOINT_URL` env var (sync & async), or `S3Client(endpoint_url=...)` (sync only) |
|
|
55
|
+
| GCS | `gcp-storage-emulator` | `STORAGE_EMULATOR_HOST` env var (sync & async; `GSClient` has no endpoint kwarg), or `AsyncGSClient(api_root=...)` (async, passed to `Storage(api_root=...)`) |
|
|
56
|
+
| Azure | Azurite | `AZURE_STORAGE_CONNECTION_STRING` env var (sync & async), or `connection_string=...` on `AzureBlobClient` / `AsyncAzureBlobClient` |
|
|
57
|
+
|
|
58
|
+
## See Also
|
|
59
|
+
|
|
60
|
+
- [Contributing](../about/contributing.md) - Development setup
|
|
61
|
+
- [Quick Start](../getting-started/quick-start.md) - Basic usage
|
|
@@ -290,23 +290,22 @@ asyncio.run(download_all(urls))
|
|
|
290
290
|
|
|
291
291
|
### Common Exceptions
|
|
292
292
|
|
|
293
|
+
panpath raises the standard Python exceptions, so the same `except` clauses work
|
|
294
|
+
for local and cloud paths:
|
|
295
|
+
|
|
293
296
|
```python
|
|
294
297
|
from panpath import PanPath
|
|
295
|
-
from panpath.exceptions import
|
|
296
|
-
PanPathException,
|
|
297
|
-
PathNotFoundError,
|
|
298
|
-
PermissionError,
|
|
299
|
-
)
|
|
298
|
+
from panpath.exceptions import PanPathError
|
|
300
299
|
|
|
301
300
|
path = PanPath("s3://bucket/nonexistent.txt")
|
|
302
301
|
|
|
303
302
|
try:
|
|
304
303
|
content = path.read_text()
|
|
305
|
-
except
|
|
304
|
+
except FileNotFoundError:
|
|
306
305
|
print("File not found")
|
|
307
306
|
except PermissionError:
|
|
308
307
|
print("Access denied")
|
|
309
|
-
except
|
|
308
|
+
except PanPathError as e:
|
|
310
309
|
print(f"Other error: {e}")
|
|
311
310
|
```
|
|
312
311
|
|
|
@@ -302,18 +302,18 @@ Configure cloud credentials using environment variables:
|
|
|
302
302
|
For advanced use cases, you can configure clients:
|
|
303
303
|
|
|
304
304
|
```python
|
|
305
|
-
from panpath import
|
|
306
|
-
from panpath.
|
|
305
|
+
from panpath.s3_client import S3Client
|
|
306
|
+
from panpath.s3_path import S3Path
|
|
307
307
|
|
|
308
|
-
#
|
|
309
|
-
|
|
308
|
+
# Create a shared client with custom config
|
|
309
|
+
S3Path._default_client = S3Client(
|
|
310
310
|
aws_access_key_id="your_key",
|
|
311
311
|
aws_secret_access_key="your_secret",
|
|
312
|
-
region_name="us-west-2"
|
|
312
|
+
region_name="us-west-2",
|
|
313
313
|
)
|
|
314
314
|
|
|
315
315
|
# Use the path normally
|
|
316
|
-
path =
|
|
316
|
+
path = S3Path("s3://bucket/file.txt")
|
|
317
317
|
```
|
|
318
318
|
|
|
319
319
|
## Next Steps
|
|
@@ -78,13 +78,12 @@ if directory.exists() and directory.is_dir():
|
|
|
78
78
|
|
|
79
79
|
```python
|
|
80
80
|
from panpath import PanPath
|
|
81
|
-
from panpath.exceptions import PathNotFoundError, PermissionError
|
|
82
81
|
|
|
83
82
|
directory = PanPath("s3://bucket/data/")
|
|
84
83
|
|
|
85
84
|
try:
|
|
86
85
|
directory.rmtree()
|
|
87
|
-
except
|
|
86
|
+
except FileNotFoundError:
|
|
88
87
|
print("Directory doesn't exist")
|
|
89
88
|
except PermissionError:
|
|
90
89
|
print("Access denied")
|
|
@@ -560,7 +559,7 @@ asyncio.run(fast_copy())
|
|
|
560
559
|
|
|
561
560
|
```python
|
|
562
561
|
from panpath import PanPath
|
|
563
|
-
from panpath.exceptions import
|
|
562
|
+
from panpath.exceptions import PanPathError
|
|
564
563
|
|
|
565
564
|
def robust_copytree(src: str, dst: str):
|
|
566
565
|
"""Copy directory with error handling."""
|
|
@@ -570,7 +569,7 @@ def robust_copytree(src: str, dst: str):
|
|
|
570
569
|
try:
|
|
571
570
|
src_path.copytree(dst_path)
|
|
572
571
|
print("Copy successful!")
|
|
573
|
-
except
|
|
572
|
+
except (OSError, PanPathError) as e:
|
|
574
573
|
print(f"Error during copy: {e}")
|
|
575
574
|
# Cleanup partial copy
|
|
576
575
|
if dst_path.exists():
|
|
@@ -4,23 +4,22 @@ Understanding and handling errors in PanPath.
|
|
|
4
4
|
|
|
5
5
|
## Common Exceptions
|
|
6
6
|
|
|
7
|
+
panpath raises the standard Python exceptions, so the same `except` clauses work
|
|
8
|
+
for local and cloud paths:
|
|
9
|
+
|
|
7
10
|
```python
|
|
8
11
|
from panpath import PanPath
|
|
9
|
-
from panpath.exceptions import
|
|
10
|
-
PanPathException,
|
|
11
|
-
PathNotFoundError,
|
|
12
|
-
PermissionError,
|
|
13
|
-
)
|
|
12
|
+
from panpath.exceptions import PanPathError
|
|
14
13
|
|
|
15
14
|
path = PanPath("s3://bucket/nonexistent.txt")
|
|
16
15
|
|
|
17
16
|
try:
|
|
18
17
|
content = path.read_text()
|
|
19
|
-
except
|
|
18
|
+
except FileNotFoundError:
|
|
20
19
|
print("File not found")
|
|
21
20
|
except PermissionError:
|
|
22
21
|
print("Access denied")
|
|
23
|
-
except
|
|
22
|
+
except PanPathError as e:
|
|
24
23
|
print(f"Other error: {e}")
|
|
25
24
|
```
|
|
26
25
|
|
|
@@ -241,17 +241,17 @@ Most operations are identical:
|
|
|
241
241
|
|
|
242
242
|
=== "PanPath"
|
|
243
243
|
```python
|
|
244
|
-
from panpath import
|
|
245
|
-
from panpath.
|
|
244
|
+
from panpath.s3_client import S3Client
|
|
245
|
+
from panpath.s3_path import S3Path
|
|
246
246
|
|
|
247
247
|
# Configure client (optional - uses env vars by default)
|
|
248
|
-
client =
|
|
248
|
+
client = S3Client(
|
|
249
249
|
aws_access_key_id="key",
|
|
250
250
|
aws_secret_access_key="secret"
|
|
251
251
|
)
|
|
252
252
|
|
|
253
|
-
#
|
|
254
|
-
path =
|
|
253
|
+
# Pass the client to a path, or set S3Path._default_client for all paths
|
|
254
|
+
path = S3Path("s3://bucket/file.txt", client=client)
|
|
255
255
|
```
|
|
256
256
|
|
|
257
257
|
### 4. File Caching
|
|
@@ -320,11 +320,11 @@ client = S3Client(...)
|
|
|
320
320
|
path = S3Path("s3://bucket/key", client=client)
|
|
321
321
|
|
|
322
322
|
# After
|
|
323
|
-
from panpath import
|
|
324
|
-
from panpath.
|
|
323
|
+
from panpath.s3_client import S3Client
|
|
324
|
+
from panpath.s3_path import S3Path
|
|
325
325
|
|
|
326
|
-
|
|
327
|
-
path =
|
|
326
|
+
client = S3Client(...)
|
|
327
|
+
path = S3Path("s3://bucket/key", client=client)
|
|
328
328
|
```
|
|
329
329
|
|
|
330
330
|
### Step 4: Update Async Code
|
|
@@ -399,10 +399,11 @@ Here's a complete migration example:
|
|
|
399
399
|
=== "PanPath"
|
|
400
400
|
```python
|
|
401
401
|
from panpath import PanPath
|
|
402
|
-
from panpath.
|
|
402
|
+
from panpath.s3_client import S3Client
|
|
403
|
+
from panpath.s3_path import S3Path
|
|
403
404
|
|
|
404
|
-
# Configure client (optional - uses env vars by default)
|
|
405
|
-
|
|
405
|
+
# Configure shared client (optional - uses env vars by default)
|
|
406
|
+
S3Path._default_client = S3Client(
|
|
406
407
|
aws_access_key_id="key",
|
|
407
408
|
aws_secret_access_key="secret"
|
|
408
409
|
)
|
|
@@ -409,19 +409,19 @@ src_dir.copytree("s3://bucket/backup/")
|
|
|
409
409
|
### Custom Client
|
|
410
410
|
|
|
411
411
|
```python
|
|
412
|
-
from panpath import
|
|
413
|
-
from panpath.
|
|
412
|
+
from panpath.s3_client import S3Client
|
|
413
|
+
from panpath.s3_path import S3Path
|
|
414
414
|
|
|
415
|
-
# Configure with custom settings
|
|
416
|
-
|
|
415
|
+
# Configure with custom settings; kwargs go to boto3.client()
|
|
416
|
+
S3Path._default_client = S3Client(
|
|
417
417
|
aws_access_key_id="your_key",
|
|
418
418
|
aws_secret_access_key="your_secret",
|
|
419
419
|
region_name="us-west-2",
|
|
420
|
-
endpoint_url="https://custom-s3-endpoint.com" # For S3-compatible services
|
|
420
|
+
endpoint_url="https://custom-s3-endpoint.com", # For S3-compatible services
|
|
421
421
|
)
|
|
422
422
|
|
|
423
|
-
#
|
|
424
|
-
path =
|
|
423
|
+
# Every S3Path now uses this configuration
|
|
424
|
+
path = S3Path("s3://bucket/file.txt")
|
|
425
425
|
```
|
|
426
426
|
|
|
427
427
|
### S3-Compatible Services
|
|
@@ -429,35 +429,31 @@ path = PanPath("s3://bucket/file.txt")
|
|
|
429
429
|
PanPath works with S3-compatible services (MinIO, DigitalOcean Spaces, etc.):
|
|
430
430
|
|
|
431
431
|
```python
|
|
432
|
-
from panpath.
|
|
432
|
+
from panpath.s3_client import S3Client
|
|
433
|
+
from panpath.s3_path import S3Path
|
|
433
434
|
|
|
434
435
|
# Configure for MinIO
|
|
435
|
-
|
|
436
|
+
S3Path._default_client = S3Client(
|
|
436
437
|
endpoint_url="http://localhost:9000",
|
|
437
438
|
aws_access_key_id="minioadmin",
|
|
438
|
-
aws_secret_access_key="minioadmin"
|
|
439
|
+
aws_secret_access_key="minioadmin",
|
|
439
440
|
)
|
|
440
441
|
|
|
441
442
|
# Use normally
|
|
442
|
-
|
|
443
|
-
path = PanPath("s3://my-bucket/file.txt")
|
|
443
|
+
path = S3Path("s3://my-bucket/file.txt")
|
|
444
444
|
```
|
|
445
445
|
|
|
446
446
|
## Error Handling
|
|
447
447
|
|
|
448
448
|
```python
|
|
449
449
|
from panpath import PanPath
|
|
450
|
-
from panpath.exceptions import (
|
|
451
|
-
PathNotFoundError,
|
|
452
|
-
PermissionError,
|
|
453
|
-
)
|
|
454
450
|
import botocore.exceptions
|
|
455
451
|
|
|
456
452
|
path = PanPath("s3://bucket/file.txt")
|
|
457
453
|
|
|
458
454
|
try:
|
|
459
455
|
content = path.read_text()
|
|
460
|
-
except
|
|
456
|
+
except FileNotFoundError:
|
|
461
457
|
print("File not found")
|
|
462
458
|
except PermissionError:
|
|
463
459
|
print("Access denied")
|