renom_cn.api.filesystem

Copyright 2019, Grid.

This source code is licensed under the ReNom Subscription Agreement, version 1.0. ReNom Subscription Agreement Ver. 1.0 ( https://www.renom.jp/info/license/index.html )

renom_cn.api.filesystem. get_fs ( type='local' )

get filesystem function.

Args:
type : string, default "local".
Returns:
fs : pyarrow.filesystem.LocalFileSystem, pyarrow.filesystem.S3FSWrapper.
pyarrow.filesystem module.
Examples:
>>> from renom_cn.api.filesystem import get_fs
>>> fs = get_fs(type="local")
>>> fs.ls(".")
['./a.txt']
>>> fs.mkdir("testdir")
>>> fs.ls(".")
['./a.txt', './testdir']
>>> fs.exists("./a.txt")
True
>>> fs.exists("./b.txt")
False
>>> fs.isdir("./testdir")
True
>>> fs.rm("./a.txt")
>>> fs = get_fs(type="s3")
>>> fs.ls("my-bucket")
FileNotFoundError: my-bucket  # if bucket is empty, raise FileNotFoundError
>>> fs.mkdir("my-bucket/testdir")
>>> fs.ls("my-bucket")
['my-bucket/testdir']
>>> with fs.open('my-bucket/testdir/a.txt', 'wb') as f:
...     f.write(b"hello")
...
5
>>> with fs.open('my-bucket/testdir/a.txt', 'rb') as f:
...     print(f.read())
...
b'hello'
>>> fs.rm('my-bucket/testdir/a.txt')