Contract
cli.commands.contract
Module for creating data contracts in the Hari CLI.
contract(version, created_at, name, output_table, columns, description=None, owner_email=None, sla=None)
Create a data contract dictionary.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
version
|
str
|
The version of the Hari library. |
required |
created_at
|
str
|
The creation date of the contract. |
required |
name
|
str
|
The name of the contract. |
required |
output_table
|
Dict[str, str]
|
Information about the output table, including name, path, format, and partition columns. |
required |
columns
|
List[Dict[str, str]]
|
List of column definitions for the output table. |
required |
description
|
Optional[str]
|
Description of the contract. Defaults to None. |
None
|
owner_email
|
Optional[str]
|
Email of the contract owner. Defaults to None. |
None
|
sla
|
Optional[Dict[str, str]]
|
SLA information, such as frequency and tolerance. Defaults to None. |
None
|
Returns:
| Type | Description |
|---|---|
Dict[str, Any]
|
Dict[str, Any]: A dictionary representing the data contract. |
Examples:
>>> contract(
... version='0.1.0',
... created_at='2025-07-01',
... name='example',
... description='This is an example contract.',
... owner_email='user@mail.com',
... output_table={
... 'name': 'table_name',
... 'path': 'catalog.schema.table_name',
... 'format': 'delta',
... 'partitioned_by': ['col1', 'col2'],
... },
... columns=[
... {'name': 'col1', 'type': 'string'},
... {'name': 'col2', 'type': 'integer'},
... ],
... sla={
... 'frequency': 'daily',
... 'tolerance': '22:00:00'
... }
... )
{
'hari_version': '0.1.0',
'created_at': '2025-07-01',
'name': 'example',
'description': 'This is an example contract.',
'owner_email': 'user@mail.com',
'output_table': {
'name': 'table_name',
'path': 'catalog.schema.table_name',
'format': 'delta',
'partitioned_by': ['col1', 'col2'],
'columns': [
{'name': 'col1', 'type': 'string'},
{'name': 'col2', 'type': 'integer'},
],
},
'sla': {
'frequency': 'daily',
'tolerance': '22:00:00',
},
}
Source code in hari_data/cli/commands/contract.py
13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 | |