Hi, i'm trying to ingest a custom test results (no...
# troubleshoot
l
Hi, i'm trying to ingest a custom test results (not assertions, test) to Dataset using the script below. The script was successfully executed, and the test aspects was ingested into the gms backend. But the problem is that UI does not show any test details if all the test is passed, however it will show all the test details if at least 1 test is in
failing
. Any idea how to show all the test results if all the tests are passed ?
✅ 1
Copy code
import logging
from datahub.emitter.mcp import MetadataChangeProposalWrapper
from datahub.ingestion.graph.client import DatahubClientConfig, DataHubGraph
from datahub.metadata.schema_classes import (
    TestResultsClass,
    TestResultClass,
    TestResultTypeClass,
    TestInfoClass,
    TestDefinitionClass,
    TestDefinitionTypeClass
)

log = logging.getLogger(__name__)
logging.basicConfig(level=logging.INFO)

gms_endpoint = "http://host..."
graph = DataHubGraph(
    config=DatahubClientConfig(
        server=gms_endpoint
    )
)

test_properties = TestInfoClass(
    category="lineage",
    description="Simple test description 2",
    name="lineage-test",
    definition=TestDefinitionClass(
        type=TestDefinitionTypeClass.JSON,
        json="..."
    )
)

event: MetadataChangeProposalWrapper = MetadataChangeProposalWrapper(
    entityUrn="urn:li:test:lineage-test-2",
    aspect=test_properties,
)
graph.emit(event)

