learning-it by example

#212 Data governance 5.3 min

Data Ownership in Git: CODEOWNERS for Datasets

A five-line file in git says who owns each dataset. A script found a gap and a ghost team.

1. In a CODEOWNERS file, what happens when a file matches more than one pattern?
2. In the Python CODEOWNERS data ownership check on the made-up repository, who owns datasets/customers/customers.sql, and why?
3. What did the Python CODEOWNERS check over the six made-up files report about products and about the refunds owner?
4. In a CODEOWNERS data ownership register, why is an owner who has left worse than having no owner?
5. A code owners entry means a person or team is asked to review changes. When CODEOWNERS is used as a data ownership register, what is that not the same as?

Practice only: nothing is saved and no score counts towards anything. Each answer comes with the reason.

  1. Give products an owner

    Copy the code folder first. Add a new line at the end of the CODEOWNERS file that gives /datasets/products/ to @ana, then run python run.py. When I ran this, the products line showed @ana instead of NO OWNER, and the stale owner line for @shop/old-team was still printed. Why is the stale line still there?

    A hint

    Only one rule changed. Look at which owner the stale line names.

  2. Retire the old team

    In your copy, change @shop/old-team in CODEOWNERS to @shop/finance-data and run python run.py again. Predict first: will the stale owner line still appear? When I ran it, refunds.sql showed @shop/finance-data and no stale line was printed.

    A hint

    The stale check compares every owner in the file with the ACTIVE set in owners.py.

  3. Swap the order of two lines

    In your copy, rewrite CODEOWNERS so the line for /datasets/customers/*.sql comes first and the line for /datasets/customers/ comes second. Predict who owns customers.sql, then run python run.py. When I ran it, customers.sql showed @shop/data-platform. Explain the result using the last matching rule wins.

    A hint

    Both lines match customers.sql. Which one is read last now?

  4. Add a file with no rule

    In owners.py, add the path datasets/payments/payments.sql to the end of the FILES list. Predict what run.py prints for it and what the first line says about the number of files, then run it and compare. The CODEOWNERS file stays as it is.

    A hint

    No rule starts with datasets/payments/, so owners_of returns an empty list.

These tasks are for you to try on your own machine. Nothing is checked or saved.

What this does not show

Made-up repository, teams and file list; the matcher is simplified and differs from GitHub's, the script only prints, and a code owner is asked to review, not held accountable.

Up next in Data governance

More in Data governance

All Data governance videos

Related videos