Skip to main content

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
  • 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 profile is omitted
  • a remote path when profile is 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


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

ppathlib-0.1.0.tar.gz (52.5 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

ppathlib-0.1.0-py3-none-any.whl (63.4 kB view details)

Uploaded Python 3

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

Hashes for ppathlib-0.1.0.tar.gz
Algorithm Hash digest
SHA256 feffcacb2c752430af8808a1920a52f68fdeb729f0a2d125e549e3d5a220852f
MD5 ab757d318c7135808c0de775dda43c23
BLAKE2b-256 d67f56e1f50f472d9e2f018236ddba603d48adc4c62f969c2000fe2774c9274e

See more details on using hashes here.

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

Hashes for ppathlib-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 b6a46e1812619fba5aa6b88b5e7b5430466637cb857274628f68a32c4d5cf72e
MD5 b6c2d9d3f7e3c140debd64021df77dc4
BLAKE2b-256 7990bb86f7cd4fe949bb63f5a9dc5ab0792ea2a3becc6a1d4e01f31ac2004a97

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page