Exemplo n.º 1
0
        ">>>>Review the printout above to see what will be associated. Press enter to continue or Ctrl+C to back out now..."
    )
    # For every entity and term that met the threshold, add an
    # AtlasGlossarySemanticAssignment relationship (one at a time).
    for so in search_intermediate_results:
        print(
            f"Attempting to add '{so.TermDisplay}' to {so.AssetId} ({so.SearchScore}) because {so.Reason} "
        )
        relationship = {
            "typeName": "AtlasGlossarySemanticAssignment",
            "attributes": {},
            "guid": -100,
            "end1": {
                "guid": so.TermId,
                "typeName": "AtlasGlossaryTerm"
            },
            "end2": {
                "guid": so.AssetId
            }
        }
        try:
            # Attempt the upload, but the relationship may already exist
            # So simply skip log it and skip past it.
            results = client.upload_relationship(relationship)
            print("\tSuccess")
        except Exception as e:
            print(
                f"\tException for {so.TermId}:{so.AssetId} and was not uploaded: {e}"
            )
        print("\n")
Exemplo n.º 2
0
            "typeName": "hive_table_columns",
            "attributes": {},
            "guid": -100,
            # Ends are either guid or guid + typeName
            # (in case there are ambiguities?)
            # End1 is the hive_table
            "end1": {
                "guid": assignments["-1"]
            },
            # End2 is the hive_column
            "end2": {
                "guid": assignments["-5"]
            }
        }

        relation_upload = client.upload_relationship(relationship)

        # Check that we have one more relationship
        print(
            "Now we can see that there should be one more relationship attribute."
        )
        live_table_post_relationship = client.get_entity(
            guid=assignments["-1"])["entities"][0]
        print(
            json.dumps(live_table_post_relationship["relationshipAttributes"],
                       indent=2))

    finally:
        # Need to delete all columns BEFORE you delete the table
        for local_id in [str(s) for s in range(-5, 0)]:
            guid = assignments[local_id]