A small Python CLI example you can use to build on. With an emphasis on Linux and creating automation tools that solve a problem for you. THis is the basis for DevOps principles that you can apply in your own environment as well as production environments.
💡 Are you just looking for a 👉 Rust template to get started easily with a Rust project? The template has everything you need!
This repository is part of the Python and Rust CLI tools course:
- 1: Resources
- 2: Python CLI 👈 You are here!
- 3: Rust CLI
- 4: Python Advanced CLI
- 5: Rust Advanced CLI
🚀 Watch the Video course
Use the included practice lab to apply the content you've learned in this week. Follow the steps to create your own repository and apply the requirements to complete the lab.
Python development will require you to have Python installed on your system. For Linux systems, you should prefer the Python that comes available through the package manager. For example, on Ubuntu, you can install Python with the following command:
sudo apt-get update && sudo apt-get install python3
The update part is required if this is a fresh install of the system. Any Python version above 3.6 should work well for this repository, its examples, and most of the work shown in the video course.
The course uses Visual Studio Code exclusively, but you can use any other text editor as well.
These are all the tools and editor extensions recommended for Python development:
Adding modules (Python files) is as easy as adding more files. But you can also add a directory and add an __init__.py
file to it. This will allow you to import the modules from the directory as if they were part of the same file. There are some caveats and things to keep in mind when working with modules, and what strategies you can use to make your code more maintainable and easier to understand for you as well as other developers.
- Use the ceph-volume command-line tool as an example to explore module organizing
- Add imports to
__init__.py
as a shorthand for making modules available, but be aware of side effects - Use relative imports to avoid circular imports and understand absolute
Using dependencies can be tricky, but you can use the well known requirements.txt
file to keep track of the dependencies for your projects which is something that works with the pip
installer tool. Here are some things to be aware of when working with dependencies:
- Create a
requirements.txt
file, optionally read it in for thesetup.py
file - Use separate files for development and testing like
dev-requirements.txt
andtest-requirements.txt
when needed - Use
pip
to install dependencies and usepip freeze
to pin dependencies. Be aware of the caveats and positive aspects of pinning. - Understand how relaxed dependencies can be instead of pinning
Explore additional content that you can use to learn more about the topics covered in this course.
Coursera Courses
- Linux and Bash for Data Engineering
- Open Source Platforms for MLOps
- Python Essentials for MLOps
- Web Applications and Command-Line tools for Data Engineering
- Python and Pandas for Data Engineering
- Scripting with Python and SQL for Data Engineering
O'Reilly Courses and Books
- Python for DevOps (Book)
- Practical MLOps (Book)
- Linux For Beginners (Video)
- GitHub Codespaces Course (Video)
- Python Command-line Tools course (Video)