Skip to content
Merged
3 changes: 2 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -24,13 +24,14 @@ 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
PROVIDER=Azure
QUEUECONNECTION=xxx
STORAGECONNECTION=xxx
FORMATTER_TOPIC=xxx
FORMATTER_SUBSCRIPTION=xxx
FORMATTER_UPLOAD_TOPIC=xxx
CONTAINER_NAME=xxx
MAX_CONCURRENT_MESSAGES=xx
MAX_CONCURRENT_MESSAGES=xx # Optional if not passed defaults to 2
```

The application connect with the `STORAGECONNECTION` string provided in `.env` file and validates downloaded zipfile using `python-osw-validation` package.
Expand Down
2 changes: 1 addition & 1 deletion requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -3,5 +3,5 @@ pydantic==1.10.4
python-ms-core==0.0.23
uvicorn==0.20.0
html_testRunner==1.2.1
osm-osw-reformatter==0.2.6
osm-osw-reformatter==0.2.8
numpy==1.26.4
23 changes: 19 additions & 4 deletions src/service/osw_formatter_service.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
)
from python_ms_core.core.queue.models.queue_message import QueueMessage
import threading
import osm_osw_reformatter

logging.basicConfig()
logger = logging.getLogger("OSW_FORMATTER")
Expand Down Expand Up @@ -173,11 +174,18 @@ def send_status(self, result: ValidationResult, upload_message: OSWValidationMes
upload_message.data.message = result.validation_message
if upload_url:
upload_message.data.formatted_url = upload_url

resp_data = upload_message.data.to_json()
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this is changing the response message format from this service back. How to ensure the integrity of the message? there is no unit test to check the sanity of the response message

resp_data['package'] = {
'python-ms-core': Core.__version__,
'osm-osw-reformatter': osm_osw_reformatter.__version__

}
data = QueueMessage.data_from(
{
"messageId": upload_message.message_id,
"messageType": upload_message.message_type,
"data": upload_message.data.to_json(),
'messageId': upload_message.message_id,
'messageType': upload_message.message_type,
'data': resp_data
}
)
try:
Expand Down Expand Up @@ -252,10 +260,17 @@ def process_on_demand_format(self, request: OSWOnDemandRequest):

def send_on_demand_response(self, response: OSWOnDemandResponse):
logger.info(f"Sending response for {response.data.jobId}")
resp_data = asdict(response.data)
resp_data['package'] = {
'python-ms-core': Core.__version__,
'osm-osw-reformatter': osm_osw_reformatter.__version__

}

data = QueueMessage.data_from({
"messageId": response.messageId,
"messageType": response.messageType,
'data': asdict(response.data)
'data': resp_data
})
publishing_topic_name = self._settings.event_bus.formatter_topic or ""
publishing_topic = self.core.get_topic(topic_name=publishing_topic_name)
Expand Down
Loading