Skip to content

Commit f1e5356

Browse files
dhaniram-kshirsagarUbuntuchauhang
authored
Fixed install_from_src failure (#798)
* Fix for issue 796 * Made install_dep modular * fixed import * fixed sudo commands * Changed package name to ts_script to avoid conflict with conda script pkg" * modified script to ts_script Co-authored-by: Ubuntu <[email protected]> Co-authored-by: Geeta Chauhan <[email protected]>
1 parent 38e8e02 commit f1e5356

25 files changed

+65
-54
lines changed

.circleci/config.yml

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ commands:
3434
steps:
3535
- run:
3636
name: Install build and test dependencies for torchserve
37-
command: "python scripts/install_dependencies.py"
37+
command: "python ts_scripts/install_dependencies.py"
3838

3939
attach-torchserve-workspace:
4040
description: "Attach the torchserve directory which was saved into workspace"
@@ -59,7 +59,7 @@ commands:
5959
steps:
6060
- run:
6161
name: Start torchserve, Execute << parameters.collection >> API Tests, Stop torchserve
62-
command: python scripts/test_api.py << parameters.collection >>
62+
command: python ts_scripts/test_api.py << parameters.collection >>
6363
when: always
6464

6565

@@ -102,7 +102,7 @@ jobs:
102102
- install-dependencies
103103
- run:
104104
name: Execute frontend gradle tests
105-
command: python scripts/test_frontend.py
105+
command: python ts_scripts/test_frontend.py
106106
- store_artifacts:
107107
name: Store frontend gradle test results
108108
path: frontend/server/build/reports/tests/test
@@ -117,7 +117,7 @@ jobs:
117117
- install-dependencies
118118
- run:
119119
name: Execute python lint and unit tests
120-
command: python scripts/test_torchserve.py
120+
command: python ts_scripts/test_torchserve.py
121121
- store_artifacts:
122122
name: Store python Test results
123123
path: result_units
@@ -134,7 +134,7 @@ jobs:
134134
- install-torchserve
135135
- run:
136136
name: Execute sanity tests
137-
command: python scripts/test_sanity.py
137+
command: python ts_scripts/test_sanity.py
138138
- store_artifacts:
139139
name: Store TS logs from sanity tests
140140
path: logs/
@@ -171,7 +171,7 @@ jobs:
171171
- install-torchserve
172172
- run:
173173
name: Execute regression suite
174-
command: python scripts/test_regression.py
174+
command: python ts_scripts/test_regression.py
175175
- store_artifacts:
176176
name: Store server logs from regression tests
177177
path: test/pytest/logs/
@@ -232,7 +232,7 @@ jobs:
232232
- install-torchserve
233233
- run:
234234
name: Execute python lint, unit and integration tests
235-
command: python scripts/test_modelarchiver.py
235+
command: python ts_scripts/test_modelarchiver.py
236236
- store_artifacts:
237237
name: Store unit tests results from model archiver tests
238238
path: model-archiver/result_units

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,7 @@ NOTE: This script uninstalls existing `torchserve` and `torch-model-archiver` in
7979
#### For Debian Based Systems/ MacOS
8080

8181
```
82-
python ./scripts/install_from_src.py
82+
python ./ts_scripts/install_from_src.py
8383
```
8484

8585
For information about the model archiver, see [detailed documentation](model-archiver/README.md).

binaries/build.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
REPO_ROOT = os.path.join(os.path.dirname(os.path.abspath(__file__)), "..")
77
sys.path.append(REPO_ROOT)
88

9-
from scripts import tsutils
9+
from ts_scripts import tsutils
1010
from binaries.conda.build_packages import conda_build
1111

1212

binaries/install.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
REPO_ROOT = os.path.join(os.path.dirname(os.path.abspath(__file__)), "..")
77
sys.path.append(REPO_ROOT)
88

9-
from scripts import tsutils
9+
from ts_scripts import tsutils
1010

1111

1212
def install():

ci/buildspec.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ version: 0.2
55
phases:
66
install:
77
commands:
8-
- python scripts/install_dependencies.py --cuda=cu101
8+
- python ts_scripts/install_dependencies.py --cuda=cu101
99

1010
build:
1111
commands:

docs/torchserve_on_win_native.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ NOTE At present, wheels for windows are not available on PyPi. However following
4545
- `git clone https://github.com/pytorch/serve.git`
4646
- `pip install click`
4747
- `cd serve`
48-
- `python .\scripts\install_from_src.py`
48+
- `python .\ts_scripts\install_from_src.py`
4949
- Refer [Install torchserve for development](https://github.com/pytorch/serve#install-torchserve-for-development)
5050

5151
## Troubleshooting

docs/torchserve_on_wsl.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ cd serve
4747
4848
./scripts/setup_wsl_ubuntu
4949
export PATH=$HOME/.local/bin:$PATH
50-
python ./scripts/install_from_src.py
50+
python ./ts_scripts/install_from_src.py
5151
echo 'export PATH=$HOME/.local/bin:$PATH' >> ~/.bashrc
5252
source ~/.bashrc
5353
```

test/buildspec.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ version: 0.2
55
phases:
66
install:
77
commands:
8-
- python scripts/install_dependencies.py --cuda=cu101
8+
- python ts_scripts/install_dependencies.py --cuda=cu101
99

1010
build:
1111
commands:

test/regression_tests.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,9 +6,9 @@
66
REPO_ROOT = os.path.join(os.path.dirname(os.path.abspath(__file__)), "..")
77
sys.path.append(REPO_ROOT)
88

9-
from scripts.install_from_src import install_from_src
10-
from scripts.test_regression import test_regression
11-
from scripts.test_api import test_api
9+
from ts_scripts.install_from_src import install_from_src
10+
from ts_scripts.test_regression import test_regression
11+
from ts_scripts.test_api import test_api
1212

1313
from pygit2 import Repository
1414
git_branch = Repository('.').head.shorthand

torchserve_sanity.py

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
1-
from scripts.test_modelarchiver import test_modelarchiver
2-
from scripts.test_torchserve import test_torchserve
3-
from scripts.install_from_src import install_from_src
4-
from scripts.test_sanity import test_sanity
5-
from scripts.shell_utils import rm_dir
6-
from scripts.test_frontend import test_frontend
7-
import scripts.tsutils as ts
1+
from ts_scripts.test_modelarchiver import test_modelarchiver
2+
from ts_scripts.test_torchserve import test_torchserve
3+
from ts_scripts.install_from_src import install_from_src
4+
from ts_scripts.test_sanity import test_sanity
5+
from ts_scripts.shell_utils import rm_dir
6+
from ts_scripts.test_frontend import test_frontend
7+
import ts_scripts.tsutils as ts
88
import test.print_env_info as build_hdr_printer
99

1010

scripts/Readme.md renamed to ts_scripts/Readme.md

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ The scripts are designed to execute independent of each other.
55
1. [install_dependencies.py](install_dependencies.py) : Helps you install build and test dependencies for torchserve (like java, torch packages, newman, etc)
66
```
77
# Example
8-
python scripts/install_dependencies.py
8+
python ts_scripts/install_dependencies.py
99
1010
2. [tsutils.py](tsutils.py.py) : Import this module in your scripts to have access to utility methods like start\stop torchserve, register\infer\unregister models, etc.
1111
3. [shell_utils.py](shell_utils.py) : Import this module in your scripts to have access to utility methods like download file, remove directory, unzip files, etc
@@ -17,8 +17,8 @@ The scripts are designed to execute independent of each other.
1717
9. [test_api.py](test_api.py) : Executes newman api collections (management\inference\increased_timeout_inference\https\all)
1818
```
1919
# Example
20-
python scripts/test_api.py management
21-
python scripts/test_api.py inference
22-
python scripts/test_api.py all
20+
python ts_scripts/test_api.py management
21+
python ts_scripts/test_api.py inference
22+
python ts_scripts/test_api.py all
2323
```
24-
10. [test_regression.py](test_regression.py) : Executes regression pytests.
24+
10. [test_regression.py](test_regression.py) : Executes regression pytests.
File renamed without changes.

scripts/install_dependencies.py renamed to ts_scripts/install_dependencies.py

Lines changed: 29 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -4,10 +4,11 @@
44

55

66
class Common():
7-
def __init__(self):
7+
def __init__(self, sudo_cmd):
88
# Assumption is nvidia-smi is installed on systems with gpu
99
self.is_gpu_instance = True if os.system("nvidia-smi") == 0 else False
1010
self.torch_stable_url = "https://download.pytorch.org/whl/torch_stable.html"
11+
self.sudo_cmd = sudo_cmd
1112

1213
def install_java(self):
1314
pass
@@ -31,40 +32,42 @@ def install_python_packages(self, cuda_version):
3132
os.system("conda install -y conda-build")
3233

3334
def install_node_packages(self):
34-
os.system("npm install -g newman newman-reporter-html markdown-link-check")
35+
os.system(f"{self.sudo_cmd}apt-get update")
36+
os.system(f"{self.sudo_cmd}npm install -g newman newman-reporter-html markdown-link-check")
3537

3638
def install_jmeter(self):
3739
pass
3840

39-
def install_ab(self):
40-
pass
41-
4241

4342
class Linux(Common):
43+
def __init__(self, sudo_cmd):
44+
super().__init__(sudo_cmd)
45+
4446
def install_java(self):
45-
os.system("apt-get install -y openjdk-11-jdk")
47+
os.system(f"{self.sudo_cmd}apt-get update")
48+
os.system(f"{self.sudo_cmd}apt-get install -y openjdk-11-jdk")
4649

4750
def install_nodejs(self):
48-
os.system("curl -sL https://deb.nodesource.com/setup_14.x | bash -")
49-
os.system("apt-get update")
50-
os.system("apt-get install -y nodejs")
51-
52-
def install_ab(self):
53-
os.system("apt-get install -y apache2-utils")
51+
os.system(f"{self.sudo_cmd}apt-get update")
52+
os.system(f"{self.sudo_cmd}curl -sL https://deb.nodesource.com/setup_14.x | {self.sudo_cmd}bash -")
53+
os.system(f"{self.sudo_cmd}apt-get install -y nodejs")
5454

5555

5656
class Windows(Common):
57+
def __init__(self, sudo_cmd):
58+
super().__init__(sudo_cmd)
59+
5760
def install_java(self):
5861
pass
5962

6063
def install_nodejs(self):
6164
pass
6265

63-
def install_ab(self):
64-
pass
65-
6666

6767
class Darwin(Common):
68+
def __init__(self, sudo_cmd):
69+
super().__init__(sudo_cmd)
70+
6871
def install_java(self):
6972
os.system("brew tap AdoptOpenJDK/openjdk")
7073
os.system("brew cask install adoptopenjdk11")
@@ -76,21 +79,25 @@ def install_torch_packages(self, cuda_version=''):
7679
os.system(f"pip install -U -r requirements/torch.txt -f {self.torch_stable_url}")
7780

7881

79-
if __name__ == "__main__":
80-
parser = argparse.ArgumentParser(description="Install various build and test dependencies of TorchServe")
81-
parser.add_argument('--cuda', default=None, choices=['cu101'], help="CUDA version for torch")
82-
args = parser.parse_args()
83-
82+
def install_dependencies(sudo_cmd='sudo ', cuda_version=None):
8483
os_map = {
8584
"Linux": Linux,
8685
"Windows": Windows,
8786
"Darwin": Darwin
8887
}
89-
system = os_map[platform.system()]()
88+
system = os_map[platform.system()](sudo_cmd)
9089

9190
import sys
9291
# Sequence of installation to be maintained
9392
system.install_java()
9493
system.install_nodejs()
95-
system.install_python_packages(cuda_version=args.cuda)
94+
system.install_python_packages(cuda_version)
9695
system.install_node_packages()
96+
97+
if __name__ == "__main__":
98+
parser = argparse.ArgumentParser(description="Install various build and test dependencies of TorchServe")
99+
parser.add_argument('--cuda', default=None, choices=['cu101'], help="CUDA version for torch")
100+
args = parser.parse_args()
101+
102+
install_dependencies('', cuda_version=args.cuda)
103+

scripts/install_from_src.py renamed to ts_scripts/install_from_src.py

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,11 +3,14 @@
33
import time
44
import shutil
55

6+
67
# To help discover local modules
78
REPO_ROOT = os.path.join(os.path.dirname(os.path.abspath(__file__)), "..")
89
sys.path.append(REPO_ROOT)
910

10-
from scripts import tsutils as ts
11+
from ts_scripts import tsutils as ts
12+
from ts_scripts import install_dependencies as idep
13+
1114

1215
def clean_slate():
1316
print("## Uninstall existing torchserve and model archiver")
@@ -54,4 +57,5 @@ def install_from_src():
5457

5558

5659
if __name__ == '__main__':
60+
idep.install_dependencies()
5761
install_from_src()
File renamed without changes.
File renamed without changes.
File renamed without changes.

scripts/test_api.py renamed to ts_scripts/test_api.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
import os
33
import sys
44
import argparse
5-
from scripts import tsutils as ts
5+
from ts_scripts import tsutils as ts
66

77

88
REPO_ROOT = os.path.join(os.path.dirname(os.path.abspath(__file__)), "..")
File renamed without changes.
File renamed without changes.
File renamed without changes.

scripts/test_sanity.py renamed to ts_scripts/test_sanity.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
import nvgpu
44
import glob
55

6-
from scripts import tsutils as ts
6+
from ts_scripts import tsutils as ts
77

88

99
def run_markdown_link_checker():
File renamed without changes.
File renamed without changes.

0 commit comments

Comments
 (0)