Spaces:
Runtime error
Runtime error
Update cli.py
Browse files- t5s/cli.py +51 -20
t5s/cli.py
CHANGED
|
@@ -3,30 +3,50 @@ import os
|
|
| 3 |
import subprocess
|
| 4 |
import sys
|
| 5 |
|
| 6 |
-
arg_parser = argparse.ArgumentParser(
|
| 7 |
-
|
|
|
|
| 8 |
# Command choice
|
| 9 |
-
command_subparser = arg_parser.add_subparsers(
|
|
|
|
|
|
|
| 10 |
|
| 11 |
-
parser_req = command_subparser.add_parser(
|
|
|
|
|
|
|
| 12 |
|
| 13 |
-
parser_dirs = command_subparser.add_parser(
|
| 14 |
-
|
|
|
|
|
|
|
| 15 |
|
| 16 |
-
parser_push = command_subparser.add_parser(
|
|
|
|
|
|
|
| 17 |
|
| 18 |
-
parser_pull = command_subparser.add_parser(
|
|
|
|
|
|
|
| 19 |
|
| 20 |
-
parser_run = command_subparser.add_parser(
|
| 21 |
-
|
|
|
|
|
|
|
|
|
|
| 22 |
|
| 23 |
-
parser_visualize = command_subparser.add_parser(
|
|
|
|
|
|
|
| 24 |
|
| 25 |
-
parser_upload = command_subparser.add_parser(
|
|
|
|
|
|
|
| 26 |
|
| 27 |
-
parser_lint = command_subparser.add_parser(
|
| 28 |
|
| 29 |
-
parser_clone = command_subparser.add_parser(
|
|
|
|
|
|
|
| 30 |
|
| 31 |
|
| 32 |
class Run(object):
|
|
@@ -37,15 +57,26 @@ class Run(object):
|
|
| 37 |
arguments = self.arguments
|
| 38 |
print(f"arguments passed: {arguments['command']}")
|
| 39 |
# os.chdir('../')
|
| 40 |
-
cmd = [
|
| 41 |
-
|
| 42 |
-
|
| 43 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 44 |
retval = os.getcwd()
|
| 45 |
print(retval)
|
| 46 |
return list_files.returncode
|
| 47 |
-
elif arguments[
|
| 48 |
-
os.chdir(
|
| 49 |
retval = os.getcwd()
|
| 50 |
print(retval)
|
| 51 |
list_files = subprocess.run(["make", arguments["command"]])
|
|
|
|
| 3 |
import subprocess
|
| 4 |
import sys
|
| 5 |
|
| 6 |
+
arg_parser = argparse.ArgumentParser(
|
| 7 |
+
description="T5 Summarisation Using Pytorch Lightning", prog="t5s"
|
| 8 |
+
)
|
| 9 |
# Command choice
|
| 10 |
+
command_subparser = arg_parser.add_subparsers(
|
| 11 |
+
dest="command", help="command (refer commands section in documentation)"
|
| 12 |
+
)
|
| 13 |
|
| 14 |
+
parser_req = command_subparser.add_parser(
|
| 15 |
+
"requirements", help="Install Python Dependencies."
|
| 16 |
+
)
|
| 17 |
|
| 18 |
+
parser_dirs = command_subparser.add_parser(
|
| 19 |
+
"dirs",
|
| 20 |
+
help="Create directories that are ignored by git but required for " "the project",
|
| 21 |
+
)
|
| 22 |
|
| 23 |
+
parser_push = command_subparser.add_parser(
|
| 24 |
+
"push", help="Upload Data to default DVC remote"
|
| 25 |
+
)
|
| 26 |
|
| 27 |
+
parser_pull = command_subparser.add_parser(
|
| 28 |
+
"pull", help="Download Data from default DVC remote"
|
| 29 |
+
)
|
| 30 |
|
| 31 |
+
parser_run = command_subparser.add_parser(
|
| 32 |
+
"run",
|
| 33 |
+
help="run the DVC pipeline - recompute any modified outputs such as "
|
| 34 |
+
"processed data or trained models",
|
| 35 |
+
)
|
| 36 |
|
| 37 |
+
parser_visualize = command_subparser.add_parser(
|
| 38 |
+
"visualize", help="run the visualization using Streamlit"
|
| 39 |
+
)
|
| 40 |
|
| 41 |
+
parser_upload = command_subparser.add_parser(
|
| 42 |
+
"upload", help="push the trained model to HF model hub"
|
| 43 |
+
)
|
| 44 |
|
| 45 |
+
parser_lint = command_subparser.add_parser("lint", help=" Lint using flake8")
|
| 46 |
|
| 47 |
+
parser_clone = command_subparser.add_parser(
|
| 48 |
+
"clone", help="Clone the T5 summarisation repo"
|
| 49 |
+
)
|
| 50 |
|
| 51 |
|
| 52 |
class Run(object):
|
|
|
|
| 57 |
arguments = self.arguments
|
| 58 |
print(f"arguments passed: {arguments['command']}")
|
| 59 |
# os.chdir('../')
|
| 60 |
+
cmd = [
|
| 61 |
+
"requirements",
|
| 62 |
+
"dirs",
|
| 63 |
+
"push",
|
| 64 |
+
"pull",
|
| 65 |
+
"run",
|
| 66 |
+
"visualize",
|
| 67 |
+
"upload",
|
| 68 |
+
"lint",
|
| 69 |
+
]
|
| 70 |
+
if arguments["command"] == "clone":
|
| 71 |
+
list_files = subprocess.run(
|
| 72 |
+
["git", "clone", "https://dagshub.com/gagan3012/summarization.git"]
|
| 73 |
+
)
|
| 74 |
+
os.chdir("./summarization/")
|
| 75 |
retval = os.getcwd()
|
| 76 |
print(retval)
|
| 77 |
return list_files.returncode
|
| 78 |
+
elif arguments["command"] in cmd:
|
| 79 |
+
os.chdir("./summarization/")
|
| 80 |
retval = os.getcwd()
|
| 81 |
print(retval)
|
| 82 |
list_files = subprocess.run(["make", arguments["command"]])
|