Skip to content

Commit

Permalink
switch ia_app_basic to uv (sectra-medical#8)
Browse files Browse the repository at this point in the history
Switch ia_app_basic to uv

bump shapely to avoid windows issue
  • Loading branch information
sectra-masve authored Nov 22, 2024
1 parent cd24e61 commit aa4a1df
Show file tree
Hide file tree
Showing 9 changed files with 372 additions and 457 deletions.
7 changes: 4 additions & 3 deletions examples/python/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,12 +8,13 @@ This document outlines how we suggest you try the examples to get started using

- We assume you have a copy of the document *"Interface Specification: Pathology Image Analysis Application Interface, Sectra Digital Pathology Module"*. At the time of writing, the most recent version was *"Verion 4.1, August 2024"*.
- This document describes all the REST endpoints and corresponding json schemas.
- Contact Sectra support for a copy, see https://my.sectra.com/en-US/support-contact/
- Contact Sectra for a copy, see https://forms.office.com/e/WBEsUrLyJV

- You will need to have access to a Sectra PACS with the Digital Pathology module
- We suggest you start testing in your testing Sectra PACS instance, if such an installatino is available to you.
- You will need the appropriate permissions to add and configure IA Applications in that Sectra PACS, or be in contact with someone who has
- For third party AI vendors, there is an online Sectra PACS available for a fee. Contact Sectra Support and request "discussing access to a test PACS for digital pathology AI vendors".
- For third party AI vendors, there is an online Sectra PACS available for a fee.
- Use https://forms.office.com/e/WBEsUrLyJV to contact Sectra for discussions.

- You will need ensure TCP/IP connectivity between the Sectra PACS server and the machine running your IA-APP.
- Both parties will initiate communications, so both servers need to be accessible to each other under appropiate DNS names.
Expand All @@ -31,7 +32,7 @@ cd examples/python/ia_app_basic
./flask_run.sh
```

See the README linked above for how to configure the Sectra DPAT module to connect.
See the README linked above for how to configure the Sectra DPAT module to connect.

Once you have succesfully got this basic app working inside the Sectra Pathology module, we strongly suggest you proceed with adopting the practices in the second example below.

Expand Down
29 changes: 16 additions & 13 deletions examples/python/ia_app_basic/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,11 @@ For a more realistic implementation where WSI processing is done in longer-runni

- Output: a graphical primitive, or a "patch gallery" (see `webserver.py:DEMO_TYPE` and `webserver.py:app_on_userinput` )

**Screenshot**

![pcad_demo_2024-11-21_15-48-thumbnail](https://github.com/user-attachments/assets/51c2d8d6-a549-411a-bc56-38d866e80d60)


### Development notes
Uses a simple flask server for responding to IA-API requests and a requests-based client for outgoing communications with the IA-API..

Expand All @@ -32,25 +37,18 @@ In order to try this out you'll need to
### Install and run

#### Prerequisites
We use astral `uv` for python dependency management. Please install it first. See https://docs.astral.sh/uv/ for more install options.

You currently need libgeos to build shapely. On ubuntu `sudo apt install libgeos-dev`.
The shapely dependency will eventually be removed.

#### Starting

You can run this example in a virtualenv using poetry, or directly in the current python environment.

Using poetry:
```
poetry install
poetry run python pcaddemo/__main__.py
curl -LsSf https://astral.sh/uv/install.sh | sh
```

As plain-old python:
#### Starting

Start the webserver:

```
pip install -e .
python pcaddemo/__main__.py
./flask_run.sh
```

### Configuring the Sectra DPAT Server
Expand All @@ -71,6 +69,11 @@ You need to configure the Sectra Pathology Server (SPS) to call this server. Thi

If succesful, you should now be able to right-click in any Pathology Image and select your new IA-APP (you might need to refresh any running sessions).

**Screenshot of configuration where app is running on the same machine as the server**

![edit_thumbnail](https://github.com/user-attachments/assets/4e10cb17-c7d9-462a-bc2c-810fc916770e)



## Tested with

Expand Down
2 changes: 1 addition & 1 deletion examples/python/ia_app_basic/flask_run.bat
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
set FLASK_APP=pcaddemo\webserver
set FLASK_RUN_PORT=5005
set FLASK_DEBUG=1
flask run
uv run -- flask run
2 changes: 1 addition & 1 deletion examples/python/ia_app_basic/flask_run.sh
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,4 @@ export FLASK_APP=pcaddemo/webserver
export FLASK_RUN_PORT=5005
export FLASK_RUN_HOST=0.0.0.0
export FLASK_DEBUG=1
flask run
uv run -- flask run
1 change: 1 addition & 0 deletions examples/python/ia_app_basic/pcaddemo/version.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
"""
version info
"""

__version__ = "0.1.0"

# this is the minimum version we require, we do not support
Expand Down
7 changes: 3 additions & 4 deletions examples/python/ia_app_basic/pcaddemo/webserver.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
APP_MANUFACTURER = "Sectra (demo)"
BIND_PORT = 5005


def json_resp(data):
"""serialize data to JSON and add appropriate IA-api headers"""
resp = jsonify(data)
Expand Down Expand Up @@ -89,7 +90,7 @@ def app_on_userinput():
data = request.get_json()

save_filename = f"./debug/userinput_{data['action']}_tmp.json"
with open(save_filename, 'w') as file:
with open(save_filename, "w") as file:
json.dump(data, file)

# data['action'] :: create, modify, delete, cancel
Expand Down Expand Up @@ -138,9 +139,7 @@ def app_create_primitiveArea(data):
"content": {
"style": {"fillStyle": None, "size": None, "strokeStyle": "#FFA500"},
"polygons": input_polygons, # same area as user input,
"labels": [
{"location": min_y_pt, "label": text}
],
"labels": [{"location": min_y_pt, "label": text}],
},
}

Expand Down
Loading

0 comments on commit aa4a1df

Please sign in to comment.