diff --git a/bin/dvc b/bin/dvc new file mode 100755 index 000000000..a10ec2e31 --- /dev/null +++ b/bin/dvc @@ -0,0 +1,3 @@ +#!/bin/bash + +PYTHONPATH=$DVC_HOME python $DVC_HOME/dvc2.py $@ diff --git a/dvc2.py b/dvc2.py index 6b2bd6e98..8c205370e 100755 --- a/dvc2.py +++ b/dvc2.py @@ -1,4 +1,5 @@ from __future__ import print_function + """ main entry point / argument parsing for dvc @@ -7,9 +8,8 @@ NB: for ${REASONS}, cannot be named dvc.py. trust me. import sys -from dvc import * from dvc.runtime import Runtime -from dvc.command.data_import import CmdDataImport +from dvc.command.init import CmdInit from dvc.command.remove import CmdDataRemove from dvc.command.run import CmdRun from dvc.command.repro import CmdRepro @@ -17,7 +17,6 @@ from dvc.command.data_sync import CmdDataSync from dvc.command.data_import import CmdDataImport - def print_usage(): usage = ('', 'These are common dvc commands:', @@ -35,13 +34,14 @@ def print_usage(): print('\n'.join(usage)) if __name__ == '__main__': - cmds = ['init', 'run', 'sync', 'data', 'data-sync', 'data-remove', 'data-import', 'cloud', \ + cmds = ['init', 'run', 'sync', 'repro', 'data', 'data-sync', 'data-remove', 'data-import', 'cloud', \ 'cloud', 'cloud-run', 'cloud-instance-create', 'cloud-instance-remove', 'cloud-instance-describe'] cmds_expand = {'data': ['sync', 'remove', 'import'], 'cloud': ['run', 'instance-create', 'instance-remove', 'instance-describe'] } if len(sys.argv) < 2 or sys.argv[1] not in cmds: + print('Unimplemented or unrecognized command. ' + ' '.join(sys.argv[1])) print_usage() sys.exit(-1) @@ -55,17 +55,19 @@ if __name__ == '__main__': else: subcmd = sys.argv[2] - argv_offset = 1 + (0 if subcmd == None else 1) + argv_offset = 2 + (0 if subcmd == None else 1) if cmd == 'init': - Runtime.run(CmdRun, args_start_loc=2) + Runtime.run(CmdInit, parse_config=False, args_start_loc=2) elif cmd == 'run': - Runtime.run(CmdDataImport, args_start_loc=2) + Runtime.run(CmdRun, args_start_loc=2) elif cmd == 'repro': Runtime.run(CmdRepro, args_start_loc=2) elif cmd == 'data-sync' or (cmd == 'data' and subcmd == 'sync'): Runtime.run(CmdDataSync, args_start_loc=argv_offset) elif cmd == 'data-import' or (cmd == 'data' and subcmd == 'import'): Runtime.run(CmdDataImport, args_start_loc=argv_offset) + elif cmd == 'data-remove' or (cmd == 'data' and subcmd == 'remove'): + Runtime.run(CmdDataRemove, args_start_loc=argv_offset) elif cmd == 'cloud-run' or (cmd == 'cloud' and subcmd == 'run'): print('cloud-run unimplemented') elif cmd == 'cloud-instance-create' or (cmd == 'cloud' and subcmd == 'instance-create'): @@ -75,6 +77,6 @@ if __name__ == '__main__': elif cmd == 'cloud-instance-describe' or (cmd == 'cloud' and subcmd == 'instance-describe'): print('cloud-instance-describe unimplemented') else: - print('Unimplemented or unrecognized command. sorry!') + print('Unimplemented or unrecognized command. ' + ' '.join(sys.argv[1])) print_usage() sys.exit(-1) diff --git a/functest/common.rc b/functest/common.rc index c53069cb8..dda00a5f8 100644 --- a/functest/common.rc +++ b/functest/common.rc @@ -13,11 +13,11 @@ function dvc_info() { function _init_repo() { dvc_info 'init reporitory' git init - dvc-init + dvc init dvc_info 'import xml files' mkdir data/xml - dvc-data-import ../$RAW_DATA_LOCAL/* data/xml + dvc data-import ../$RAW_DATA_LOCAL/* data/xml dvc_info 'copy code' mkdir code diff --git a/functest/test-repro-code.sh b/functest/test-repro-code.sh index 8b1189d45..479131f0a 100755 --- a/functest/test-repro-code.sh +++ b/functest/test-repro-code.sh @@ -6,14 +6,14 @@ function run_test() { mkdir data/tsv dvc_info 'convert Budget.xml to tsv' - dvc-run --code code/xmltotsv.py python code/xmltotsv.py --extract row/@Id,row/@UserId,row/@Name,row/@Class,row/@TagBased,row/@Date data/xml/Badges.xml data/tsv/Badges.tsv + dvc run --code code/xmltotsv.py python code/xmltotsv.py --extract row/@Id,row/@UserId,row/@Name,row/@Class,row/@TagBased,row/@Date data/xml/Badges.xml data/tsv/Badges.tsv dvc_info 'modify code' echo " " >> code/xmltotsv.py git commit -am 'Change code' dvc_info 'reproduce tsv convertion code' - dvc-repro data/tsv/Badges.tsv + dvc repro data/tsv/Badges.tsv } create_repo