Pathlib-style classes for local files and named remote storage.
Project description
ppathlib
ppathlib is a path interface for local files and named remote storage.
It behaves like pathlib.Path when no profile is provided, and it switches to remote mode when a profile is given. A profile maps to environment variables that define a backend such as S3, GCS, or Azure Blob Storage, plus an optional default ROOT. SFTP and WebDAV support are planned (구현 예정).
The main examples in this README use S3 because that is the most familiar starting point for most users. The same model also works for other supported remotes.
Why ppathlib
- Use one path API for both local and remote storage
- Keep remote access explicit with named profiles
- Avoid process-global provider credential variables
- Support relative paths against a configured remote
ROOT - Reuse the same profile across pandas and pyarrow workflows
Installation
pip install ppathlib
For parquet workflows you will typically also want:
pip install pandas pyarrow
Quick Start
Local Mode
If profile is omitted, PPath(...) behaves like pathlib.Path(...).
from ppathlib import PPath
path = PPath("data/local-report.parquet")
Remote Mode
Define a named remote with a stable profile name:
export MY_RESEARCH_BUCKET_STORAGE_TYPE=s3
export MY_RESEARCH_BUCKET_ENDPOINT_URL=https://s3.ap-northeast-2.amazonaws.com
export MY_RESEARCH_BUCKET_ACCESS_KEY_ID=xxx
export MY_RESEARCH_BUCKET_SECRET_ACCESS_KEY=yyy
export MY_RESEARCH_BUCKET_REGION=ap-northeast-2
export MY_RESEARCH_BUCKET_ROOT=s3://analytics-bucket
Use a relative path against that remote root:
from ppathlib import PPath
path = PPath("daily/report.parquet", profile="MY_RESEARCH_BUCKET")
with path.open("rb") as f:
payload = f.read()
You can also pass a full remote URI:
from ppathlib import PPath
path = PPath(
"s3://analytics-bucket/daily/report.parquet",
profile="MY_RESEARCH_BUCKET",
)
Core Behavior
from ppathlib import PPath
PPath("data/file.parquet")- local mode
PPath("daily/report.parquet", profile="MY_RESEARCH_BUCKET")- remote mode with
<PROFILE>_ROOT
- remote mode with
PPath("s3://bucket/file.parquet", profile="MY_RESEARCH_BUCKET")- remote mode with an explicit URI
PPath("s3://bucket/file.parquet")- error, because remote URIs require a profile
Example Usage
import pandas as pd
from ppathlib import PPath
src = PPath("in.parquet", profile="MY_RESEARCH_BUCKET")
dst = PPath("out.parquet", profile="MY_RESEARCH_BUCKET")
df = pd.read_parquet(src)
df.to_parquet(dst)
API
PPath(path, profile=None)
Creates either:
- a local path when
profileis omitted - a remote path when
profileis provided
get_client(profile)
Returns the cached client for a named remote.
clear_client_cache()
Clears the internal client registry.
Documentation
License
MIT
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file ppathlib-0.1.0.tar.gz.
File metadata
- Download URL: ppathlib-0.1.0.tar.gz
- Upload date:
- Size: 52.5 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.13.2
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
feffcacb2c752430af8808a1920a52f68fdeb729f0a2d125e549e3d5a220852f
|
|
| MD5 |
ab757d318c7135808c0de775dda43c23
|
|
| BLAKE2b-256 |
d67f56e1f50f472d9e2f018236ddba603d48adc4c62f969c2000fe2774c9274e
|
File details
Details for the file ppathlib-0.1.0-py3-none-any.whl.
File metadata
- Download URL: ppathlib-0.1.0-py3-none-any.whl
- Upload date:
- Size: 63.4 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.13.2
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
b6a46e1812619fba5aa6b88b5e7b5430466637cb857274628f68a32c4d5cf72e
|
|
| MD5 |
b6c2d9d3f7e3c140debd64021df77dc4
|
|
| BLAKE2b-256 |
7990bb86f7cd4fe949bb63f5a9dc5ab0792ea2a3becc6a1d4e01f31ac2004a97
|