The xFusionCorp Industries ML platform team maintains a Cookiecutter template that new ML projects are generated from. A draft template exists at /root/code/mlops-template/, but it does not render. Correct the template and use it to generate a project.
A Cookiecutter template exists at /root/code/mlops-template/. cookiecutter is installed system-wide.
The corrected template must satisfy every one of the following:
cookiecutter.json declares four variables:
project_name (default my-ml-project)author (default xFusionCorp)python_version (default 3.11)ml_framework with the choices sklearn, pytorch, and tensorflowrequirements.txt logic:
scikit-learn when ml_framework is sklearntorch when ml_framework is pytorchtensorflow when ml_framework is tensorflowREADME.md content:
project_name and the author from cookiecutter variables./ must contain:
README.md and requirements.txtdata/, models/, src/, and tests/Review the existing template in the VS Code explorer and correct everything that prevents it from rendering.
Once the template renders, generate a project at /root/code/churn-model/:
cookiecutter /root/code/mlops-template/ -o /root/code/ --no-input project_name=churn-model ml_framework=sklearn
The generated project must contain a requirements.txt listing scikit-learn and a README.md that mentions xFusionCorp.
This is a pretty interesting tool. We have to go through the official documentation to fix the issues properly. Like we have to understand how we can cheeck string matching conditions, nested if-else block, writing cookiecutter.json files configurations, etc. Let’s see what we had to fix:
Let’s open the cookiecutter.json file in editor. We can notice several issues like missing variables, wrong variable names, etc.
Let’s update with the correct config;
{
"project_name": "my-ml-project",
"author": "xFusionCorp",
"python_version": "3.11",
"ml_framework": ["sklearn", "pytorch", "tensorflow"]
}
Let’s open the requirements.txt file in editor and update according to this template: day 09 cookiecutter_requirements.txt
we have replaced
=with==to ensure string matching Added conditional ending clause.
Updated README.md with proper variable referance name. Updated Author to author to call actual variable.
That’s all. You can run the given command:
cookiecutter /root/code/mlops-template/ -o /root/code/ --no-input project_name=churn-model ml_framework=sklearn
If everything is done correctly, It will create the files properly. Otherwise you will get errors. Read them carefully and fix the further issues. Make sure all the directory exists, requirements.txt is created, and README.md updated before submitting the solution.
cookiecutter.json is the configuration file that declares the variables and their default values. It can also declare choices for variables.