Created
January 12, 2022 09:39
-
-
Save skshetry/859342a26c1ea0e81ca8c432cb73702a to your computer and use it in GitHub Desktop.
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
from dvc.repo import locked | |
from dvc.repo.scm_context import scm_context | |
from dvc.repo.add import create_stages | |
@locked | |
@scm_context | |
def single_add(repo, target): | |
# does not support --recursive add | |
stage, = create_stages(repo, [target]) | |
stage.save() | |
stage.commit() | |
stage.dump() | |
if __name__ == "__main__": | |
# Usage: single_add.py <target> | |
from dvc.repo import Repo | |
import os | |
import sys | |
if len(sys.argv) != 2: | |
print(f"Usage: {os.path.basename(__file__)} <target>") | |
sys.exit(1) | |
single_add(Repo(), sys.argv[1]) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment