Install Python 3.12
PATH during installation, so that the Python command can be used
from the terminal or command prompt.Install pip
pip is the package manager for Python. It allows you to install, update, and manage third-party Python packages.pip should already be included. Verify the installation by running:
pip --version
pip is not installed or needs to be updated, follow the official installation
guide: pip Installation Guide.Set up a Virtual Environment (venv)
venv) isolates the dependencies of your project, ensuring that packages installed for
this project don’t interfere with other projects or the global Python installation.python -m venv .venv
.venv directory that contains a separate Python interpreter and its own package directories.source .venv/bin/activate
.venv\Scripts\Activate.ps1
(.venv), indicating that you are inside the virtual
environment.Install Project Dependencies
requirements.txt file.# remember to activate venv first!
pip install -r requirements-dev.txt
Build and test the project
install Docker from the official website (https://www.docker.com/get-started/)
run build.sh (Linux) or build.ps1 (Windows) to build the project
start the Docker Container by running:
docker run --rm -p 8080:8080 renameme:latest
RUN DOCKER! RUN! .... new name: word_prediction
docker run --rm -p 8080:8080 word_prediction:latest
with GPU, add --gpus all or --gpus device=0 flag
docker run --rm --gpus device=0 -p 8080:8080 word_prediction:latest
visit http://localhost:8080/docs You should see the Swagger UI and be able to send a request to the service REST API
Rename all places and variables that use to service name:
src/renameme_service directorybuild.ps1 and build.shpyproject.toml(Optional) Run the project from PyCharm
Run > Edit configurations > Add new configuration (+ symbol) > find and
chose FastApiApplication file to full path to src\main.pyThe project uses pyproject.toml file for storing the project configuration. The pyproject.toml file provides a clean
and standardized way to manage dependencies, configure tools like linters (e.g., Ruff), and streamline the setup for
build and packaging tasks.
Ruff is a tool that checks your Python code for errors, formatting issues, and potential bugs. This process is called linting. By ensuring that your code follows best practices, Ruff helps improve code quality and consistency across the project.
The Ruff configuration is stored in pyproject.toml in [tool.ruff] tables
To check your code for any issues, run:
ruff check src
Ruff can also automatically fix some of these problems (such as formatting). To apply fixes, run:
ruff check src --fix
Ruff is also executed during in the build.sh and build.ps1
The project uses pip-tools (https://github.com/jazzband/pip-tools) to manage both production and development
dependencies effectively.
pip-tools is a set of tools that helps you manage Python dependencies by resolving and locking down specific versions,
ensuring consistency across environments. It automatically resolves and pins all transitive dependencies, preventing
conflicts and avoiding "dependency hell."
Important files:
requirements.in - lists production dependenciesrequirements-dev.in includes development dependencies and references requirements.in to keep dev environments
aligned with productionrequirements.txt and requirements-dev.txt - list all dependencies, including all transitive dependencies with all
pinned versions, ensuring that the exact same dependencies are installed across different environments YOU MUST NOT
MODIFY THEM MANUALLYIf you want to add new library to your project, you must add them to either requirements.in (if the library is
required to deploy the service) or to requirements-dev.in (if the library is required only during development). Then
run following command to generate requirements.txt and requirements-dev.txt:
pip-compile requirements.in
pip-compile requirements-dev.in
This will resolve and pin all dependencies, generating requirements.txt and requirements-dev.txt files
To install dependencies on your computer run:
# remember to activate venv first!
pip install -r requirements-dev.txt
│ .dockerignore - Specifies files and directories to ignore when building the Docker image.
│ .gitignore - Lists files and directories that should be ignored by Git version control.
│ build.ps1 - PowerShell script for building the project
│ build.sh - Bash script for building the project
│ Dockerfile
│ pyproject.toml - Defines project metadata, configuration for tools (such as Ruff), etc
│ readme.md
│ requirements-dev.in - Lists the development dependencies (including production ones via -r requirements.in).
│ requirements-dev.txt - The compiled and pinned versions of all development dependencies.
│ requirements.in - Lists the main dependencies required for the project in production.
│ requirements.txt - The compiled and pinned versions of all production dependencies.
└───src - Contains the source code for the service
This project uses FastAPI as the web framework for building the REST API. FastAPI is designed to simplify the development of APIs while ensuring high performance. Key features relevant to this project include:
The project will use APIRouter to organize and structure the API into multiple, smaller modules.
Each router can handle a specific set of routes (e.g., user-related or product-related endpoints) and is registered with
the main FastAPI application.
For more details check:
main.pyrouters/example.pyLearn more: https://fastapi.tiangolo.com/tutorial/
1 commits
Python
79.3%
Dockerfile
15.5%
PowerShell
3.1%
Shell
2.2%
Install Python 3.12
PATH during installation, so that the Python command can be used
from the terminal or command prompt.Install pip
pip is the package manager for Python. It allows you to install, update, and manage third-party Python packages.pip should already be included. Verify the installation by running:
pip --version
pip is not installed or needs to be updated, follow the official installation
guide: pip Installation Guide.Set up a Virtual Environment (venv)
venv) isolates the dependencies of your project, ensuring that packages installed for
this project don’t interfere with other projects or the global Python installation.python -m venv .venv
.venv directory that contains a separate Python interpreter and its own package directories.source .venv/bin/activate
.venv\Scripts\Activate.ps1
(.venv), indicating that you are inside the virtual
environment.Install Project Dependencies
requirements.txt file.# remember to activate venv first!
pip install -r requirements-dev.txt
Build and test the project
install Docker from the official website (https://www.docker.com/get-started/)
run build.sh (Linux) or build.ps1 (Windows) to build the project
start the Docker Container by running:
docker run --rm -p 8080:8080 renameme:latest
RUN DOCKER! RUN! .... new name: word_prediction
docker run --rm -p 8080:8080 word_prediction:latest
with GPU, add --gpus all or --gpus device=0 flag
docker run --rm --gpus device=0 -p 8080:8080 word_prediction:latest
visit http://localhost:8080/docs You should see the Swagger UI and be able to send a request to the service REST API
Rename all places and variables that use to service name:
src/renameme_service directorybuild.ps1 and build.shpyproject.toml(Optional) Run the project from PyCharm
Run > Edit configurations > Add new configuration (+ symbol) > find and
chose FastApiApplication file to full path to src\main.pyThe project uses pyproject.toml file for storing the project configuration. The pyproject.toml file provides a clean
and standardized way to manage dependencies, configure tools like linters (e.g., Ruff), and streamline the setup for
build and packaging tasks.
Ruff is a tool that checks your Python code for errors, formatting issues, and potential bugs. This process is called linting. By ensuring that your code follows best practices, Ruff helps improve code quality and consistency across the project.
The Ruff configuration is stored in pyproject.toml in [tool.ruff] tables
To check your code for any issues, run:
ruff check src
Ruff can also automatically fix some of these problems (such as formatting). To apply fixes, run:
ruff check src --fix
Ruff is also executed during in the build.sh and build.ps1
The project uses pip-tools (https://github.com/jazzband/pip-tools) to manage both production and development
dependencies effectively.
pip-tools is a set of tools that helps you manage Python dependencies by resolving and locking down specific versions,
ensuring consistency across environments. It automatically resolves and pins all transitive dependencies, preventing
conflicts and avoiding "dependency hell."
Important files:
requirements.in - lists production dependenciesrequirements-dev.in includes development dependencies and references requirements.in to keep dev environments
aligned with productionrequirements.txt and requirements-dev.txt - list all dependencies, including all transitive dependencies with all
pinned versions, ensuring that the exact same dependencies are installed across different environments YOU MUST NOT
MODIFY THEM MANUALLYIf you want to add new library to your project, you must add them to either requirements.in (if the library is
required to deploy the service) or to requirements-dev.in (if the library is required only during development). Then
run following command to generate requirements.txt and requirements-dev.txt:
pip-compile requirements.in
pip-compile requirements-dev.in
This will resolve and pin all dependencies, generating requirements.txt and requirements-dev.txt files
To install dependencies on your computer run:
# remember to activate venv first!
pip install -r requirements-dev.txt
│ .dockerignore - Specifies files and directories to ignore when building the Docker image.
│ .gitignore - Lists files and directories that should be ignored by Git version control.
│ build.ps1 - PowerShell script for building the project
│ build.sh - Bash script for building the project
│ Dockerfile
│ pyproject.toml - Defines project metadata, configuration for tools (such as Ruff), etc
│ readme.md
│ requirements-dev.in - Lists the development dependencies (including production ones via -r requirements.in).
│ requirements-dev.txt - The compiled and pinned versions of all development dependencies.
│ requirements.in - Lists the main dependencies required for the project in production.
│ requirements.txt - The compiled and pinned versions of all production dependencies.
└───src - Contains the source code for the service
This project uses FastAPI as the web framework for building the REST API. FastAPI is designed to simplify the development of APIs while ensuring high performance. Key features relevant to this project include:
The project will use APIRouter to organize and structure the API into multiple, smaller modules.
Each router can handle a specific set of routes (e.g., user-related or product-related endpoints) and is registered with
the main FastAPI application.
For more details check:
main.pyrouters/example.pyLearn more: https://fastapi.tiangolo.com/tutorial/
1 commits
Python
79.3%
Dockerfile
15.5%
PowerShell
3.1%
Shell
2.2%