mirror of
				https://github.com/datahub-project/datahub.git
				synced 2025-10-30 18:26:58 +00:00 
			
		
		
		
	 0527a57617
			
		
	
	
		0527a57617
		
			
		
	
	
	
	
		
			
			Co-authored-by: John Joyce <john@ip-192-168-1-200.us-west-2.compute.internal> Co-authored-by: John Joyce <john@Johns-MBP.lan>
		
			
				
	
	
		
			29 lines
		
	
	
		
			1.1 KiB
		
	
	
	
		
			Python
		
	
	
	
	
	
			
		
		
	
	
			29 lines
		
	
	
		
			1.1 KiB
		
	
	
	
		
			Python
		
	
	
	
	
	
| import logging
 | |
| 
 | |
| from datahub.ingestion.graph.client import DatahubClientConfig, DataHubGraph
 | |
| 
 | |
| log = logging.getLogger(__name__)
 | |
| 
 | |
| graph = DataHubGraph(
 | |
|     config=DatahubClientConfig(
 | |
|         server="http://localhost:8080",
 | |
|     )
 | |
| )
 | |
| 
 | |
| new_assertion_urn = "urn:li:assertion:my-unique-assertion-id"
 | |
| 
 | |
| # Upsert the assertion
 | |
| res = graph.upsert_custom_assertion(
 | |
|     urn=new_assertion_urn,  # If the assertion already exists, provide the URN
 | |
|     entity_urn="<urn of entity being monitored>",
 | |
|     type="My Custom Category",  # This categorizes your assertion in DataHub
 | |
|     description="The description of my external assertion for my dataset",
 | |
|     platform_urn="urn:li:dataPlatform:great-expectations",  # OR you can provide 'platformName="My Custom Platform"'
 | |
|     field_path="field_foo",  # Optional: if you want to associate it with a specific field
 | |
|     external_url="https://my-monitoring-tool.com/result-for-this-assertion",  # Optional: link to monitoring tool
 | |
|     logic="SELECT * FROM X WHERE Y",  # Optional: custom SQL for the assertion, rendered in the UI
 | |
| )
 | |
| 
 | |
| if res is not None:
 | |
|     log.info(f"Upserted assertion with urn: {new_assertion_urn}")
 |