mirror of
https://github.com/datahub-project/datahub.git
synced 2025-08-31 21:03:03 +00:00
fix(docs): fixing metadata model doc generation script and updating png (#4120)
This commit is contained in:
parent
ea2b092fe8
commit
d1a14abb53
43
.github/workflows/metadata-model.yml
vendored
Normal file
43
.github/workflows/metadata-model.yml
vendored
Normal file
@ -0,0 +1,43 @@
|
|||||||
|
name: metadata model generate
|
||||||
|
on:
|
||||||
|
push:
|
||||||
|
branches:
|
||||||
|
- master
|
||||||
|
paths-ignore:
|
||||||
|
- "docs/**"
|
||||||
|
- "**.md"
|
||||||
|
release:
|
||||||
|
types: [published, edited]
|
||||||
|
|
||||||
|
jobs:
|
||||||
|
setup:
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
outputs:
|
||||||
|
publish: ${{ steps.publish.outputs.publish }}
|
||||||
|
steps:
|
||||||
|
- name: Check whether upload to datahub is enabled
|
||||||
|
id: publish
|
||||||
|
env:
|
||||||
|
ENABLE_PUBLISH: ${{ secrets.DataHubToken }}
|
||||||
|
run: |
|
||||||
|
echo "Enable publish: ${{ env.ENABLE_PUBLISH != '' }}"
|
||||||
|
echo "::set-output name=publish::${{ env.ENABLE_PUBLISH != '' }}"
|
||||||
|
metadata-ingestion-docgen:
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
steps:
|
||||||
|
- uses: actions/checkout@v2
|
||||||
|
- uses: actions/setup-python@v2
|
||||||
|
with:
|
||||||
|
python-version: "3.9.9"
|
||||||
|
- name: Install dependencies
|
||||||
|
run: ./metadata-ingestion/scripts/install_deps.sh
|
||||||
|
- name: Run model generation
|
||||||
|
run: ./gradlew :metadata-models:build
|
||||||
|
- name: Upload metadata to DataHub
|
||||||
|
if: ${{ needs.setup.outputs.publish == 'true' }}
|
||||||
|
env:
|
||||||
|
DATAHUB_SERVER: ${{ secrets.DataHubServer }}
|
||||||
|
DATAHUB_TOKEN: ${{ secrets.DataHubToken }}
|
||||||
|
run: ./gradlew :metadata-ingestion:modelDocUpload
|
||||||
|
|
||||||
|
|
Binary file not shown.
Before Width: | Height: | Size: 296 KiB After Width: | Height: | Size: 460 KiB |
@ -231,7 +231,9 @@ def make_entity_docs(entity_display_name: str, graph: RelationshipGraph) -> str:
|
|||||||
if adjacency.self_loop:
|
if adjacency.self_loop:
|
||||||
relationships_section += f"\n### Self\nThese are the relationships to itself, stored in this entity's aspects"
|
relationships_section += f"\n### Self\nThese are the relationships to itself, stored in this entity's aspects"
|
||||||
for relnship in adjacency.self_loop:
|
for relnship in adjacency.self_loop:
|
||||||
relationships_section += f"\n- {relnship.name} ({relnship.doc[1:] if relnship.doc else ''})"
|
relationships_section += (
|
||||||
|
f"\n- {relnship.name} ({relnship.doc[1:] if relnship.doc else ''})"
|
||||||
|
)
|
||||||
|
|
||||||
if adjacency.outgoing:
|
if adjacency.outgoing:
|
||||||
relationships_section += f"\n### Outgoing\nThese are the relationships stored in this entity's aspects"
|
relationships_section += f"\n### Outgoing\nThese are the relationships stored in this entity's aspects"
|
||||||
@ -274,9 +276,7 @@ def generate_stitched_record(relnships_graph: RelationshipGraph) -> List[Any]:
|
|||||||
if aspect_name not in aspect_registry:
|
if aspect_name not in aspect_registry:
|
||||||
print(f"Did not find aspect name: {aspect_name} in aspect_registry")
|
print(f"Did not find aspect name: {aspect_name} in aspect_registry")
|
||||||
continue
|
continue
|
||||||
import pdb
|
|
||||||
|
|
||||||
# breakpoint()
|
|
||||||
# all aspects should have a schema
|
# all aspects should have a schema
|
||||||
aspect_schema = aspect_registry[aspect_name].schema
|
aspect_schema = aspect_registry[aspect_name].schema
|
||||||
assert aspect_schema
|
assert aspect_schema
|
||||||
@ -292,7 +292,7 @@ def generate_stitched_record(relnships_graph: RelationshipGraph) -> List[Any]:
|
|||||||
field_objects = []
|
field_objects = []
|
||||||
for f in entity_fields:
|
for f in entity_fields:
|
||||||
field = avro.schema.Field(
|
field = avro.schema.Field(
|
||||||
type_=f["type"],
|
type=f["type"],
|
||||||
name=f["name"],
|
name=f["name"],
|
||||||
has_default=False,
|
has_default=False,
|
||||||
)
|
)
|
||||||
@ -327,7 +327,8 @@ def generate_stitched_record(relnships_graph: RelationshipGraph) -> List[Any]:
|
|||||||
for f_field in schema_fields:
|
for f_field in schema_fields:
|
||||||
if f_field.jsonProps:
|
if f_field.jsonProps:
|
||||||
import pdb
|
import pdb
|
||||||
#breakpoint()
|
|
||||||
|
# breakpoint()
|
||||||
json_dict = json.loads(f_field.jsonProps)
|
json_dict = json.loads(f_field.jsonProps)
|
||||||
if "Aspect" in json_dict:
|
if "Aspect" in json_dict:
|
||||||
aspect_info = json_dict["Aspect"]
|
aspect_info = json_dict["Aspect"]
|
||||||
@ -483,7 +484,7 @@ def generate(
|
|||||||
server: Optional[str],
|
server: Optional[str],
|
||||||
file: Optional[str],
|
file: Optional[str],
|
||||||
dot: Optional[str],
|
dot: Optional[str],
|
||||||
png: Optional[str]
|
png: Optional[str],
|
||||||
) -> None:
|
) -> None:
|
||||||
logger.info(f"server = {server}")
|
logger.info(f"server = {server}")
|
||||||
logger.info(f"file = {file}")
|
logger.info(f"file = {file}")
|
||||||
@ -497,7 +498,7 @@ def generate(
|
|||||||
else:
|
else:
|
||||||
# schema file
|
# schema file
|
||||||
load_schema_file(schema_file)
|
load_schema_file(schema_file)
|
||||||
|
|
||||||
relationship_graph = RelationshipGraph()
|
relationship_graph = RelationshipGraph()
|
||||||
events = generate_stitched_record(relationship_graph)
|
events = generate_stitched_record(relationship_graph)
|
||||||
|
|
||||||
@ -573,9 +574,12 @@ def generate(
|
|||||||
try:
|
try:
|
||||||
graph.write_png(png)
|
graph.write_png(png)
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
logger.error("Failed to create png file. Do you have graphviz installed?")
|
logger.error(
|
||||||
|
"Failed to create png file. Do you have graphviz installed?"
|
||||||
|
)
|
||||||
raise e
|
raise e
|
||||||
|
|
||||||
|
|
||||||
if __name__ == "__main__":
|
if __name__ == "__main__":
|
||||||
logger.setLevel("INFO")
|
logger.setLevel("INFO")
|
||||||
generate()
|
generate()
|
||||||
|
@ -6,8 +6,8 @@ OUTDIR=./generated/docs
|
|||||||
# Note: this assumes that datahub has already been built with `./gradlew build`.
|
# Note: this assumes that datahub has already been built with `./gradlew build`.
|
||||||
DATAHUB_ROOT=..
|
DATAHUB_ROOT=..
|
||||||
REGISTRY_ROOT="$DATAHUB_ROOT/metadata-models/src/main/resources"
|
REGISTRY_ROOT="$DATAHUB_ROOT/metadata-models/src/main/resources"
|
||||||
SCHEMAS_ROOT="$DATAHUB_ROOT/metadata-models/src/mainGeneratedAvroSchema/avro/com/linkedin"
|
SCHEMAS_ROOT="$DATAHUB_ROOT/metadata-events/mxe-schemas/src/mainGeneratedAvroSchema/avro"
|
||||||
FILES="$REGISTRY_ROOT/entity-registry.yml $SCHEMAS_ROOT/mxe/MetadataChangeEvent.avsc"
|
FILES="$REGISTRY_ROOT/entity-registry.yml $SCHEMAS_ROOT/com/linkedin/mxe/MetadataChangeEvent.avsc"
|
||||||
# Since we depend on jq, check if jq is installed
|
# Since we depend on jq, check if jq is installed
|
||||||
if ! which jq > /dev/null; then
|
if ! which jq > /dev/null; then
|
||||||
echo "jq is not installed. Please install jq and rerun (https://stedolan.github.io/jq/)"
|
echo "jq is not installed. Please install jq and rerun (https://stedolan.github.io/jq/)"
|
||||||
|
Loading…
x
Reference in New Issue
Block a user