2023-05-17 00:17:25 -07:00
|
|
|
import os
|
2023-05-24 00:34:16 +05:30
|
|
|
from typing import Dict, Type
|
|
|
|
|
|
|
|
import click
|
|
|
|
from pydantic import BaseModel
|
|
|
|
|
2023-05-17 00:17:25 -07:00
|
|
|
from datahub.api.entities.dataproduct.dataproduct import DataProduct
|
|
|
|
from datahub.ingestion.source.metadata.business_glossary import BusinessGlossaryConfig
|
2023-05-24 00:34:16 +05:30
|
|
|
|
2023-05-17 00:17:25 -07:00
|
|
|
|
|
|
|
@click.command()
|
|
|
|
@click.option("--out-dir", type=str, required=True)
|
2023-05-24 00:34:16 +05:30
|
|
|
def generate_specs(out_dir: str) -> None:
|
2023-05-17 00:17:25 -07:00
|
|
|
print(out_dir)
|
|
|
|
schemas_dir = f"{out_dir}/schemas"
|
|
|
|
os.makedirs(schemas_dir, exist_ok=True)
|
2023-05-24 00:34:16 +05:30
|
|
|
concept_class_map: Dict[str, Type[BaseModel]] = {
|
2023-05-17 00:17:25 -07:00
|
|
|
"dataproduct": DataProduct,
|
2023-05-24 00:34:16 +05:30
|
|
|
"businessglossary": BusinessGlossaryConfig,
|
2023-05-17 00:17:25 -07:00
|
|
|
}
|
|
|
|
for concept, concept_class in concept_class_map.items():
|
|
|
|
with open(f"{schemas_dir}/{concept}_schema.json", "w") as f:
|
|
|
|
f.write(concept_class.schema_json(indent=2))
|
|
|
|
|
|
|
|
|
|
|
|
if __name__ == "__main__":
|
2023-05-24 00:34:16 +05:30
|
|
|
generate_specs()
|