Skip to content

Commit 84e207e

Browse files
authored
Read a team given as a list of members as a team without a name (#1768)
* Read a team given as a list of members as a team without a name * Import a workbook team holding only members as a team object * Drop the list-team handling of the catalog and the changelog, which only see resolved contracts * Note in the changelog that a member-list team is now written as a team object
1 parent 01c7ec9 commit 84e207e

17 files changed

Lines changed: 148 additions & 53 deletions

‎CHANGELOG.md‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,13 +16,15 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
1616
- The bundled Data Contract Editor (`datacontract edit`) is updated to 0.1.16
1717
- `datacontract export excel`: the ODCS v3.2 template shows a tooltip with the field description on every field label
1818
- `datacontract lint` and `datacontract test`: reject duplicate keys in a data contract instead of silently keeping the last value (#1741 @kamathramu87)
19+
- `datacontract export odcs`, `import odcs` and `import excel` write a `team` given as a list of members as a team object with `members` (this syntax is preferred by ODCS 3.2)
1920

2021
### Fixed
2122
- `datacontract dbt sync`: library metrics (`nullValues`, `missingValues`, `invalidValues`, `duplicateValues`) generate tests that check the metric against its bound
2223
- `datacontract export sql`: apostrophes and backslashes in descriptions no longer break ClickHouse and Snowflake `COMMENT` clauses (#1729,#1731 @banshee @ezno12)
2324
- `datacontract changelog` and `datacontract breaking` recognize a quality rule that was named, renamed or moved, instead of reporting it as removed and added
2425
- `datacontract breaking` grades more changes to quality rules and to `minimum`/`maximum` bounds instead of warning
2526
- `datacontract breaking` no longer flags changes that `datacontract test` does not check
27+
- Contracts whose `team` is the deprecated list of members no longer fail to export, `import odcs --owner` or `dbt sync`
2628

2729
## [1.2.7] - 2026-10-16
2830

‎datacontract/catalog/catalog.py‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717

1818
def _get_owner(odcs: OpenDataContractStandard) -> Optional[str]:
1919
"""Get the owner from ODCS customProperties or team."""
20-
if odcs.team and hasattr(odcs.team, "name") and odcs.team.name:
20+
if odcs.team and odcs.team.name:
2121
return odcs.team.name
2222
if odcs.customProperties:
2323
for prop in odcs.customProperties:

‎datacontract/changelog/normalize.py‎

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -263,8 +263,6 @@ def normalize(contract: dict) -> dict:
263263
team = out["team"]
264264
if isinstance(team, dict) and "members" in team and isinstance(team["members"], list):
265265
out["team"] = {**team, "members": _normalize_by(team["members"], "username")}
266-
elif isinstance(team, list):
267-
out["team"] = _normalize_by(team, "username")
268266

269267
if "authoritativeDefinitions" in out and isinstance(out["authoritativeDefinitions"], list):
270268
out["authoritativeDefinitions"] = _normalize_auth_defs(out["authoritativeDefinitions"])

‎datacontract/export/excel_exporter.py‎

Lines changed: 14 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,6 @@
1414
OpenDataContractStandard,
1515
SchemaObject,
1616
SchemaProperty,
17-
Team,
1817
)
1918
from openpyxl.cell.cell import Cell
2019
from openpyxl.utils import range_boundaries
@@ -629,24 +628,24 @@ def fill_support(export: Export):
629628

630629
def fill_team(export: Export):
631630
team = export.odcs.team
632-
members = team.members if isinstance(team, Team) else team
633-
if isinstance(team, Team):
634-
for name, value in (
635-
("team.name", team.name),
636-
("team.description", team.description),
637-
("team.tags", ",".join(team.tags) if team.tags else None),
638-
("team.id", team.id),
639-
):
640-
if value is not None and not set_optional_cell(export, name, value):
641-
export.unsupported["team details"] += 1
642-
# the team block has no inline pairs: every custom property goes to the sheet
643-
export.custom_property_rows += [(export.element(team), prop) for prop in team.customProperties or []]
644-
export.sheet_authoritative_definitions(team)
631+
if team is None:
632+
return
633+
for name, value in (
634+
("team.name", team.name),
635+
("team.description", team.description),
636+
("team.tags", ",".join(team.tags) if team.tags else None),
637+
("team.id", team.id),
638+
):
639+
if value is not None and not set_optional_cell(export, name, value):
640+
export.unsupported["team details"] += 1
641+
# the team block has no inline pairs: every custom property goes to the sheet
642+
export.custom_property_rows += [(export.element(team), prop) for prop in team.customProperties or []]
643+
export.sheet_authoritative_definitions(team)
645644
found = row_sheet(export, "Team", "team")
646645
if not found:
647646
return
648647
sheet, header_row = found
649-
for offset, member in enumerate(members or []):
648+
for offset, member in enumerate(team.members or []):
650649
values = {
651650
"username": member.username,
652651
"name": member.name,

‎datacontract/export/markdown_exporter.py‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,7 @@ def info_to_markdown(data_contract: OpenDataContractStandard) -> str:
7272
parts.append(f"- **version:** {data_contract.version}")
7373
if data_contract.status:
7474
parts.append(f"- **status:** {data_contract.status}")
75-
if data_contract.team:
75+
if data_contract.team and data_contract.team.name:
7676
parts.append(f"- **team:** {data_contract.team.name}")
7777
return "\n".join(parts)
7878

‎datacontract/export/rdf_exporter.py‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -127,7 +127,7 @@ def add_basic_info(contract, data_contract: OpenDataContractStandard, graph, odc
127127
graph.add((bnode_info, odcs.version, Literal(data_contract.version)))
128128

129129
# Add team/owner
130-
if data_contract.team:
130+
if data_contract.team and data_contract.team.name:
131131
graph.add((bnode_info, odcs.team, Literal(data_contract.team.name)))
132132

133133

‎datacontract/imports/excel_importer.py‎

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -505,7 +505,7 @@ def import_support(workbook: Workbook) -> Optional[List[Support]]:
505505

506506

507507
def import_team(workbook: Workbook):
508-
"""The team: a list of members, or a Team block when the template's team cells are filled"""
508+
"""The team, or None when the workbook has neither members nor filled team cells"""
509509
members = []
510510
table = open_row_sheet(workbook, "Team", "team")
511511
if table:
@@ -533,9 +533,9 @@ def import_team(workbook: Workbook):
533533
team_description = get_cell_value_by_name(workbook, "team.description")
534534
team_tags = split_list(get_cell_value_by_name(workbook, "team.tags"))
535535
team_id = get_cell_value_by_name(workbook, "team.id")
536-
if team_name or team_description or team_tags or team_id:
536+
if members or team_name or team_description or team_tags or team_id:
537537
return Team(name=team_name, description=team_description, tags=team_tags, id=team_id, members=members or None)
538-
return members or None
538+
return None
539539

540540

541541
def import_roles(workbook: Workbook, servers: Optional[List[Server]] = None) -> Optional[List[Role]]:
@@ -765,8 +765,8 @@ def resolve_element(odcs: OpenDataContractStandard, row: Row, what: str):
765765
ref = row.text("scope name") or ""
766766
if kind == "Description" and odcs.description is None:
767767
odcs.description = Description()
768-
if kind == "Team" and not isinstance(odcs.team, Team):
769-
odcs.team = Team(members=odcs.team or None)
768+
if kind == "Team" and odcs.team is None:
769+
odcs.team = Team()
770770
element = element_index(odcs).get((kind, ref))
771771
if element is None:
772772
logger.warning(

‎datacontract/imports/odcs_importer.py‎

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
from open_data_contract_standard.model import OpenDataContractStandard
33

44
from datacontract.imports.importer import Importer
5+
from datacontract.lint.resolve import convert_member_list_team
56
from datacontract.lint.resources import read_resource
67
from datacontract.model.exceptions import DataContractException
78

@@ -44,7 +45,7 @@ def import_odcs(source: str, config=None) -> OpenDataContractStandard:
4445
)
4546
elif odcs_api_version.startswith("v3."):
4647
# Parse directly as ODCS
47-
return OpenDataContractStandard.model_validate(odcs_yaml)
48+
return convert_member_list_team(OpenDataContractStandard.model_validate(odcs_yaml))
4849
else:
4950
raise DataContractException(
5051
type="schema",

‎datacontract/lint/resolve.py‎

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
import yaml
1212
from jsonschema import validators
1313
from jsonschema.exceptions import best_match
14-
from open_data_contract_standard.model import OpenDataContractStandard, SchemaProperty
14+
from open_data_contract_standard.model import OpenDataContractStandard, SchemaProperty, Team
1515
from pydantic import BaseModel, ConfigDict
1616

1717
from datacontract.config import Config
@@ -202,7 +202,7 @@ def resolve_data_contract_with_lint_info(
202202
configured_host_only=configured_host_only,
203203
)
204204
elif data_contract is not None:
205-
return data_contract, None, []
205+
return convert_member_list_team(data_contract), None, []
206206
else:
207207
raise DataContractException(
208208
type="lint",
@@ -879,7 +879,7 @@ def _parse_odcs_from_dict(yaml_dict: dict, lax: bool = False) -> OpenDataContrac
879879
"""Parse ODCS from a dictionary."""
880880
cls = _LaxOpenDataContractStandard if lax else OpenDataContractStandard
881881
try:
882-
return cls(**yaml_dict)
882+
return convert_member_list_team(cls(**yaml_dict))
883883
except Exception as e:
884884
raise DataContractException(
885885
type="schema",
@@ -890,6 +890,13 @@ def _parse_odcs_from_dict(yaml_dict: dict, lax: bool = False) -> OpenDataContrac
890890
)
891891

892892

893+
def convert_member_list_team(odcs: OpenDataContractStandard) -> OpenDataContractStandard:
894+
"""Read the deprecated list-of-members `team` as a team object holding those members."""
895+
if isinstance(odcs.team, list):
896+
odcs.team = Team(members=odcs.team) if odcs.team else None
897+
return odcs
898+
899+
893900
def _to_yaml(data_contract_str, location: str | None = None) -> dict:
894901
try:
895902
return yaml.load(data_contract_str, Loader=_SafeLoaderNoTimestamp)

‎datacontract/model/workbook.py‎

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616

1717
import openpyxl
1818
import yaml
19-
from open_data_contract_standard.model import OpenDataContractStandard, SchemaProperty, Team
19+
from open_data_contract_standard.model import OpenDataContractStandard, SchemaProperty
2020

2121
from datacontract.model.natural_keys import NATURAL_KEYS
2222

@@ -93,13 +93,10 @@ def iter_elements(odcs: OpenDataContractStandard) -> Iterator[Element]:
9393
yield from _property_elements(schema.obj.properties, schema.ref, schema.label)
9494
for support in _keyed(odcs.support, NATURAL_KEYS["support"], "Support", "support channel"):
9595
yield support
96-
if isinstance(odcs.team, Team):
96+
if odcs.team is not None:
9797
yield Element("Team", odcs.team.name or "", odcs.team, "the team")
98-
members = odcs.team.members
99-
else:
100-
members = odcs.team
101-
for member in _keyed(members, NATURAL_KEYS["team.members"], "Team Member", "team member"):
102-
yield member
98+
for member in _keyed(odcs.team.members, NATURAL_KEYS["team.members"], "Team Member", "team member"):
99+
yield member
103100
for role in _keyed(odcs.roles, NATURAL_KEYS["roles"], "Role", "role"):
104101
yield role
105102
for sla in _keyed(odcs.slaProperties, NATURAL_KEYS["slaProperties"], "SLA", "SLA property"):

0 commit comments

Comments
 (0)