Skip to content

Commit 0a21cde

Browse files
committed
Accept only folder input path on App Runner
Signed-off-by: Gigon Bae <gbae@nvidia.com>
1 parent 3ace120 commit 0a21cde

File tree

9 files changed

+138
-101
lines changed

9 files changed

+138
-101
lines changed

README.md

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -44,8 +44,12 @@ python examples/apps/simple_imaging_app/app.py -i examples/apps/simple_imaging_a
4444
# Package app (creating MAP Docker image), using `-l DEBUG` option to see progress.
4545
monai-deploy package examples/apps/simple_imaging_app -t simple_app:latest -l DEBUG
4646

47-
# Run the app with docker image and input file locally
48-
monai-deploy run simple_app:latest examples/apps/simple_imaging_app/brain_mr_input.jpg output
47+
# Run the app with docker image and an input file locally
48+
## Copy a test input file to 'input' folder
49+
mkdir -p input && rm -rf input/*
50+
cp examples/apps/simple_imaging_app/brain_mr_input.jpg input/
51+
## Launch the app
52+
monai-deploy run simple_app:latest input output
4953
```
5054

5155
[MedNIST demo](TBD) is available on Colab.

docs/source/developing_with_sdk/executing_packaged_app_locally.md

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ usage: monai-deploy run [-h] [-l <LEVEL>G,INFO,WARN,ERROR,CRITICAL}] [-q] <map-i
1717

1818
positional arguments:
1919
<map-image[:tag]> MAP image name
20-
<input> Input data path
20+
<input> Input data directory path
2121
<output> Output data directory path
2222

2323
optional arguments:
@@ -40,14 +40,14 @@ monai-deploy run <container-image-name>[:tag] <input> <output> [-q|--quiet]
4040
| Name | Format | Description |
4141
| -------- | -------------------------------- | ------------------------------------------------------------- |
4242
| MAP | `container-image-name[:tag]` | MAP container image name with or without image tag. |
43-
| input | file or directory path | Local file or folder that contains input dataset for the MAP. |
44-
| output | path | Local path to store output from the executing MAP. |
43+
| input | directory path | Local folder path that contains input dataset for the MAP. |
44+
| output | directory path | Local folder path to store output from the executing MAP. |
4545

4646
#### Optional arguments
4747

4848
| Name | Shorthand | Default | Description |
4949
| ------------------- | ---------- | ---------- | -------------------------------------------------------------- |
50-
| quiet | -q | False | Suppress the STDOUT and print only STDERR from the application |
50+
| quiet | -q | False | Suppress the STDOUT and print only STDERR from the application. |
5151

5252
## Example
5353

examples/apps/mednist_classifier_monaideploy/mednist_classifier_monaideploy.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,8 @@ def compute(self, input: InputContext, output: OutputContext, context: Execution
3939
from PIL import Image as PILImage
4040

4141
input_path = input.get().path
42+
if input_path.is_dir():
43+
input_path = next(input_path.glob("*.*")) # take the first file
4244

4345
image = PILImage.open(input_path)
4446
image = image.convert("L") # convert to greyscale image

examples/apps/simple_imaging_app/sobel_operator.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,8 @@ def compute(self, input: InputContext, output: OutputContext, context: Execution
3737
from skimage import filters, io
3838

3939
input_path = input.get().path
40+
if input_path.is_dir():
41+
input_path = next(input_path.glob("*.*")) # take the first file
4042

4143
data_in = io.imread(input_path)[:, :, :3] # discard alpha channel if exists
4244
data_out = filters.sobel(data_in)

monai/deploy/runner/README.md

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,23 +1,25 @@
1-
# MONAI APPLICATION RUNNER
1+
# MONAI Application Runner
22

3-
The MONAI Application Runner (MAR) allows users to run and test their MONAI Application Package (MAP) locally. MAR allows the users to specify input and output path on local file system which it maps to the input and output of MAP during execution.
3+
The MONAI Application Runner (MAR) is a command-line utility that allows users to run and test their MONAI Application Package (MAP) locally. MAR is developed to make the running and testing of MAPs locally an easy process for developers and scientists by abstracting away the need to understand the internal details of the MAP. MAR allows the users to specify input and output paths on the local file system which it maps to the input and output of MAP during execution.
44

55
## Syntax
6-
```
6+
7+
```bash
78
monai-deploy run <container-image-name>[:tag] <input> <output> [-q|--quiet]
89
```
10+
911
### Arguments
1012

11-
#### Positional arguments:
13+
#### Positional arguments
1214

1315
| Name | Format | Description |
1416
| -------- | -------------------------------- | ------------------------------------------------------------- |
1517
| MAP | `container-image-name[:tag]` | MAP container image name with or without image tag. |
16-
| input | file or directory path | Local file or folder that contains input dataset for the MAP. |
17-
| output | path | Local path to store output from the executing MAP. |
18+
| input | directory path | Local folder path that contains input dataset for the MAP. |
19+
| output | directory path | Local folder path to store output from the executing MAP. |
1820

19-
#### Optional arguments:
21+
#### Optional arguments
2022

2123
| Name | Shorthand | Default | Description |
2224
| ------------------- | ---------- | ---------- | -------------------------------------------------------------- |
23-
| quiet | -q | False | Supress the STDOUT and print only STDERR from the application |
25+
| quiet | -q | False | Suppress the STDOUT and print only STDERR from the application. |

monai/deploy/runner/run_command.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ def create_run_parser(subparser: _SubParsersAction, command: str, parents: List[
2424

2525
parser.add_argument("map", metavar="<map-image[:tag]>", help="MAP image name")
2626

27-
parser.add_argument("input", metavar="<input>", type=argparse_types.valid_existing_path, help="Input data path")
27+
parser.add_argument("input", metavar="<input>", type=argparse_types.valid_existing_path, help="Input data directory path")
2828

2929
parser.add_argument(
3030
"output", metavar="<output>", type=argparse_types.valid_dir_path, help="Output data directory path"

0 commit comments

Comments
 (0)