Empowering ML with Async Magic!
_Built with:_
- Overview
- Features
- Project Structure 3.1. Project Index
- Getting Started 4.1. Prerequisites 4.2. Installation 4.3. Usage 4.4. Tests
- Roadmap
- Contributing
- License
- Acknowledgments
async-ml-inference orchestrates distributed tasks for audio processing and Euro results retrieval. It streamlines asynchronous processing, enhancing efficiency and scalability. Ideal for developers seeking seamless task management in machine learning applications.
Feature | Summary | |
---|---|---|
⚙️ | Architecture |
|
🔩 | Code Quality |
|
📄 | Documentation |
|
🔌 | Integrations |
|
🧩 | Modularity |
|
🧪 | Testing |
|
⚡️ | Performance |
|
🛡️ | Security |
|
└── async-ml-inference/
├── Pipfile
├── Pipfile.lock
├── README.md
├── docker-compose.yaml
├── docs
│ └── diagram
├── src
│ ├── api
│ ├── client
│ └── workers
└── tests
└── README.md
Async-ml-inference Index
__root__
docker-compose.yaml - Orchestrates Docker services for a Celery-based distributed system
- Manages RabbitMQ and Redis containers for task queuing and backend storage
- Spins up Celery workers for audio and euro tasks, along with an API service and a client for interaction
- Establishes network connections for seamless communication between components.Pipfile Define project dependencies and scripts for development and deployment using the Pipfile.
src
api
requirements.txt - Facilitates dependency management for the project's API by specifying required packages and versions in the 'requirements.txt' file located at 'src/api/'
- This file ensures that the necessary libraries like Celery, FastAPI, uvicorn, and pydantic are installed to support the API functionality within the project architecture.Dockerfile - Facilitates containerized deployment of the API service by defining necessary dependencies and configurations
- Sets up a Python environment, installs required packages, exposes specified ports, and launches the API service using Uvicorn
- Streamlines the deployment process within the project architecture.api.py - Defines FastAPI endpoints for creating and retrieving audio and Euro task results using Celery for asynchronous processing
- Handles task creation, status retrieval, and result sending
- Utilizes Redis and RabbitMQ for backend and broker connections
- Implements background tasks for result notifications.workers
backend.py - Defines functions to retrieve Redis connection details and check if the backend is running
- The code constructs a Redis URL based on environment variables and attempts a connection to the Redis instance
- If successful, it confirms the backend is operational; otherwise, it logs an error.requirements.txt - Manages project dependencies for the workers module, ensuring the required libraries are available for seamless execution
- This file specifies the versions of libraries like BeautifulSoup, Celery, librosa, and numba needed by the workers to perform tasks efficiently within the project architecture.Dockerfile Builds a Docker image for worker processes, installing dependencies and exposing necessary ports. broker.py - Defines functions to retrieve RabbitMQ connection details and check if the broker is running
- The code constructs a broker URL using environment variables and attempts to connect to RabbitMQ with retries
- If successful, it confirms the broker is running; otherwise, it logs an error.audio
worker.py - Implements a Celery worker for extracting audio length
- Validates backend and broker connections before processing audio URL
- Downloads audio data, calculates duration using librosa, and simulates task processing time
- Handles exceptions and returns the audio length upon completion.config.py Configure Celery settings for the Audio Length worker to optimize task processing efficiency and ensure reliable task handling within the project architecture. euro
worker.py - The code file in src/workers/euro/worker.py serves as a Celery worker for fetching Euromillions results
- It ensures the backend and broker services are running before scraping the results from a specified URL
- The worker extracts numbers and stars from the webpage based on the draw date provided, returning them as a tuple.config.py - Configure Celery settings for the Euromillions Results worker, including task acknowledgment, prefetch multiplier, task queues, and result expiration time
- This module centralizes the configurations necessary for efficient task processing within the project's architecture.client
requirements.txt Manage external dependencies for the client-side application using the specified versions of requests, retrying, and joblib. Dockerfile Builds a lightweight Python container for the client module, installing dependencies and exposing port 5000. client.py - Generates audio and date tasks, sends them to the API, retrieves results, and displays successful outputs
- Utilizes parallel processing for efficiency
- Key functionalities include posting audio URLs and dates, checking task statuses, and handling retries
- The script orchestrates the entire process seamlessly, enhancing performance through parallel execution.
Before getting started with async-ml-inference, ensure your runtime environment meets the following requirements:
- Programming Language: Python
- Package Manager: Pipenv, Pip
- Container Runtime: Docker
Install async-ml-inference using one of the following methods:
Build from source:
- Clone the async-ml-inference repository:
❯ git clone https://github.com/FerrariDG/async-ml-inference
- Navigate to the project directory:
❯ cd async-ml-inference
- Install the project dependencies:
❯ pipenv install
❯ pip install -r src/api/requirements.txt, src/workers/requirements.txt, src/client/requirements.txt
❯ docker build -t FerrariDG/async-ml-inference .
Run async-ml-inference using the following command:
❯ pipenv shell
❯ pipenv run python {entrypoint}
❯ python {entrypoint}
❯ docker run -it {image_name}
Run the test suite using the following command:
❯ pipenv shell
❯ pipenv run pytest
❯ pytest
-
Task 1
:Implement feature one. -
Task 2
: Implement feature two. -
Task 3
: Implement feature three.
Contributions are welcome! Here are several ways you can contribute:
- Report Issues: Submit bugs found or log feature requests for the
async-ml-inference
project. - Submit Pull Requests: Review open PRs, and submit your own PRs.
- Join the Discussions: Share your insights, provide feedback, or ask questions.
Contributing Guidelines
- Fork the Repository: Start by forking the project repository to your github account.
- Clone Locally: Clone the forked repository to your local machine using a git client.
git clone https://github.com/FerrariDG/async-ml-inference
- Create a New Branch: Always work on a new branch, giving it a descriptive name.
git checkout -b new-feature-x
- Make Your Changes: Develop and test your changes locally.
- Commit Your Changes: Commit with a clear message describing your updates.
git commit -m 'Implemented new feature x.'
- Push to github: Push the changes to your forked repository.
git push origin new-feature-x
- Submit a Pull Request: Create a PR against the original project repository. Clearly describe the changes and their motivations.
- Review: Once your PR is reviewed and approved, it will be merged into the main branch. Congratulations on your contribution!
This project is protected under the SELECT-A-LICENSE License. For more details, refer to the LICENSE file.
- List any resources, contributors, inspiration, etc. here.