test_result_properties = TestResultClass(
    type=TestResultTypeClass.SUCCESS,
    test="urn:li:test:lineage-test-2"
)
test_results = TestResultsClass(
    failing=[],
    passing=[test_result_properties]
)
event: MetadataChangeProposalWrapper = MetadataChangeProposalWrapper(
    entityUrn="urn:li:dataset:(urn:li:dataPlatform:bigquery,xxx,PROD)",
    aspect=test_results,
)
graph.emit(event)
if I change the
test_results
to
Copy code
test_results = TestResultsClass(
    passing=[test_result_properties],
    failing=[test_result_properties]
)
, then it will give me this
Or if i change it to
Copy code
test_results = TestResultsClass(
    passing=[],
    failing=[test_result_properties]
)
then it will give me
a
Hi @limited-library-89060, do you think you could provide ingestion and frontend logs here? Are you able to query the data in GMS via the GraphQL api? @hundreds-photographer-13496 might be able to provide some guidance
l
Thanks for replying @astonishing-answer-96712, this is the log in
ingestion
state (local python logs)
Copy code
DEBUG:urllib3.connectionpool:Starting new HTTP connection (1): dummy_host:8082
DEBUG:urllib3.connectionpool:http://dummy_host:8082 "GET /config HTTP/1.1" 200 None
DEBUG:urllib3.connectionpool:http://dummy_host:8082 "GET /aspects/urn%3Ali%3Atelemetry%3AclientId?aspect=telemetryClientId&version=0 HTTP/1.1" 404 8642
DEBUG:datahub.emitter.rest_emitter:Attempting to emit to DataHub GMS; using curl equivalent to:
curl -X POST -H 'User-Agent: python-requests/2.28.1' -H 'Accept-Encoding: gzip, deflate' -H 'Accept: */*' -H 'Connection: keep-alive' -H 'X-RestLi-Protocol-Version: 2.0.0' -H 'Content-Type: application/json' --data '{"proposal": {"entityType": "test", "entityUrn": "urn:li:test:lineage-test-2", "changeType": "UPSERT", "aspectName": "testInfo", "aspect": {"value": "{\"name\": \"lineage-test\", \"category\": \"lineage\", \"description\": \"Simple test description 2\", \"definition\": {\"type\": \"JSON\", \"json\": \"\"}}", "contentType": "application/json"}}}' 'http://dummy_host:8082/aspects?action=ingestProposal'
DEBUG:urllib3.connectionpool:http://dummy_host:8082 "POST /aspects?action=ingestProposal HTTP/1.1" 200 38
DEBUG:datahub.emitter.rest_emitter:Attempting to emit to DataHub GMS; using curl equivalent to:
curl -X POST -H 'User-Agent: python-requests/2.28.1' -H 'Accept-Encoding: gzip, deflate' -H 'Accept: */*' -H 'Connection: keep-alive' -H 'X-RestLi-Protocol-Version: 2.0.0' -H 'Content-Type: application/json' --data '{"proposal": {"entityType": "dataset", "entityUrn": "urn:li:dataset:(urn:li:dataPlatform:postgres,dummy_dataset,PROD)", "changeType": "UPSERT", "aspectName": "testResults", "aspect": {"value": "{\"failing\": [], \"passing\": [{\"test\": \"urn:li:test:lineage-test-2\", \"type\": \"SUCCESS\"}]}", "contentType": "application/json"}}}' 'http://dummy_host:8082/aspects?action=ingestProposal'
DEBUG:urllib3.connectionpool:http://dummy_host:8082 "POST /aspects?action=ingestProposal HTTP/1.1" 200 93
In gms container
Copy code
00:42:24.706 [qtp522764626-38929] INFO  c.l.m.r.entity.AspectResource:143 - INGEST PROPOSAL proposal: {aspectName=testResults, entityUrn=urn:li:dataset:(urn:li:dataPlatform:postgres,dummy_dataset,PROD), entityType=dataset, aspect={contentType=application/json, value=ByteString(length=87,bytes=7b226661...227d5d7d)}, changeType=UPSERT}
00:42:24.710 [pool-11-thread-1] INFO  c.l.m.filter.RestliLoggingFilter:55 - POST /aspects?action=ingestProposal - ingestProposal - 200 - 4ms
00:43:18.712 [pool-11-thread-1] INFO  c.l.m.filter.RestliLoggingFilter:55 - GET /entitiesV2?ids=List(urn%3Ali%3Acorpuser%3Adatahub) - batchGet - 200 - 2ms
00:43:18.715 [pool-11-thread-1] INFO  c.l.m.filter.RestliLoggingFilter:55 - GET /entitiesV2?ids=List(urn%3Ali%3Adataset%3A%28urn%3Ali%3AdataPlatform%3Apostgres%2Cdummy_dataset%2CPROD%29) - batchGet - 200 - 2ms
00:43:18.717 [pool-11-thread-1] INFO  c.l.m.filter.RestliLoggingFilter:55 - GET /entitiesV2?ids=List(urn%3Ali%3Acorpuser%3Adatahub) - batchGet - 200 - 1ms
00:43:19.051 [qtp522764626-36516] INFO  c.l.m.resources.usage.UsageStats:291 - Attempting to query usage stats
00:43:19.058 [pool-11-thread-1] INFO  c.l.m.filter.RestliLoggingFilter:55 - POST /usageStats?action=queryRange - queryRange - 200 - 7ms
00:43:19.362 [I/O dispatcher 1] INFO  c.l.m.s.e.update.BulkListener:47 - Successfully fed bulk request. Number of events: 2 Took time ms: -1
Are you able to query the data in GMS via the GraphQL api?
Yes, I am able to access the dataset details (including
TestResults
) using graphql. I am using the default graphiql
Did I miss something in the payload @hundreds-photographer-13496?
a
Could you share graphql query you are using ? Also the script and screenshot where UI does not show any test detauls if all test is passed.
l
the graphql
Copy code
query getDetail{
  dataset(urn: "urn:li:dataset:(urn:li:dataPlatform:postgres,dummy_dataset,PROD)") {
    urn
    testResults{
      passing{
        test{
          urn
          type
          name
          category
          description
          definition{
            json
          }
        }
      }
      failing{
        test{
          urn
          type
          name
          category
          description
          definition{
            json
          }
        }
      }
    }
  }
}
The UI and script are already described in my previous chat @hundreds-photographer-13496 Script : here
image.png
h
Ahh okay, this one gives idea about "no details". Let me have a deeper look and get back in some time
l
And for context, I'm using datahub
0.9.5
h
This looks like a bug - https://github.com/datahub-project/datahub/blob/master/datahub-web-react/src/app/entity/shared/tabs/Dataset/Validations/TestResults.tsx#L25 this check
filteredFailing.length > 0
needs to be updated by
totalTests > 0
Would you be able to create a PR for this ?
l
I could try, do I also need to change the unit-test case for that ?
a
I am not much familiar with that piece. I'll let someone more familiar help on this. cc:: @echoing-airport-49548
l
Is this one okay @hundreds-photographer-13496 ? https://github.com/datahub-project/datahub/pull/7747
h
looks good to me.
e
Thanks @limited-library-89060! Let me take a look at this
Awesome, approved
Will wait for CI to complete