0% found this document useful (0 votes)
11 views2 pages

Python Microservice for Report Generation

The document outlines the requirements for a Python-based microservice that processes large input files to generate reports using configurable transformation rules. It specifies functional requirements such as REST endpoints for file uploads, report generation, and transformation rule configuration, as well as non-functional requirements like authentication and performance benchmarks. Deliverables include source code in a private GitHub repository and comprehensive documentation.
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
11 views2 pages

Python Microservice for Report Generation

The document outlines the requirements for a Python-based microservice that processes large input files to generate reports using configurable transformation rules. It specifies functional requirements such as REST endpoints for file uploads, report generation, and transformation rule configuration, as well as non-functional requirements like authentication and performance benchmarks. Deliverables include source code in a private GitHub repository and comprehensive documentation.
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd

Python Backend Developer Assessment: Report Generator Microservice

Objective

Create a Python-based microservice that ingests large input files and generates output reports by joining with reference data and
applying configurable transformation rules.

Transformation Rules (Must Be Configurable via External File)

1. outfield1 = field1 + field2


2. outfield2 = refdata1
3. outfield3 = refdata2 + refdata3
4. outfield4 = field3 * max(field5, refdata4)
5. outfield5 = max(field5, refdata4)

Functional Requirements

1. Implement using a framework of your choice: FastAPI/Flask/Django


2. Provide REST endpoints to:
3. Upload [Link] and [Link]
4. Trigger report generation on-demand
5. Download generated reports
6. End points to configure transformation rules
7. Ability to define schedules using cron expressions or configuration
8. Read transformation rules from a JSON or YAML config file
9. Easily extend to support new formats like Excel (.xlsx) and JSON

Non Functional Requirements

1. Authentication, Authorization
2. Monitoring and observability
3. Structured logging
4. Unit tests and Test coverage
5. Leverage docker for deployment and dependent services(database)
6. Must be able to generate a report from a 1 GB file in under 30 seconds
7. Handle up to 250 fields in input/output files

Deliverables

1. Source code hosted on GitHub private repository (with clean and meaningful commit history)
2. [Link] with:
3. Setup instructions
4. API documentation (Swagger UI or Redoc if using FastAPI)

Example Input & Output File Details


1. [Link]

1. Up to 1 GB in size
2. Columns:

field1(String), field2(String), field3(String), field4(String), field5(Decimal), refkey1(String), refkey2(String)

2. [Link]

1. Up to 1 GB in size
2. Columns:

refkey1(String), refdata1(String), refkey2(String), refdata2(String), refdata3(String), refdata4(Decimal)

3. [Link]

1. Columns:

outfield1, outfield2, outfield3, outfield4, outfield5

Common questions

Powered by AI

Transformation rules can be configured in the Python microservice via an external file in JSON or YAML format. These rules are defined such that they operate on fields from the input data and reference data. For instance, the rule 'outfield1 = field1 + field2' implies that the output report will include a field where each entry is the concatenation of 'field1' and 'field2' from the input CSV file. Similarly, other rules allow the microservice to join data using reference keys and apply mathematical operations like maximization or multiplication, as seen in 'outfield4 = field3 * max(field5, refdata4)' .

Scheduling the report generation using cron expressions allows the microservice to automate routine data processing tasks, thereby increasing operational efficiency. This feature facilitates time-based job execution, such as nightly batch processing or weekly report generation, reducing manual intervention and optimizing resource use. Automation also minimizes the risk of human error and ensures consistent performance over time .

Handling up to 250 fields in input/output files requires considerations of data structure and processing efficiency. The service must efficiently parse, transform, and aggregate large datasets without degrading performance. This can involve optimizing data storage structures, using parallel processing where applicable, and ensuring algorithmic efficiency in applying transformation rules. Careful memory management and input/output operation minimization are also critical to prevent bottlenecks and sustain performance, especially under the stringent demand of processing 1 GB files in under 30 seconds .

Docker facilitates the deployment of the microservice by containerizing the application, ensuring consistency across various environments. It allows developers to package the microservice along with all necessary dependencies, streamlining the deployment process and isolating the service from system-specific issues. Docker also assists in managing dependent services like databases, supporting scalability and simplifying the update process .

The microservice can be implemented using FastAPI, Flask, or Django. These frameworks facilitate the creation of REST endpoints which are crucial for uploading input and reference CSV files, triggering report generation, downloading reports, and configuring transformation rules. They enable the service to handle HTTP requests efficiently, manage data uploads, and process large datasets under stringent performance requirements, like generating reports from a 1 GB file in under 30 seconds .

Monitoring and observability are critical for maintaining the microservice's health and performance, allowing developers to detect and resolve issues proactively. They can be achieved using logging tools for structured logs, integrating with monitoring platforms like Prometheus or DataDog, and using APM (Application Performance Management) tools to gain insights into request handling and resource utilization. These methods provide visibility into the service workflow and help ensure it meets performance requirements .

Extending support for new data formats like Excel and JSON allows the microservice to handle a wider range of data exchange scenarios, increasing its applicability. Excel support would facilitate easier human readability and influence compatibility with business processes reliant on spreadsheets, while JSON support would enhance interoperability with other web services and APIs. These extensions would broaden user accessibility and usability across diverse use cases .

The README.md should include clear setup instructions to guide users through installation and configuration, comprehensive API documentation (potentially using Swagger UI or Redoc for detailed REST endpoint information if using FastAPI), and usage examples. Additionally, it should outline the pre-requisites, explain the functionality of transformation rules, list potential errors, and provide solutions or contact information for troubleshooting. Such detailed documentation ensures users can effectively deploy and utilize the microservice .

Unit tests are crucial for validating the functionality of individual units within the microservice, ensuring each part performs as expected. Test coverage measures how much of the codebase is exercised by tests, which helps identify untested paths and reduce bugs. Implementing comprehensive test cases allows developers to catch errors early, improve code reliability, and support refactoring by providing a safety net against breaking changes .

Authentication and authorization are essential to ensure that only authorized users can interact with the microservice, thereby protecting sensitive data and functionalities. This can be implemented using OAuth tokens, JWT (JSON Web Tokens), or API keys within the chosen framework (FastAPI, Flask, Django). These mechanisms verify user identities and control access levels, offering a secure environment for data transactions and configuration management .

You might also like