Skip to content

Commit 0f62372

Browse files
committed
Modify packager test to utilize dummy example application code
1 parent 3f91379 commit 0f62372

File tree

1 file changed

+10
-47
lines changed

1 file changed

+10
-47
lines changed

tests/system/packager/test_packager.py

Lines changed: 10 additions & 47 deletions
Original file line numberDiff line numberDiff line change
@@ -9,56 +9,19 @@
99
# See the License for the specific language governing permissions and
1010
# limitations under the License.
1111

12-
import argparse
13-
import json
1412
import os
15-
import shutil
16-
import tempfile
13+
import subprocess
1714

18-
from monai.deploy.packager import util as packager_util
15+
from monai.deploy.cli.main import main as monai_deploy
1916

2017

2118
def test_packager():
22-
23-
# Create mock inputs
2419
test_map_tag = "monaitest:latest"
25-
test_app = tempfile.mkdtemp(dir=".")
26-
test_models_dir = tempfile.mkdtemp(dir=test_app)
27-
test_model = tempfile.mkstemp(dir=test_models_dir, suffix=".ts")
28-
with open(test_model[1], "w") as test_model_file:
29-
test_model_file.write("Foo")
30-
test_params_file = tempfile.mkstemp(dir=".")
31-
32-
test_params_values = {}
33-
test_params_values["app-name"] = "test_app"
34-
test_params_values["app-version"] = "0.0.0"
35-
test_params_values["sdk-version"] = "0.0.0"
36-
test_params_values["command"] = "/usr/bin/python3 -u /opt/monai/app/main.py"
37-
test_params_values["pip-packages"] = []
38-
test_params_values["models"] = []
39-
test_params_values["resource"] = {"cpu": 1, "gpu": 2, "memory": "4Gi"}
40-
41-
test_params_string = json.dumps(test_params_values, sort_keys=True, indent=4, separators=(",", ": "))
42-
43-
with open(test_params_file[1], "w") as tmp_params:
44-
tmp_params.write(test_params_string)
45-
46-
parser = argparse.ArgumentParser()
47-
args = parser.parse_args([])
48-
args.application = test_app
49-
args.tag = test_map_tag
50-
args.params = test_params_file[1]
51-
args.base = None
52-
args.working_dir = None
53-
args.input_dir = None
54-
args.output_dir = None
55-
args.models_dir = None
56-
args.timeout = None
57-
args.model = None
58-
args.version = None
59-
args.verbose = False
60-
61-
packager_util.package_application(args)
62-
63-
shutil.rmtree(test_app)
64-
os.remove(test_params_file[1])
20+
test_app_path_rel = "examples/apps/simple_imaging_app/"
21+
test_app_path = os.path.abspath(test_app_path_rel)
22+
args = ["monai-deploy", "package", "-t", test_map_tag, test_app_path]
23+
monai_deploy(args)
24+
25+
# Delete MONAI application package image
26+
docker_rmi_cmd = ["docker", "rmi", "-f", tag]
27+
subprocess.Popen(docker_rmi_cmd)

0 commit comments

Comments
 (0)