Skip to main content

Quality LAC data beta: Python validator

Build & Test PyPI version Run on Repl.it

We want to build a tool that improves the quality of data on Looked After Children so that Children’s Services Departments have all the information needed to enhance their services.

We believe that a tool that highlights and helps fixing data errors would be valuable for:

  1. Reducing the time analysts, business support and social workers spend cleaning data.
  2. Enabling leadership to better use evidence in supporting Looked After Children.

About this project

The aim of this project is to deliver a tool to relieve some of the pain-points of reporting and quality in children's services data. This project focuses, in particular, on data on looked after children (LAC) and the SSDA903 return.

The project consists of a number of related pieces of work:

The core parts consist of a Python validator engine and rules using Pandas with Poetry for dependency management. The tool is targeted to run either standalone, or in pyodide in the browser for a zero-install deployment with offline capabilities.

It provides methods of finding the validation errors defined by the DfE in 903 data. The validator needs to be provided with a set of input files for the current year and, optionally, the previous year. These files are coerced into a common format and sent to each of the validator rules in turn. The validators report on rows not meeting the rules and a report is provided highlight errors for each row and which fields were included in the checks.

Data pipeline

  • Loading of files
  • Identification of tables - currently matched on exact filename
  • Conversion of CSV to tabular format - no type checking
  • Enrichment of provided data with Postcode distances
  • Evaluation of rules
  • Report

Project Structure

These are the key files

project
├─── pyproject.toml           - Project details and dependencies
├─── validator903
│    ├─── config.py           - High-level configuration
│    ├─── ingress.py          - Data ingress (handling CSV and XML files)
│    ├─── types.py            - Classes used across the work
│    ├─── validator.py        - The core validator process
│    └─── validators.py       - All individual validator codes
└─── tests                    - Unit tests

Most of the work from contributors will be in validators.py and the associated testing files under tests. Please do not submit a pull-request without a comprehensive test.

Development

To run in codespaces, you need to run in a virtual environment, this information can be found in a .txt file in the documentation.

To install the code and dependencies, from the main project directory run:

poetry install

If this does not work, it might be because you're running the wrong version of Python, the version of Numpy used by the 903 validator is locked at 3.9. The devcontainer and dockerfile should ensure you are running 3.9 and you may simply require a rebuild. If not, ensure you are working in an environment or venv with Python 3.9 as your interpreter.

Adding validators

Validators are contained in rule_XXX() files in the rules folder, where xxx is the code of the validation rule. Each file contains a validate which defines the rule logic and a test_validate function which runs the validate function on some test data to check that the rule works as expected. The validator takes a single argument, the datastore, which is a Mapping (a dict-like) following the structure below.

The following is the expected structure for the input data that is given to each validator (the dfs object). You should assume that not all of these keys are present and handle that appropriately.

Any XML uploads are converted into CSV form to give the same inputs.

{
    # This years data
    'Header':   # header dataframe
    'Episodes': # episodes dataframe
    'Reviews':  # reviews dataframe
    'UASC':     # UASC dataframe
    'OC2':      # OC2 dataframe
    'OC3':      # OC3 dataframe
    'AD1':      # AD1 dataframe
    'PlacedAdoption':  # Placed for adoption dataframe
    'PrevPerm': # Previous permanence dataframe
    'Missing':  # Missing dataframe
    'SWEpisodes': # Social Worker Episodes dataframe (new from 2023/24 return) 
    # Last years data
    'Header_last':   # header dataframe
    'Episodes_last': # episodes dataframe
    'Reviews_last':  # reviews dataframe
    'UASC_last':     # UASC dataframe
    'OC2_last':      # OC2 dataframe
    'OC3_last':      # OC3 dataframe
    'AD1_last':      # AD1 dataframe
    'PlacedAdoption_last':  # Placed for adoption dataframe
    'PrevPerm_last': # Previous permanence dataframe
    'Missing_last':  # Missing dataframe
    'SWEpisodes_last': # Social Worker Episodes dataframe (new from 2023/24 return)
    # Metadata
    'metadata': {
        'collection_start': # A datetime with the collection start date (year/4/1)
        'collection_end':   # A datetime with the collection end date (year + 1/4/1)
        'postcodes':        # Postcodes dataframe, columns laua, oseast1m, osnrth1m, pcd
        'localAuthority:    # The local authority code entered (long form, e.g. E07000026)
        'collectionYear':   # The raw collection year string - unlikely to need this (e.g. '2019/20')
    }
}

Yearly rule updates

Each year, the DfE might release specifications of any rules which have been added, modified or deleted. Expanded guidance on how to incorporate these changes can be found in the landing page (readme.md file) of the CIN validator repo. The CIN and LAC validators have been refactored to resemble each other as much as possible so their overall documentation applies to both tool backends.

Publishing backend changes to the frontend live tool

When bugs are fixed or rules modified, it is necessary to update the tool so that users can have access to the improvements that have been made in the backend. Detailed steps on how to do this are spelt out in the README of the children in need data validator. Read about making changes available to users

Releases

To build and release a new version, make sure all your unit tests pass.

We use semantic versioning, so update the project version in pyproject.toml accordingly and commit, creating a PR. Once the release version is on GitHub, create a GitHub release naming the release with the current release name, e.g. 1.0 and the tag with the release name prefixed with a v, i.e. v1.0. Alpha and beta releases can be flagged by appending -alpha.<number> and -beta.<number>.

Metadata

Release files for csc-validator-be-903 0.1.17

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for csc-validator-be-903 0.1.17
File Size Uploaded
csc_validator_be_903-0.1.17.tar.gz 163.6 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for csc-validator-be-903 0.1.17
File Interpreter ABI Platform
csc_validator_be_903-0.1.17-py3-none-any.whl Python 3 none any Details

Total release size: 561.5 kB

Release files / csc_validator_be_903-0.1.17.tar.gz

Download URL csc_validator_be_903-0.1.17.tar.gz
Size 163.6 kB
Tags Source
SHA-256 checksum
How to use checksums
2937dc1ac6c0ceb2cc39cb810388702378dbe1e80bc31ccbec86cf3382678874
BLAKE2b-256 checksum
How to use checksums
417729bc0517e9ca4f72f74d50106e8a1e82533d01fdc21b9c8f4ee98513576a
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.14

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Oct 12, 2026.

Transparency log

Release files / csc_validator_be_903-0.1.17-py3-none-any.whl

Download URL csc_validator_be_903-0.1.17-py3-none-any.whl
Size 397.9 kB
Tags Python 3
SHA-256 checksum
How to use checksums
9f9e27340f5416153dc635592c8265b00a14ec6292dcf502ff52b7b04d3b5f66
BLAKE2b-256 checksum
How to use checksums
7c646facd06040df35949157751f32a71fb6ff418634fcd37664b89c8f35e92a
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.14

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Oct 12, 2026.

Transparency log

Release history Release notifications | RSS feed

This release

0.1.17 This release

2 release files

0.1.15

2 release files

0.1.14

2 release files

0.1.13

2 release files

0.1.11

2 release files

0.1.10

2 release files

0.1.9

2 release files

0.1.8

2 release files

0.1.7

2 release files

0.1.6

2 release files

0.1.5

1 release file

0.1.4

2 release files

0.1.3

2 release files

0.1.1

2 release files

0.1.0

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page