-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Poetry, period specific mappings, and OO refactor (#71)
* New period class * New survey mapping * MBS tests * poetry
- Loading branch information
Showing
177 changed files
with
3,583 additions
and
1,086 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
* @ONSdigital/DFTS |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1 @@ | ||
0.6.5 | ||
1.0.0 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,11 @@ | ||
FROM europe-west2-docker.pkg.dev/ons-sdx-ci/sdx-apps/sdx-gcp:1.4.4 | ||
FROM europe-west2-docker.pkg.dev/ons-sdx-ci/sdx-apps/sdx-gcp:1.4.5 | ||
|
||
COPY . /app | ||
WORKDIR /app | ||
|
||
# Export dependencies to requirements.txt and install them | ||
RUN poetry export -f requirements.txt --output requirements.txt | ||
RUN pip install -r requirements.txt | ||
|
||
EXPOSE 5000 | ||
CMD ["python", "./run.py"] | ||
CMD ["python", "./run.py"] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,43 @@ | ||
# SDX-Transformer | ||
|
||
The sdx-transformer service provides data transformation functionality for SDX. It is used to transform both survey submission data into pck files on the journey downstream, and for transforming the data headed upstream for pre-population. | ||
The sdx-transformer service provides data transformation functionality for SDX. | ||
It is used to transform both survey submission data into pck files on the journey downstream, and for transforming the data headed upstream for pre-population. | ||
|
||
## Getting Started | ||
|
||
### 1. Install Poetry: | ||
- This project uses Poetry for dependency management. Ensure Poetry is installed on your system. | ||
- If you have poetry installed, you can skip this step. | ||
- If Poetry is not installed, you can install it using: | ||
```bash | ||
brew install poetry | ||
``` | ||
or | ||
```bash | ||
brew install pipx | ||
pipx install poetry | ||
``` | ||
- Use the official Poetry installation guide for other installation methods: https://python-poetry.org/docs/#installation | ||
- Verify the installation by using the following command: | ||
```bash | ||
poetry --version | ||
``` | ||
|
||
### 2. Install Dependencies: | ||
- Install the project dependencies using Poetry by running the following command at the project root: | ||
```bash | ||
poetry install | ||
``` | ||
This will create a new virtual environment if one does not already exist and install the dependencies into it. | ||
|
||
### 3. Run the tests: | ||
- To run all the tests, use the following command or use the Makefile: | ||
```bash | ||
poetry run pytest -v --cov-report term-missing --disable-warnings --cov=app tests/ | ||
``` | ||
|
||
### 4. Run the transformer: | ||
- To run the transformer, use the following command: | ||
```bash | ||
poetry run python run.py | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,210 @@ | ||
openapi: 3.0.3 | ||
info: | ||
title: SDX Transformer API | ||
version: 1.0.0 | ||
description: API for processing PCK and Prepop requests | ||
paths: | ||
/pck: | ||
post: | ||
summary: Process PCK request | ||
description: "Convert a survey response into a PCK file" | ||
operationId: processPck | ||
requestBody: | ||
required: true | ||
content: | ||
application/json: | ||
schema: | ||
oneOf: | ||
- $ref: '#/components/schemas/ListCollector' | ||
- $ref: '#/components/schemas/Data' | ||
parameters: | ||
- name: survey_id | ||
description: "The id of the survey" | ||
example: "009" | ||
in: query | ||
required: true | ||
schema: | ||
type: string | ||
- name: period_id | ||
description: "The period of the collection exercise" | ||
example: "202501" | ||
in: query | ||
required: true | ||
schema: | ||
type: string | ||
- name: ru_ref | ||
description: "The reference of the respondent" | ||
example: "12345678901A" | ||
in: query | ||
required: true | ||
schema: | ||
type: string | ||
- name: form_type | ||
description: "The form type" | ||
example: "0001" | ||
in: query | ||
required: true | ||
schema: | ||
type: string | ||
- name: period_start_date | ||
description: "The start date of the period in iso 8601 format (YYY-MM-DD)" | ||
example: "2025-01-01" | ||
in: query | ||
required: true | ||
schema: | ||
type: string | ||
- name: period_end_date | ||
description: "The end date of the period in iso 8601 format (YYY-MM-DD)" | ||
example: "2025-01-31" | ||
in: query | ||
required: true | ||
schema: | ||
type: string | ||
- name: data_version | ||
description: The version of schema of the data. | ||
example: "0.0.3" | ||
in: query | ||
required: false | ||
schema: | ||
type: string | ||
default: "0.0.1" | ||
responses: | ||
'200': | ||
description: Successful response | ||
content: | ||
text/plain: | ||
schema: | ||
oneOf: | ||
- type: string | ||
- $ref: '#/components/schemas/SPP' | ||
'400': | ||
description: Bad request | ||
'500': | ||
description: Internal server error | ||
/prepop: | ||
post: | ||
summary: Process Prepop request | ||
description: "Convert prepopulated data into a supplementary data file" | ||
operationId: processPrepop | ||
requestBody: | ||
required: true | ||
content: | ||
application/json: | ||
schema: | ||
$ref: '#/components/schemas/PrepopData' | ||
parameters: | ||
- name: survey_id | ||
description: "The id of the survey" | ||
example: "071" | ||
in: query | ||
required: true | ||
schema: | ||
type: string | ||
responses: | ||
'200': | ||
description: Successful response | ||
content: | ||
application/json: | ||
schema: | ||
type: object | ||
'400': | ||
description: Bad request | ||
'500': | ||
description: Internal server error | ||
components: | ||
schemas: | ||
Data: | ||
type: object | ||
PrepopData: | ||
type: object | ||
additionalProperties: | ||
type: array | ||
items: | ||
type: object | ||
additionalProperties: | ||
type: string | ||
Answer: | ||
type: object | ||
properties: | ||
answer_id: | ||
type: string | ||
value: | ||
oneOf: | ||
- type: object | ||
- type: array | ||
- type: string | ||
list_item_id: | ||
type: string | ||
nullable: true | ||
SupplementaryDataMapping: | ||
type: object | ||
properties: | ||
identifier: | ||
type: string | ||
list_item_id: | ||
type: string | ||
Group: | ||
type: object | ||
properties: | ||
items: | ||
type: array | ||
items: | ||
type: string | ||
name: | ||
type: string | ||
supplementary_data_mappings: | ||
type: array | ||
items: | ||
$ref: '#/components/schemas/SupplementaryDataMapping' | ||
nullable: true | ||
AnswerCode: | ||
type: object | ||
properties: | ||
answer_id: | ||
type: string | ||
code: | ||
type: string | ||
answer_value: | ||
type: string | ||
nullable: true | ||
ListCollector: | ||
type: object | ||
properties: | ||
answer_codes: | ||
type: array | ||
items: | ||
$ref: '#/components/schemas/AnswerCode' | ||
answers: | ||
type: array | ||
items: | ||
$ref: '#/components/schemas/Answer' | ||
lists: | ||
type: array | ||
items: | ||
$ref: '#/components/schemas/Group' | ||
PCK: | ||
type: string | ||
SPPResponse: | ||
type: object | ||
properties: | ||
questioncode: | ||
type: string | ||
response: | ||
type: string | ||
instance: | ||
type: integer | ||
SPP: | ||
type: object | ||
properties: | ||
formtype: | ||
type: string | ||
reference: | ||
type: string | ||
period: | ||
type: string | ||
survey: | ||
type: string | ||
responses: | ||
type: array | ||
items: | ||
$ref: '#/components/schemas/SPPResponse' |
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.