Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
42 changes: 42 additions & 0 deletions data-science/data_contracts/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
# Data Contracts

This directory contains data contracts for the data science components of the Lucky Parking project.

## What are Data Contracts?

Data contracts are formal agreements between data producers and consumers that define the structure, quality, and semantics of data. They ensure data reliability and consistency across different components of the system.

## Structure

Each data contract specifies:
- Schema definition (fields, types, constraints)
- Data quality expectations (nullability, uniqueness, ranges)
- Semantic meaning of data elements
- Versioning information

## Usage

Data contracts are used by:
- Data validation pipelines
- ETL processes
- API interfaces between services
- Machine learning model training and inference

## Files

- `schema.json`: JSON Schema definitions for data entities
- `contracts.yaml`: YAML files describing specific data contracts
- `examples/`: Sample data instances that conform to the contracts

## Contributing

When adding or modifying data contracts:
1. Ensure backward compatibility where possible
2. Update version numbers appropriately
3. Provide clear documentation of changes
4. Add examples demonstrating correct usage
5. Update any dependent consumers of the contract

## Maintenance

Data contracts should be reviewed periodically to ensure they remain accurate reflections of the data being produced and consumed.
108 changes: 108 additions & 0 deletions data-science/data_contracts/data_contract.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,108 @@
#Created using the editor at https://editor.datacontract.com
apiVersion: "v3.1.0"
kind: "DataContract"
id: "example-id"
version: "0.0.1"
status: "draft"
name: "Lucky Parking Data Contract"
schema:
- name: "single_data"
businessName: "Schema 1"
physicalType: "table"
properties:
- name: "region_type"
logicalType: "string"
required: true
primaryKey: false
quality:
- type: "library"
metric: "invalidValues"
description: "Region Type should be one of the valid region types"
mustBe: 0
arguments:
validValues:
- "Neighborhood Council"
- "Zip Code"
- "Place (Radius)"
dimension: "conformity"
- name: "region"
logicalType: "string"
required: false
primaryKey: false
- name: "date_min"
logicalType: "date"
required: true
primaryKey: false
- name: "date_max"
logicalType: "date"
required: true
primaryKey: false
- name: "chart_type"
logicalType: "string"
required: false
primaryKey: false
quality:
- type: "library"
mustBe: 0
metric: "invalidValues"
arguments:
validValues:
- "Total # Citations"
- "Citations per Sq. Mile (Density)"
- "Violation Type"
- "Total $ Fine Amount"
- "Fine $ Amount per Sq. Mile (Density)"
- "Day of the Week"
dimension: "conformity"
- name: "compare_mode"
businessName: "Schema 2"
physicalType: "table"
properties:
- name: "region_type"
logicalType: "string"
primaryKey: false
required: true
quality:
- type: "library"
metric: "invalidValues"
arguments:
validValues:
- "Neighborhood Council"
- "Zip Code"
- "Place (Radius)"
mustBe: 0
description: "Region Type should be one of the valid region types"
dimension: "conformity"
- name: "region_1"
logicalType: "string"
required: false
primaryKey: false
- name: "region_2"
logicalType: "string"
required: false
primaryKey: false
- name: "date_min"
logicalType: "date"
required: true
primaryKey: false
- name: "date_max"
logicalType: "date"
required: true
primaryKey: false
- name: "chart_type"
logicalType: "string"
required: false
primaryKey: false
quality:
- type: "library"
mustBe: 0
metric: "invalidValues"
arguments:
validValues:
- "Total # Citations"
- "Citations per Sq. Mile (Density)"
- "Violation Type"
- "Total $ Fine Amount"
- "Fine $ Amount per Sq. Mile (Density)"
- "Day of the Week"
dimension: "conformity"
Loading