Metadata-Version: 2.1
Name: stratocumulus
Version: 0.2.1
Summary: File backend component of Cumulus
Author-email: "Yiming Yang, Joshua Gould, Rimte Rocher, Bo Li" <cumulus-support@googlegroups.com>
License: BSD 3-Clause License
        
        Copyright (c) 2021, klarman-cell-observatory
        All rights reserved.
        
        Redistribution and use in source and binary forms, with or without
        modification, are permitted provided that the following conditions are met:
        
        1. Redistributions of source code must retain the above copyright notice, this
           list of conditions and the following disclaimer.
        
        2. Redistributions in binary form must reproduce the above copyright notice,
           this list of conditions and the following disclaimer in the documentation
           and/or other materials provided with the distribution.
        
        3. Neither the name of the copyright holder nor the names of its
           contributors may be used to endorse or promote products derived from
           this software without specific prior written permission.
        
        THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
        AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
        IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
        DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
        FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
        DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
        SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
        CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
        OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
        OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
        
Project-URL: Source, https://github.com/lilab-bcb/stratocumulus
Project-URL: Documentation, https://github.com/lilab-bcb/stratocumulus
Classifier: Development Status :: 5 - Production/Stable
Classifier: Intended Audience :: Developers
Classifier: Intended Audience :: Science/Research
Classifier: License :: OSI Approved :: BSD License
Classifier: Natural Language :: English
Classifier: Operating System :: POSIX :: Linux
Classifier: Operating System :: MacOS :: MacOS X
Classifier: Operating System :: Microsoft :: Windows
Classifier: Programming Language :: Python :: 3
Classifier: Topic :: Software Development :: Build Tools
Requires-Python: >=3
Description-Content-Type: text/x-rst
License-File: LICENSE
Requires-Dist: s3fs
Requires-Dist: importlib-metadata (>=0.7) ; python_version < "3.8"
Provides-Extra: test
Requires-Dist: pytest ; extra == 'test'

===================
Stratocumulus
===================

|PyPI| |Python| |License|

.. |PyPI| image:: https://img.shields.io/pypi/v/stratocumulus.svg
   :target: https://pypi.org/project/stratocumulus

.. |Python| image:: https://img.shields.io/pypi/pyversions/stratocumulus.svg
   :target: https://pypi.org/project/stratocumulus

.. |License| image:: https://img.shields.io/github/license/lilab-bcb/stratocumulus
   :target: https://github.com/lilab-bcb/stratocumulus/blob/master/LICENSE

Stratocumulus is the backend component of `Cumulus <https://github.com/klarman-cell-observatory/cumulus>`_, which aims to providing a unified backend interface for different cloud environments.

Installation
+++++++++++++++

Stratocumulus does not include any Cloud SDK. You need to install the corresponding SDK separately, depending on which Cloud platform you use:

* Google Cloud: Install `Google Cloud SDK <https://cloud.google.com/sdk/docs/install>`_.
* Amazon AWS: Install `AWS CLI <https://aws.amazon.com/cli/>`_.
* Local machine: Works for Linux and macOS. Please make sure **rsync** is installed, as some commands will use it.

After that, install Stratocumulus in your Python environment by command::

    pip install stratocumulus

Usage
++++++

Stratocumulus has 4 commands:

* ``cp``: Copy file(s)/folder(s).
* ``sync``: Synchronize two folders, usually used for copying one folder.
* ``rm``: Remove file(s)/folder(s).
* ``exist``: Check if a (remote) file/folder exists.

These commands have options specific to backend. For now, Stratocumulus supports the following backends:

* ``aws``: Amazon AWS.
* ``gcp``: Google Cloud.
* ``local``: Local machine. In specific, macOS or Linux.

``cp``
^^^^^^^^^^

This command copies file(s) or folder(s). See examples below::

   # AWS upload
   strato cp file1 folder2 s3://my-bucket/target_folder/
   # AWS download
   strato cp s3://my-bucket/source_folder/*.zip /target_folder/

   # GCP upload
   strato cp -m -r --ionice file1 folder2 gs://my-bucket/target_folder/
   # GCP download
   mkdir /target_folder
   strato cp -m gs://my-bucket/source_folder/*.zip /target_folder/

   # Local Machine
   strato cp -r file1 folder2 /target_folder/

Notice that:

* For AWS backend, you must explicitly attach a trailing slash for source folder.
* For Google Cloud download, you'll have to explicitly create the target folder, and then run ``strato cp`` command.
* Wildcards are acceptable.
* ``-r`` option is not needed for AWS, and copying folders is always recursive.
* ``-m`` and ``--ionice`` options only work for Google Cloud.

For details on the options, try command ``strato cp -h``.

``sync``
^^^^^^^^^^^

This command synchronizes two folders. Notice that this synchronization will delete content in the target folder not existing in the source folder.

See examples below::

   # AWS
   strato sync source_folder s3://my-bucket/target_folder
   # GCP
   strato sync -m --ionice source_folder gs://my-bucket/target_folder
   # Local Machine
   strato sync source_folder target_folder

Notice that:

* ``-m`` and ``--ionice`` options only work for Google Cloud.

For details on the options, try command ``strato sync -h``.

``rm``
^^^^^^^^^

This command deletes file(s) or folder(s). See examples below::

   # AWS
   strato rm s3://my-bucket/file1 s3://my-bucket/folder2/
   # GCP
   strato rm -m gs://my-bucket/file1 gs://my-bucket/folder2 gs://my-bucket/folder3/*.zip
   # Local Machine
   strato rm file1 folder2

Notice that:

* ``-m`` option only works for Google Cloud.
* For AWS backend, wildcards are not yet accepted.

For details on the options, try command ``strato rm -h``.

``exists``
^^^^^^^^^^^^^

This command checks if a (remote) file or folder exists. If it exists, the command terminates without any output.
Otherwise, the command will break with Python ``subprocess.CalledProcessError`` exception.

See examples below::

   # AWS
   strato exists s3://my-bucket/file1
   # GCP
   strato exists gs://my-bucket/folder2/
   # Local Machine
   strato exists folder2/

Notice that this command works for both file and folder, regardless of backend.

For details on the options, try command ``strato exists -h``.

``help``
^^^^^^^^^^

Type ``strato -h`` or ``strato --help`` to check available Stratocumulus commands.

Check version
^^^^^^^^^^^^^^^

Type ``strato -v`` or ``strato --version`` to check the version of Stratocumulus currently installed on your machine.
