Introduction to YAML

CI/CD for Machine Learning

Ravi Bhadauria

Machine Learning Engineer

What is YAML?

  • YAML: YAML Ain't Markup Language
  • Used in configuration files, data exchange, and structured data representation
  • A data formatting language similar to JSON and XML
  • Allows a standard format to transfer data between languages or applications
  • Simple and clean format
  • Valid file extensions: .yaml or .yml
  • Used to write configuration for variety of CI/CD tools:
    • GitHub Actions
    • Data Version Control (DVC)
CI/CD for Machine Learning

YAML Syntax

  • YAML has a hierarchical structure
    • Indentation is meaningful
  • Tabs are not allowed
  • YAML validators (https://www.yamllint.com/)
  • Comments start with #
name: Ravi
occupation: Instructor
# This is a valid comment
programming_languages: # and this one too
  python: Advanced
  go: Intermediate
  scala: Beginner
CI/CD for Machine Learning

YAML Scalars

  • Numbers: Integers or floating-point numbers
  • Booleans: true or false
  • Null: keyword null or ~
  • Strings: Represented as plain text or enclosed in '' or ""
# Integer
42
# Floating point
3.14
# Boolean
true
# Null values
null
# String value
a: "A string in YAML"
b: 'A string in YAML'
c: A string in YAML
CI/CD for Machine Learning

YAML Collections

Sequences

  • Also called lists, arrays, or vectors
  • Written in two styles:

    • Block style

      - first
      - second
      - third
      
    • Flow style

      [first, second, third]
      

Mappings

  • Also called dictionary, key-value pairs, hashes, or objects
  • Unique keys, any valid data as values
  • Keys and values are separated by :
key1: value1
blocklist:
  - first
  - second
flowlist: [1.2, 2, "fifty", true]
CI/CD for Machine Learning

Summary

  • YAML is a data formatting language
  • Useful in writing CI/CD configurations
  • Indentation is very important
    • Tabs are not allowed
  • Mappings, sequences, and scalars are building blocks of YAML

A hierarchical graph of YAML data structure.

CI/CD for Machine Learning

Editor Exercises Layout

Annotated picture of editor exercise layout displaying folder, file, and terminal area.

CI/CD for Machine Learning

Let's practice!

CI/CD for Machine Learning

Preparing Video For Download...