diff --git a/applications/CMakeLists.txt b/applications/CMakeLists.txt index 0fed9fbd..a8d79d6a 100644 --- a/applications/CMakeLists.txt +++ b/applications/CMakeLists.txt @@ -115,4 +115,4 @@ add_holohub_application(webrtc_video_server) add_subdirectory(orsi) add_subdirectory(nvidia_nim) -add_subdirectory(ehr_query_llm/domain_specific/fhir) +add_subdirectory(ehr_query_llm) diff --git a/applications/ehr_query_llm/CMakeLists.txt b/applications/ehr_query_llm/CMakeLists.txt new file mode 100644 index 00000000..9803db61 --- /dev/null +++ b/applications/ehr_query_llm/CMakeLists.txt @@ -0,0 +1,20 @@ +# SPDX-FileCopyrightText: Copyright (c) 2024 NVIDIA CORPORATION & AFFILIATES. All rights reserved. +# SPDX-License-Identifier: Apache-2.0 +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +cmake_minimum_required(VERSION 3.20) +project(ehr_query_llm LANGUAGES NONE) + +add_holohub_application(fhir) +add_holohub_application(llm) diff --git a/applications/ehr_query_llm/domain_specific/fhir/CMakeLists.txt b/applications/ehr_query_llm/fhir/CMakeLists.txt similarity index 91% rename from applications/ehr_query_llm/domain_specific/fhir/CMakeLists.txt rename to applications/ehr_query_llm/fhir/CMakeLists.txt index 5458bf09..1747da33 100644 --- a/applications/ehr_query_llm/domain_specific/fhir/CMakeLists.txt +++ b/applications/ehr_query_llm/fhir/CMakeLists.txt @@ -14,7 +14,7 @@ # limitations under the License. cmake_minimum_required(VERSION 3.20) -project(ehr_query_llm/domain_specific/fhir NONE) +project(fhir LANGUAGES NONE) # Install application and dependencies into the install/ directory for packaging install( @@ -27,10 +27,10 @@ install( requirements.txt run_cmd_template.sh test_fhir_client.py - DESTINATION fhir + DESTINATION bin/fhir/python COMPONENT "holohub-apps" ) install( DIRECTORY ${CMAKE_HOME_DIRECTORY}/operators/ehr_query_llm - DESTINATION fhir/operators) + DESTINATION bin/fhir/python/operators) diff --git a/applications/ehr_query_llm/domain_specific/fhir/Dockerfile b/applications/ehr_query_llm/fhir/Dockerfile similarity index 95% rename from applications/ehr_query_llm/domain_specific/fhir/Dockerfile rename to applications/ehr_query_llm/fhir/Dockerfile index 981ea006..c2ec7207 100644 --- a/applications/ehr_query_llm/domain_specific/fhir/Dockerfile +++ b/applications/ehr_query_llm/fhir/Dockerfile @@ -64,5 +64,5 @@ RUN apt update \ RUN if ! grep -q "VERSION_ID=\"22.04\"" /etc/os-release; then \ pip install setuptools; \ fi -COPY applications/ehr_query_llm/domain_specific/fhir/requirements.txt /tmp/requirements.txt +COPY applications/ehr_query_llm/fhir/requirements.txt /tmp/requirements.txt RUN pip install -r /tmp/requirements.txt diff --git a/applications/ehr_query_llm/domain_specific/fhir/README.md b/applications/ehr_query_llm/fhir/README.md similarity index 91% rename from applications/ehr_query_llm/domain_specific/fhir/README.md rename to applications/ehr_query_llm/fhir/README.md index 746e5a6c..7b69651c 100644 --- a/applications/ehr_query_llm/domain_specific/fhir/README.md +++ b/applications/ehr_query_llm/fhir/README.md @@ -66,7 +66,7 @@ Error processing line 1 of /usr/local/lib/python3.10/dist-packages/holoscan-2.4. This is a step wise way to run the application in a dev container. ```bash -$ ./dev_container build --docker_file applications/ehr_query_llm/domain_specific/fhir/Dockerfile --img holoscan:fhir --verbose --no-cache +./dev_container build --docker_file applications/ehr_query_llm/fhir/Dockerfile --img holoscan:fhir --verbose --no-cache ``` Optionally check the newly built image @@ -78,7 +78,7 @@ holoscan fhir 508140b8d446 3 minutes ago 14.1GB Launch the container ```bash -$ ./dev_container launch --img holoscan:fhir --as_root +./dev_container launch --img holoscan:fhir --as_root ``` Now in the container, build and run the application @@ -102,9 +102,9 @@ For a Python application, building and launching the dev container can be comple First create and activate a Python virtual environment, followed with installing the dependencies ```bash -python3 -m venv testenv -source testenv/bin/activate -pip install -r applications/ehr_query_llm/domain_specific/fhir/requirements.txt +python3 -m venv .testenv +source .testenv/bin/activate +pip install -r applications/ehr_query_llm/fhir/requirements.txt ``` Build and install the application with `dev_container` @@ -114,23 +114,23 @@ Build and install the application with `dev_container` Now, run the application which is _installed_ in the `install` folder, with server URLs and credential of your own ```bash -python install/fhir --fhir_url --auth_url --uid --secret +python install/bin/fhir/python/ --fhir_url --auth_url --uid --secret ``` ### Test the Running Application -Once the FHIR application has been started with one of the ways, a test application can be used to request and receive FHIR resources, namely `applications/ehr_query_llm/domain_specific/fhir/test_fhir_client.py`. +Once the FHIR application has been started with one of the ways, a test application can be used to request and receive FHIR resources, namely `applications/ehr_query_llm/fhir/test_fhir_client.py`. The test application contains hard coded patient name, patient FHIR resource ID, etc., corresponding to a specific test dataset, though can be easily modified for another dataset. It is strongly recommended to run this test application in a Python virtual environment, which can be the same as in running the FHIR application. The following describes running it in its own environment. ```bash -python3 -m venv testenv -source testenv/bin/activate +echo "Assuming venv already created with `python3 -m venv .testenv`" +source .testenv/bin/activate pip install -r applications/ehr_query_llm/domain_specific/fhir/requirements.txt export PYTHONPATH=${PWD} -python applications/ehr_query_llm/domain_specific/fhir/test_fhir_client.py +python applications/ehr_query_llm/fhir/test_fhir_client.py ``` From the menu, pick one of the choices for the resources of interest. @@ -141,7 +141,7 @@ With Holoscan CLI, an applications built with Holoscan SDK can be packaged into This example application provides all the necessary contents for HAP packaging. It is required to perform the packaging in a Python virtual environment, with the application's dependencies installed, before running the following script to reveal specific packaging commands. ```bash -applications/ehr_query_llm/domain_specific/fhir/packageHAP.sh +applications/ehr_query_llm/fhir/packageHAP.sh ``` Once the HAP is created, it can then be saved and restored on the target deployment host, and run with `docker run` command, shown below with to be substituted user specific parameters. diff --git a/applications/ehr_query_llm/domain_specific/fhir/__main__.py b/applications/ehr_query_llm/fhir/__main__.py similarity index 100% rename from applications/ehr_query_llm/domain_specific/fhir/__main__.py rename to applications/ehr_query_llm/fhir/__main__.py diff --git a/applications/ehr_query_llm/domain_specific/fhir/app.yaml b/applications/ehr_query_llm/fhir/app.yaml similarity index 100% rename from applications/ehr_query_llm/domain_specific/fhir/app.yaml rename to applications/ehr_query_llm/fhir/app.yaml diff --git a/applications/ehr_query_llm/domain_specific/fhir/fhir_client.py b/applications/ehr_query_llm/fhir/fhir_client.py similarity index 100% rename from applications/ehr_query_llm/domain_specific/fhir/fhir_client.py rename to applications/ehr_query_llm/fhir/fhir_client.py diff --git a/applications/ehr_query_llm/domain_specific/fhir/metadata.json b/applications/ehr_query_llm/fhir/metadata.json similarity index 100% rename from applications/ehr_query_llm/domain_specific/fhir/metadata.json rename to applications/ehr_query_llm/fhir/metadata.json diff --git a/applications/ehr_query_llm/domain_specific/fhir/packageHAP.sh b/applications/ehr_query_llm/fhir/packageHAP.sh similarity index 98% rename from applications/ehr_query_llm/domain_specific/fhir/packageHAP.sh rename to applications/ehr_query_llm/fhir/packageHAP.sh index d9ac22e7..fc831c1e 100755 --- a/applications/ehr_query_llm/domain_specific/fhir/packageHAP.sh +++ b/applications/ehr_query_llm/fhir/packageHAP.sh @@ -16,7 +16,7 @@ set -e GIT_ROOT=$(readlink -f ./$(git rev-parse --show-cdup)) -APP_PATH="$GIT_ROOT/install/fhir" +APP_PATH="$GIT_ROOT/install/bin/fhir/python" APP_CONFIG="app.yaml" APP_NAME="fhir" IMAGE_TAG="holohub-fhir" diff --git a/applications/ehr_query_llm/domain_specific/fhir/requirements.txt b/applications/ehr_query_llm/fhir/requirements.txt similarity index 100% rename from applications/ehr_query_llm/domain_specific/fhir/requirements.txt rename to applications/ehr_query_llm/fhir/requirements.txt diff --git a/applications/ehr_query_llm/domain_specific/fhir/run_cmd_template.sh b/applications/ehr_query_llm/fhir/run_cmd_template.sh similarity index 100% rename from applications/ehr_query_llm/domain_specific/fhir/run_cmd_template.sh rename to applications/ehr_query_llm/fhir/run_cmd_template.sh diff --git a/applications/ehr_query_llm/domain_specific/fhir/test_fhir_client.py b/applications/ehr_query_llm/fhir/test_fhir_client.py similarity index 100% rename from applications/ehr_query_llm/domain_specific/fhir/test_fhir_client.py rename to applications/ehr_query_llm/fhir/test_fhir_client.py diff --git a/applications/ehr_query_llm/metadata.json b/applications/ehr_query_llm/metadata.json deleted file mode 100644 index 667ea503..00000000 --- a/applications/ehr_query_llm/metadata.json +++ /dev/null @@ -1,58 +0,0 @@ -{ - "application": { - "name": "EHR Query with LLM", - "authors": [ - { - "name": "Holoscan Team", - "affiliation": "NVIDIA" - } - ], - "language": "Python", - "version": "1.0.0", - "changelog": { - "1.0": "Initial Release" - }, - "holoscan_sdk": { - "minimum_required_version": "1.0.0", - "tested_versions": [ - "1.0.0" - ] - }, - "platforms": [ - "amd64", - "arm64" - ], - "tags": [ - "HoloHub", - "EHR Query", - "LLM", - "RAG", - "Generative AI" - ], - "ranking": 1, - "dependencies": { - "python-packages": { - "holoscan": { - "version": "2.3.0", - "license-url": "https://github.com/nvidia-holoscan/holoscan-sdk/blob/main/LICENSE.txt" - }, - "fhir.resources": { - "version": "7.0.0", - "license-url": "https://github.com/nazrulworld/fhir.resources/blob/main/LICENSE" - }, - "pyzmq": { - "version": "25.1.0", - "license-url": "https://github.com/zeromq/pyzmq/blob/main/LICENSE.md" - }, - "requests": { - "version": "2.31.0", - "license-url": "https://github.com/psf/requests/blob/main/LICENSE" - } - } - }, - "run": { - "command": "", - "workdir": "holohub_bin" - } - } -} \ No newline at end of file diff --git a/operators/CMakeLists.txt b/operators/CMakeLists.txt index cced4d74..e9ae6670 100644 --- a/operators/CMakeLists.txt +++ b/operators/CMakeLists.txt @@ -48,6 +48,7 @@ add_holohub_operator(xr_basic_render) add_holohub_operator(XrFrameOp) add_holohub_operator(XrTransformOp) add_holohub_operator(yuan_qcap DEPENDS EXTENSIONS yuan_qcap) +add_holohub_operator(ehr_query_llm) # install diff --git a/operators/ehr_query_llm/CMakeLists.txt b/operators/ehr_query_llm/CMakeLists.txt new file mode 100644 index 00000000..c9f6fc27 --- /dev/null +++ b/operators/ehr_query_llm/CMakeLists.txt @@ -0,0 +1,18 @@ +# SPDX-FileCopyrightText: Copyright (c) 2023 NVIDIA CORPORATION & AFFILIATES. All rights reserved. +# SPDX-License-Identifier: Apache-2.0 +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +cmake_minimum_required(VERSION 3.20) +project(ehr_query_lmm) + +# No much to do for Python modules and all of them are to be used.