Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
50 changes: 44 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -23,17 +23,21 @@ The project is built on Python with FastAPI framework. All the regular nuances f
- Connecting this to cloud will need the following in the `.env` file

```bash
UPLOAD_TOPIC=xxxx
UPLOAD_SUBSCRIPTION=xxxx
VALIDATION_TOPIC=xxxx
QUEUECONNECTION=xxxx
STORAGECONNECTION=xxxx
VALIDATION_REQ_TOPIC=xxxx
VALIDATION_REQ_SUB=xxxx
VALIDATION_RES_TOPIC=xxxx
CONTAINER_NAME=xxxx
AUTH_PERMISSION_URL=xxx

```

The application connect with the `STORAGECONNECTION` string provided in `.env` file and validates downloaded zipfile using `python-osw-validation` package.
`QUEUECONNECTION` is used to send out the messages and listen to messages.

### How to Setup and Build

### How to Set up and Build
Follow the steps to install the python packages required for both building and running the application

1. Setup virtual environment
Expand All @@ -56,9 +60,42 @@ Follow the steps to install the python packages required for both building and r
```
3. By default `get` call on `localhost:8000/health` gives a sample response
4. Other routes include a `ping` with get and post. Make `get` or `post` request to `http://localhost:8000/health/ping`
5. Once the server starts, it will start to listening the subscriber(`UPLOAD_SUBSCRIPTION` should be in env file)
5. Once the server starts, it will start to listening the subscriber(`VALIDATION_REQ_SUB` should be in env file)


#### Request Format

```json
{
"messageId": "tdei_record_id",
"messageType": "workflow_identifier",
"data": {
"file_upload_path": "file_upload_path",
"user_id": "user_id",
"tdei_project_group_id": "tdei_project_group_id"
}
}
```

### How to Setup and run the Tests
#### Response Format

```json
{
"messageId": "tdei_record_id",
"messageType": "workflow_identifier",
"data": {
"file_upload_path": "file_upload_path",
"user_id": "user_id",
"tdei_project_group_id": "tdei_project_group_id",
"success": true/false,
"message": "message" // if false the error string else empty string
},
"publishedDate": "published date"
}
```


### How to Set up and run the Tests

Make sure you have set up the project properly before running the tests, see above for `How to Setup and Build`.

Expand Down Expand Up @@ -111,3 +148,4 @@ The format is mentioned in [osw-upload.json](./src/assets/osw-upload.json)
The outgoing messages will be to the `osw-validation` topic.
The format of the message is at [osw-validation.json](./src/assets/osw-validation.json)


