All Projects → Othoz → gcsfs

Othoz / gcsfs

Licence: MIT license
Google Cloud Storage filesystem for PyFilesystem2

Programming Languages

python
139335 projects - #7 most used programming language
shell
77523 projects

Projects that are alternatives of or similar to gcsfs

Glusterfs Java Filesystem
GlusterFS for Java
Stars: ✭ 50 (+38.89%)
Mutual labels:  storage, filesystem
Diskover Web
Web file manager, disk space usage, storage search engine and file system analytics for diskover
Stars: ✭ 121 (+236.11%)
Mutual labels:  storage, filesystem
Zbox
Zero-details, privacy-focused in-app file system.
Stars: ✭ 1,185 (+3191.67%)
Mutual labels:  storage, filesystem
Filegator
Powerful Multi-User File Manager
Stars: ✭ 587 (+1530.56%)
Mutual labels:  storage, filesystem
Autarky
Liberating disk space from 📁 node_modules
Stars: ✭ 203 (+463.89%)
Mutual labels:  storage, filesystem
Diskover
File system crawler, disk space usage, file search engine and file system analytics powered by Elasticsearch
Stars: ✭ 977 (+2613.89%)
Mutual labels:  storage, filesystem
File Storage
File storage abstraction for Yii2
Stars: ✭ 116 (+222.22%)
Mutual labels:  storage, filesystem
Glusterfs
Gluster Filesystem : Build your distributed storage in minutes
Stars: ✭ 3,437 (+9447.22%)
Mutual labels:  storage, filesystem
Tus Ruby Server
Ruby server for tus resumable upload protocol
Stars: ✭ 172 (+377.78%)
Mutual labels:  storage, filesystem
Sharesniffer
Network share sniffer and auto-mounter for crawling remote file systems
Stars: ✭ 168 (+366.67%)
Mutual labels:  storage, filesystem
S5cmd
Parallel S3 and local filesystem execution tool.
Stars: ✭ 565 (+1469.44%)
Mutual labels:  storage, filesystem
go-storage
A vendor-neutral storage library for Golang: Write once, run on every storage service.
Stars: ✭ 387 (+975%)
Mutual labels:  storage, gcs
Infinit
The Infinit policy-based software-defined storage platform.
Stars: ✭ 363 (+908.33%)
Mutual labels:  storage, filesystem
Moosefs
MooseFS – Open Source, Petabyte, Fault-Tolerant, Highly Performing, Scalable Network Distributed File System (Software-Defined Storage)
Stars: ✭ 1,025 (+2747.22%)
Mutual labels:  storage, filesystem
Juicefs
JuiceFS is a distributed POSIX file system built on top of Redis and S3.
Stars: ✭ 4,262 (+11738.89%)
Mutual labels:  storage, filesystem
Laravel Storage
A simple filesystem abstraction package for Laravel 4.
Stars: ✭ 100 (+177.78%)
Mutual labels:  storage, filesystem
Shrine
File Attachment toolkit for Ruby applications
Stars: ✭ 2,903 (+7963.89%)
Mutual labels:  storage, filesystem
Flydrive
☁️ Flexible and Fluent framework-agnostic driver based system to manage storage in Node.js
Stars: ✭ 275 (+663.89%)
Mutual labels:  storage, filesystem
Mc
MinIO Client is a replacement for ls, cp, mkdir, diff and rsync commands for filesystems and object storage.
Stars: ✭ 1,962 (+5350%)
Mutual labels:  storage, filesystem
Go Fastdfs
go-fastdfs 是一个简单的分布式文件系统(私有云存储),具有无中心、高性能,高可靠,免维护等优点,支持断点续传,分块上传,小文件合并,自动同步,自动修复。Go-fastdfs is a simple distributed file system (private cloud storage), with no center, high performance, high reliability, maintenance free and other advantages, support breakpoint continuation, block upload, small file merge, automatic synchronization, automatic r…
Stars: ✭ 2,923 (+8019.44%)
Mutual labels:  storage, filesystem

