Skip to content

Commit

Permalink
feat: Add instrumentation for resource-level examples
Browse files Browse the repository at this point in the history
  • Loading branch information
jpmckinney committed Aug 10, 2023
1 parent 0cc0b52 commit abb3e9f
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion contracting_process/resource_level/examples.py
Original file line number Diff line number Diff line change
@@ -1,9 +1,13 @@
import logging

import simplejson as json

from contracting_process.resource_level.definitions import definitions
from pelican.util.checks import ReservoirSampler
from pelican.util.services import commit, get_cursor

logger = logging.getLogger("pelican.contracting_process.resource_level.examples")

sample_size = 20


Expand Down Expand Up @@ -33,7 +37,7 @@ def create(dataset_id):
{"dataset_id": dataset_id},
)

for row in named_cursor:
for i, row in enumerate(named_cursor, 1):
meta = row["result"]["meta"]
for check_name, result in row["result"]["checks"].items():
example = {"meta": meta, "result": result}
Expand All @@ -48,6 +52,9 @@ def create(dataset_id):
else:
raise NotImplementedError("result is not a boolean or null")

if not i % 1000:
logger.info("Processed %s resource-level check results", i)

with get_cursor() as cursor:
for check_name, samplers in check_samplers.items():
data = {
Expand Down

0 comments on commit abb3e9f

Please sign in to comment.