2 changes: 1 addition & 1 deletion requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -7,4 +7,4 @@ uvicorn==0.20.0
coverage==7.2.7
html_testRunner==1.2.1
httpx==0.24.1
python-osw-validation==0.0.3
python-osw-validation==0.0.5
77 changes: 5 additions & 72 deletions src/assets/osw-upload.json
Original file line number Diff line number Diff line change
@@ -1,76 +1,9 @@
{
"messageType": "osw-upload",
"publishedDate": "2023-02-08T08:33:36.267213Z",
"messageId": "c8c76e89f30944d2b2abd2491bd95337",
"messageType": "workflow_identifier",
"data": {
"stage": "OSW-Upload",
"request": {
"tdei_project_group_id": "0b41ebc5-350c-42d3-90af-3af4ad3628fb",
"collected_by": "6D3E5B8C-FB16-4B6A-9436-72FD24756CC9",
"collection_date": "2022-11-22T09:43:07.978Z",
"collection_method": "manual",
"publication_date": "2022-11-22T09:43:07.978Z",
"data_source": "local",
"polygon": {
"coordinates": [
[
[
77.5873101438346,
12.975857172137523
],
[
77.58650666918095,
12.97272532145334
],
[
77.5869485802404,
12.970219812510848
],
[
77.58739049129997,
12.967792576658127
],
[
77.5886760507459,
12.967753427498707
],
[
77.58911796180547,
12.969123644412946
],
[
77.59016247885529,
12.972921063276544
],
[
77.58984108899386,
12.973429991296015
],
[
77.5904035212514,
12.974995917131267
],
[
77.58863587701325,
12.975074213164191
],
[
77.5873101438346,
12.975857172137523
]
]
]
},
"osw_schema_version": "1.0.0"
},
"meta": {
"file_upload_path": "https://tdeisamplestorage.blob.core.windows.net/osw/test_upload/valid.zip"
},
"response": {
"success": true,
"message": "File uploaded for the Project Group : 0b41ebc5-350c-42d3-90af-3af4ad3628fb with tdei record id : c8c76e89f30944d2b2abd2491bd95337"
},
"tdei_record_id": "c8c76e89f30944d2b2abd2491bd95337",
"tdei_project_group_id": "0b41ebc5-350c-42d3-90af-3af4ad3628fb",
"user_id": "c59d29b6-a063-4249-943f-d320d15ac9ab"
"file_upload_path": "https://tdeisamplestorage.blob.core.windows.net/osw/test_upload/valid.zip",
"user_id": "c59d29b6-a063-4249-943f-d320d15ac9ab",
"tdei_project_group_id": "0b41ebc5-350c-42d3-90af-3af4ad3628fb"
}
}
85 changes: 9 additions & 76 deletions src/assets/osw-validation.json
Original file line number Diff line number Diff line change
@@ -1,78 +1,11 @@
{
"messageType": "osw-validation",
"publishedDate": "2023-02-08T08:33:36.267213Z",
"data": {
"stage": "OSW-Validation",
"request": {
"tdei_project_group_id": "0b41ebc5-350c-42d3-90af-3af4ad3628fb",
"collected_by": "6D3E5B8C-FB16-4B6A-9436-72FD24756CC9",
"collection_date": "2022-11-22T09:43:07.978Z",
"collection_method": "manual",
"valid_from": "2022-11-22T09:43:07.978Z",
"valid_to": "2022-11-22T09:43:07.978Z",
"data_source": "local",
"polygon": {
"coordinates": [
[
[
77.5873101438346,
12.975857172137523
],
[
77.58650666918095,
12.97272532145334
],
[
77.5869485802404,
12.970219812510848
],
[
77.58739049129997,
12.967792576658127
],
[
77.5886760507459,
12.967753427498707
],
[
77.58911796180547,
12.969123644412946
],
[
77.59016247885529,
12.972921063276544
],
[
77.58984108899386,
12.973429991296015
],
[
77.5904035212514,
12.974995917131267
],
[
77.58863587701325,
12.975074213164191
],
[
77.5873101438346,
12.975857172137523
]
]
]
},
"osw_schema_version": "1.0.0"
},
"meta": {
"file_upload_path": "https://tdeisamplestorage.blob.core.windows.net/osw/2023%2FFEBRUARY%2F0b41ebc5-350c-42d3-90af-3af4ad3628fb%2Fvalid_c8c76e89f30944d2b2abd2491bd95337.zip",
"isValid": true
},
"response": {
"success": true,
"message": "Validation successful"
},
"tdei_record_id": "c8c76e89f30944d2b2abd2491bd95337",
"tdei_project_group_id": "0b41ebc5-350c-42d3-90af-3af4ad3628fb",
"user_id": "c59d29b6-a063-4249-943f-d320d15ac9ab"
}
"messageId": "c8c76e89f30944d2b2abd2491bd95337",
"messageType": "workflow_identifier",
"data": {
"file_upload_path": "https://tdeisamplestorage.blob.core.windows.net/osw/test_upload/valid.zip",
"user_id": "c59d29b6-a063-4249-943f-d320d15ac9ab",
"tdei_project_group_id": "0b41ebc5-350c-42d3-90af-3af4ad3628fb",
"success": true,
"message": ""
}
}
6 changes: 3 additions & 3 deletions src/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,9 @@

class EventBusSettings:
connection_string: str = os.environ.get('QUEUECONNECTION', None)
upload_topic: str = os.environ.get('UPLOAD_TOPIC', None)
upload_subscription: str = os.environ.get('UPLOAD_SUBSCRIPTION', None)
validation_topic: str = os.environ.get('VALIDATION_TOPIC', None)
upload_topic: str = os.environ.get('VALIDATION_REQ_TOPIC', None)
upload_subscription: str = os.environ.get('VALIDATION_REQ_SUB', None)
validation_topic: str = os.environ.get('VALIDATION_RES_TOPIC', None)
container_name: str = os.environ.get('CONTAINER_NAME', 'osw')


Expand Down
Loading