GCSFS

A Python filesystem abstraction of Google Cloud Storage (GCS) implemented as a PyFilesystem2 extension.

https://travis-ci.org/Othoz/gcsfs.svg?branch=master https://readthedocs.org/projects/fs-gcsfs/badge/?version=latest

With GCSFS, you can interact with Google Cloud Storage as if it was a regular filesystem.

Apart from the nicer interface, this will highly decouple your code from the underlying storage mechanism: Exchanging the storage backend with an in-memory filesystem for testing or any other filesystem like S3FS becomes as easy as replacing gs://bucket_name with mem:// or s3://bucket_name.

For a full reference on all the PyFilesystem possibilities, take a look at the PyFilesystem Docs!

Documentation

Installing

Install the latest GCSFS version by running:

$ pip install fs-gcsfs

Or in case you are using conda:

$ conda install -c conda-forge fs-gcsfs

Examples

Instantiating a filesystem on Google Cloud Storage (for a full reference visit the Documentation):

from fs_gcsfs import GCSFS
gcsfs = GCSFS(bucket_name="mybucket")

Alternatively you can use a FS URL to open up a filesystem:

from fs import open_fs
gcsfs = open_fs("gs://mybucket/root_path?project=test&api_endpoint=http%3A//localhost%3A8888&strict=False")

Supported query parameters are:

  • project (str): Google Cloud project to use
  • api_endpoint (str): URL-encoded endpoint that will be passed to the GCS client's client_options
  • strict ("True" or "False"): Whether GCSFS will be opened in strict mode

You can use GCSFS like your local filesystem:

>>> from fs_gcsfs import GCSFS
>>> gcsfs = GCSFS(bucket_name="mybucket")
>>> gcsfs.tree()
├── foo
│   ├── bar
│   │   ├── file1.txt
│   │   └── file2.csv
│   └── baz
│       └── file3.txt
└── file4.json
>>> gcsfs.listdir("foo")
["bar", "baz"]
>>> gcsfs.isdir("foo/bar")
True

Uploading a file is as easy as:

from fs_gcsfs import GCSFS
gcsfs = GCSFS(bucket_name="mybucket")
with open("local/path/image.jpg", "rb") as local_file:
    with gcsfs.open("path/on/bucket/image.jpg", "wb") as gcs_file:
        gcs_file.write(local_file.read())

You can even sync an entire bucket on your local filesystem by using PyFilesystem's utility methods:

from fs_gcsfs import GCSFS
from fs.osfs import OSFS
from fs.copy import copy_fs

gcsfs = GCSFS(bucket_name="mybucket")
local_fs = OSFS("local/path")

copy_fs(gcsfs, local_fs)

For exploring all the possibilities of GCSFS and other filesystems implementing the PyFilesystem interface, we recommend visiting the official PyFilesystem Docs!

Development

To develop on this project make sure you have pipenv installed and run the following from the root directory of the project:

$ pipenv install --dev --three

This will create a virtualenv with all packages and dev-packages installed.

Tests

All CI tests run against an actual GCS bucket provided by Othoz.

In order to run the tests against your own bucket, make sure to set up a Service Account with all necessary permissions:

  • storage.objects.get
  • storage.objects.list
  • storage.objects.create
  • storage.objects.update
  • storage.objects.delete

All five permissions listed above are e.g. included in the predefined Cloud Storage IAM Role roles/storage.objectAdmin.

Expose your bucket name as an environment variable $TEST_BUCKET and run the tests via:

$ pipenv run pytest

Note that the tests mostly wait for I/O, therefore it makes sense to highly parallelize them with xdist, e.g. by running the tests with:

$ pipenv run pytest -n 10

Credits

Credits go to S3FS which was the main source of inspiration and shares a lot of code with GCSFS.

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].