Skip to content

Using Recipe Files and Python Requirements Files

This topic describes how to use recipe files with the ml run xp command and provides details about MissingLink and Python requirements files.

Recipe files

Command lines are handy for short and simple commands. When more complex options are required or when developing as part of a team, you often need to preserve the commands in your source control for later and/or automated use or share the job definition with other team members. This is where “recipe” files come in handy.

Generate a recipe file by running the following commands:

$ ml run xp --command 'echo "Hello $NAME"' --env NAME "World" --image bash --save-recipe .ml_recipe.yaml
$ cat .ml_recipe.yaml
- echo "Hello $NAME"
  - NAME: "World"
image: bash

When the argument --save-recipe is used, the command will not schedule a job. It will only save the recipe file.

Once the recipe exists, it is used as a baseline for other ml run xp commands that reference it:

$ ml run xp
loading defaults from recipe: .ml_recipe.yaml

The recipe file can be saved under any name. The .ml_recipe.yaml file is the default recipe. If you are using some other recipe file, just add -r RECIPE_PATH to the ml run xp command. That makes the command above equivalent to:

$ ml run xp -r .ml_recipe.yaml 

Once a recipe file is referenced (either explicitly with the -r flag or implicitly under the name .ml_recipe.yaml, all the definitions in the recipe override the system defaults. You can still provide parameters as part of the command line and they will take precedence over the recipe file.

This means that once the recipe file in this example exists, the command:

$ ml run xp --env NAME "Earth!"
loading defaults from recipe: .ml_recipe.yaml

is equivalent to:

$ ml run xp --command 'echo "Hello $NAME"' --env NAME "Earth!" --image bash

Python Requirements installation

Many python projects have a requirements.txt file that specifies the requirements needed for the successful execution of the project. If the requirements.txt file is found in the root of your Git repository, MissingLink will detect it and install your requirements automatically. If the file is located elsewhere, use the --requirements-txt PATH flag, so:

$ ml run xp --requirements-txt custom-requirements.txt