|
1 | 1 | # TDEI-python-osw-quality-metric |
2 | | -Quality metric calculator for OSW record |
| 2 | +Quality metric calculator for OSW record. |
| 3 | + |
| 4 | +# Introduction: |
| 5 | +This service calculates the specific quality metric of a given OSW dataset. There are two algorithms that it supports: |
| 6 | +- fixed calculation (assumes a random score ) |
| 7 | +- xn calculation. Calculates the intersection quality metric based on either input sub-polygons or vornoi generated polygons. |
| 8 | + |
| 9 | +## Requirements |
| 10 | +python 3.10 |
| 11 | + |
| 12 | +## How to run the project with Python3.10 |
| 13 | +#### Create virtual env |
| 14 | + |
| 15 | +`python3.10 -m venv .venv` |
| 16 | + |
| 17 | +`source .venv/bin/activate` |
| 18 | + |
| 19 | +#### Install requirements |
| 20 | + |
| 21 | +`pip install -r requirements.txt` |
| 22 | + |
| 23 | +#### Set up env file, create a .env file at project root level |
| 24 | + |
| 25 | +```shell |
| 26 | +QUALITY_REQ_TOPIC |
| 27 | +QUALITY_REQ_SUB |
| 28 | +QUALITY_RES_TOPIC |
| 29 | +PROVIDER=Azure |
| 30 | +QUEUECONNECTION=Endpoint=sb://xxxxxxxxxxxxx |
| 31 | +STORAGECONNECTION=DefaultEndpointsProtocol=https;xxxxxxxxxxxxx |
| 32 | +MAX_CONCURRENT_MESSAGES=xxx # Optional if not provided defaults to 1 |
| 33 | +PARTITION_COUNT=xx # Optional number of partitions to use for dask library. defaults to 2 |
| 34 | +``` |
| 35 | +Note: Replace the endpoints with the actual endpoints of the environment you want to run the service in |
| 36 | + |
| 37 | +`MAX_CONCURRENT_MESSAGES` is the maximum number of concurrent messages that the service can handle. If not provided, defaults to 1 |
| 38 | + |
| 39 | +### Run the Server |
| 40 | + |
| 41 | +`uvicorn src.main:app --reload` |
| 42 | + |
| 43 | +remove `--reload` for non-debug mode |
| 44 | + |
| 45 | + |
| 46 | +### Run the Server |
| 47 | + |
| 48 | +`uvicorn src.main:app --reload` |
| 49 | + |
| 50 | +### Run Unit tests |
| 51 | + |
| 52 | +#### Run Coverage |
| 53 | +`python -m coverage run --source=src -m unittest discover -s tests/unit_tests` |
| 54 | + |
| 55 | +To run a single test use |
| 56 | + |
| 57 | +`python -m unittest tests.unit_tests.service.test_osw_confidence_metric_calculator.TestOSWConfidenceMetric.test_calculate_score` |
| 58 | + |
| 59 | +#### Run Coverage Report |
| 60 | +`coverage report` |
| 61 | + |
| 62 | +#### Run Coverage HTML report |
| 63 | +`coverage html` |
3 | 64 |
|
4 | 65 |
|
5 | 66 | # Incoming message |
6 | 67 |
|
7 | 68 | ```json |
8 | 69 | { |
9 | | - "datasetId":"", |
10 | | - "intersection_file":"" |
11 | | -} |
| 70 | + "messageType": "mettric-calculation", |
| 71 | + "messageId": "message-id-from-msg", |
| 72 | + "data": { |
| 73 | + "jobId": "0b41ebc5-350c-42d3-90af-3af4ad3628fb", |
| 74 | + "data_file": "https://tdeisamplestorage.blob.core.windows.net/osw/test/wenatchee.zip", |
| 75 | + "algorithm": "fixed", |
| 76 | + "sub_regions_file":"" |
| 77 | + } |
| 78 | + } |
12 | 79 |
|
13 | 80 | ``` |
14 | 81 |
|
15 | 82 | # Outgoing message |
16 | 83 | ```json |
17 | 84 | { |
18 | | - "datasetId":"", |
19 | | - "metrics_file":"" |
| 85 | + "status":"", |
| 86 | + "message":"", |
| 87 | + "success":true/false, |
| 88 | + "dataset_url":"", |
| 89 | + "qm_dataset_url":"" |
20 | 90 | } |
21 | 91 |
|
22 | 92 | ``` |
| 93 | + |
| 94 | +# Run the metrics locally |
| 95 | +- Use [test.py](./test.py) to run the metrics on any dataset locally. |
0 commit comments