Skip to main content

Asyncio implementation of megfile

Project description

aiomegfile - Asyncio implementation of megfile

Build Documents Codecov Latest version Support python versions License

aiomegfile is asyncio implementation of megfile.

Support Protocols

  • fs(local filesystem)
  • s3

Support more in the future.

Installation

pip3 install aiomegfile

Quick Start

Smart methods and SmartPath are the same as megfile, but all methods are async. You can use aiomegfile to do file operations in an async way.

Functional Interface Example

import asyncio
from aiomegfile import smart_open

async def main():
    async with smart_open('s3://bucket/key', 'r') as f:
        content = await f.read()
        print(content)

if __name__ == '__main__':
    asyncio.run(main())

SmartPath Interface

SmartPath has a similar interface with pathlib.Path, but async.

import asyncio
from aiomegfile import SmartPath

async def main():
    path = SmartPath('s3://bucket/key')
    content = await path.read_text()
    print(content)

if __name__ == '__main__':
    asyncio.run(main())

Quick Start

Smart methods and SmartPath are the same as megfile, but all methods are async. You can use aiomegfile to do file operations in an async way.

Functional Interface Example

import asyncio
from aiomegfile import smart_open

async def main():
    async with smart_open('s3://bucket/key', 'r') as f:
        content = await f.read()
        print(content)

if __name__ == '__main__':
    asyncio.run(main())

SmartPath Interface

SmartPath has a similar interface with pathlib.Path, but async.

import asyncio
from aiomegfile import SmartPath

async def main():
    path = SmartPath('s3://bucket/key')
    content = await path.read_text()
    print(content)

if __name__ == '__main__':
    asyncio.run(main())

CLI

Install the CLI extras:

pip3 install "aiomegfile[cli]"

Example usage:

amf ls ./data
amf ls s3://bucket/prefix -l
amf cp -r ./data s3://bucket/backup
amf sync ./data s3://bucket/backup --progress-bar

For a wider protocol matrix and advanced configuration, see the megfile docs: http://megvii-research.github.io/megfile

How to Contribute

  • We welcome everyone to contribute code to the aiomegfile project, but the contributed code needs to meet the following conditions as much as possible: You can submit code even if the code doesn't meet conditions. The project members will evaluate and assist you in making code changes

    • Code format: Your code needs to pass code format check. aiomegfile uses ruff as lint tool
    • Static check: Your code needs complete type hint. aiomegfile uses pytype as static check tool. If pytype failed in static check, use # pytype: disable=XXX to disable the error and please tell us why you disable it.
    • Test: Your code needs complete unit test coverage. aiomegfile uses pyfakefs and moto as local file system and s3 virtual environment in unit tests. The newly added code should have a complete unit test to ensure the correctness
  • You can help to improve aiomegfile in many ways:

    • Write code.
    • Improve documentation.
    • Report or investigate bugs and issues.
    • If you find any problem or have any improving suggestion, submit a new issue as well. We will reply as soon as possible and evaluate whether to adopt.
    • Review pull requests.
    • Star aiomegfile repo.
    • Recommend aiomegfile to your friends.
    • Any other form of contribution is welcomed.

Project details


Download files

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

Source Distributions

No source distribution files available for this release.See tutorial on generating distribution archives.

Built Distribution

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

aiomegfile-0.0.2-py3-none-any.whl (82.8 kB view details)

Uploaded Python 3

File details

Details for the file aiomegfile-0.0.2-py3-none-any.whl.

File metadata

  • Download URL: aiomegfile-0.0.2-py3-none-any.whl
  • Upload date:
  • Size: 82.8 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.10.19

File hashes

Hashes for aiomegfile-0.0.2-py3-none-any.whl
Algorithm Hash digest
SHA256 b82cca712bbc697884b66da78de9fd0a197aec7b6fe555aee2be219524613e1c
MD5 fb48f211d96224bb4f54aca2d187942a
BLAKE2b-256 12828a20230f2ebe5d0ba24b48efedbcede1c64e72a3806723d13523b98785f2

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