This project introduces streaming data. The Python language includes generators - we'll use this feature to generate some streaming buzzline messages. As the code runs, it will continuously update log file. We'll use a consumer to modify this log file and alert us when a special message is detected.
First, you'll need to set up your machine. Detailed instructions by operating system are provided.
- Install Git.
- Install Python Version 3.11.
- Install VS Code.
- Configure Git with user.name and user.email.
- Turn on VS Code File / Autosave.
- Install VS Code Extensions (see instructions)
For detailed instructions, see:
The most current version of Python is 3.13. This course will use advanced tools (such as Kafka) that still require Python 3.11. You are encouraged to install both and practice multiple versions. If space is an issue, we only need 3.11 in this course. For more information, See PYTHON-VERSIONS.md.
Once the tools are installed, copy/fork this project into your GitHub account and create your own version of this project to run and experiment with. Name it buzzline-01-yourname where yourname is something unique to you. Follow the instructions in FORK-THIS-REPO.md.
Python needs a place to keep all the free code we download and use in our projects. For this, we create a .venv folder to hold our local project virtual environment. We create this folder (just once), activate it, and install additional packages listed in requirements.txt.
Important: After creating, activating, and installing packages into .venv, we must remember to activate .venv every time we open a new terminal.
Follow the instructions in MANAGE-VENV.md to:
- Create your .venv
- Activate .venv
- Install the required dependencies using requirements.txt.
The instructions are repeated in requirements.txt as this file exists in all our projects.
Now we'll generate some streaming data. By the way - you've done 90% of the hard work before we even look at code. Congratulations!
In VS Code, open a terminal. Use the commands below to activate .venv, and run the generator as a module. To learn more about why we run our Python file as a module, see PYTHON-PKG-IMPORTS
Windows PowerShell:
.venv\Scripts\activate
py -m producers.basic_producer_case
Mac/Linux:
source .venv/bin/activate
python3 -m producers.basic_producer_case
A common streaming task is monitoring a log file as it is being written. This project has a consumer that reads and processes our own log file as log messages arrive.
In VS Code, open a NEW terminal in your root project folder. Use the commands below to activate .venv, and run the file as a module.
Windows:
.venv\Scripts\activate
py -m consumers.basic_consumer_case
Mac/Linux:
source .venv/bin/activate
python3 -m consumers.basic_consumer_case
To save disk space, you can delete the .venv folder when not actively working on this project. We can always recreate it, activate it, and reinstall the necessary packages later. Managing Python virtual environments is a necessary and valuable skill. We will get a good amount of practice.
This project is licensed under the MIT License as an example project. You are encouraged to fork, copy, explore, and modify the code as you like. See the LICENSE file for more.