-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #3 from lilab-bcb/develop
Add `--ionice` option
- Loading branch information
Showing
5 changed files
with
33 additions
and
24 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,29 +1,30 @@ | ||
import argparse | ||
|
||
|
||
def copy_files(backend, recursive, parallel, filenames): | ||
def copy_files(backend, recursive, parallel, ionice, filenames): | ||
assert backend in ['aws', 'gcp', 'local'], "Backend not supported!" | ||
|
||
if backend == 'aws': | ||
from strato.backends import AWSBackend | ||
be = AWSBackend() | ||
be.copy(filenames) | ||
be.copy(ionice, filenames) | ||
elif backend == 'gcp': | ||
from strato.backends import GCPBackend | ||
be = GCPBackend() | ||
be.copy(recursive, parallel, filenames) | ||
be.copy(recursive, parallel, ionice, filenames) | ||
else: | ||
from strato.backends import LocalBackend | ||
be = LocalBackend() | ||
be.copy(recursive, filenames) | ||
be.copy(recursive, ionice, filenames) | ||
|
||
|
||
def main(argsv): | ||
parser = argparse.ArgumentParser(description="Copy files or folders. Notice that for AWS backend, a folder link must end with a slash '/'.") | ||
parser.add_argument('--backend', dest='backend', action='store', required=True, help='Specify which backend to use. Available options: aws, gcp, local.') | ||
parser.add_argument('-r', dest='recursive', action='store_true', help="Recursive copy. Not needed for AWS backend.") | ||
parser.add_argument('-m', dest='parallel', action='store_true', help="Run operations in parallel. Only available for GCP backend.") | ||
parser.add_argument('--ionice', dest='ionice', action='store_true', help="Run with ionice to avoid monopolizing local disk's I/O. Only available for Linux.") | ||
parser.add_argument('files', metavar='filenames', type=str, nargs='+', help='List of file paths.') | ||
|
||
args = parser.parse_args(argsv) | ||
copy_files(args.backend, args.recursive, args.parallel, args.files) | ||
copy_files(args.backend, args.recursive, args.parallel, args.ionice, args.files) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,28 +1,29 @@ | ||
import argparse | ||
|
||
|
||
def synchronize_folders(backend, parallel, source, target): | ||
def synchronize_folders(backend, parallel, ionice, source, target): | ||
assert backend in ['aws', 'gcp', 'local'], "Backend not supported!" | ||
|
||
if backend == 'aws': | ||
from strato.backends import AWSBackend | ||
be = AWSBackend() | ||
be.sync(source, target) | ||
be.sync(ionice, source, target) | ||
elif backend == 'gcp': | ||
from strato.backends import GCPBackend | ||
be = GCPBackend() | ||
be.sync(parallel, source, target) | ||
be.sync(parallel, ionice, source, target) | ||
else: | ||
from strato.backends import LocalBackend | ||
be = LocalBackend() | ||
be.sync(source, target) | ||
be.sync(ionice, source, target) | ||
|
||
def main(argsv): | ||
parser = argparse.ArgumentParser(description="Synchronize source and target folders.") | ||
parser.add_argument('--backend', dest='backend', action='store', required=True, help='Specify which backend to use. Available options: aws, gcp, local.') | ||
parser.add_argument('-m', dest='parallel', action='store_true', help="Run operations in parallel. Only available for GCP backend.") | ||
parser.add_argument('--ionice', dest='ionice', action='store_true', help="Run with ionice to avoid monopolizing local disk's I/O. Only available for Linux.") | ||
parser.add_argument('source', metavar='source', type=str, help='Source folder path.') | ||
parser.add_argument('target', metavar='target', type=str, help='Target folder path.') | ||
|
||
args = parser.parse_args(argsv) | ||
synchronize_folders(args.backend, args.parallel, args.source, args.target) | ||
synchronize_folders(args.backend, args.parallel, args.ionice, args.source, args.target) |