Asyncio implementation of megfile
Project description
aiomegfile - Asyncio implementation of megfile
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
aiomegfileproject, 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.
aiomegfileusesruffas lint tool - Static check: Your code needs complete type hint.
aiomegfileusespytypeas static check tool. Ifpytypefailed in static check, use# pytype: disable=XXXto disable the error and please tell us why you disable it. - Test: Your code needs complete unit test coverage.
aiomegfileusespyfakefsandmotoas local file system and s3 virtual environment in unit tests. The newly added code should have a complete unit test to ensure the correctness
- Code format: Your code needs to pass code format check.
-
You can help to improve
aiomegfilein 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
aiomegfilerepo. - Recommend
aiomegfileto 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
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 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
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
b82cca712bbc697884b66da78de9fd0a197aec7b6fe555aee2be219524613e1c
|
|
| MD5 |
fb48f211d96224bb4f54aca2d187942a
|
|
| BLAKE2b-256 |
12828a20230f2ebe5d0ba24b48efedbcede1c64e72a3806723d13523b98785f2
|