@@ -40,7 +40,6 @@ def _read_gbq_dataframe(self, query: str) -> DataFrame:
40
40
"""
41
41
Execute a read query on Google BigQuery and return the results as a pandas DataFrame.
42
42
Retries up to stop_after_attempt times on connection errors with exponential backoff.
43
-
44
43
Note:
45
44
This method uses the bigframes.pandas.read_gbq function to execute the query. It relies on
46
45
Application Default Credentials (ADC) for authentication, primarily using the
@@ -57,7 +56,6 @@ def _read_gbq_dataframe(self, query: str) -> DataFrame:
57
56
logger .info ("Using enviroment variable $GOOGLE_APPLICATION_CREDENTIALS for authentication." )
58
57
else :
59
58
logger .warning ("GOOGLE_APPLICATION_CREDENTIALS not set, falling back to gcloud CLI user credentials" )
60
-
61
59
# Execute the query with retry logic
62
60
return cast (DataFrame , bpd .read_gbq (query ).to_pandas ())
63
61
@@ -71,19 +69,15 @@ def _get_indexer_eligibility_query(self, start_date: date, end_date: date) -> st
71
69
- Response latency <5,000ms,
72
70
- Blocks behind <50,000,
73
71
- Subgraph has >=500 GRT signal at query time
74
-
75
72
Note: The 500 GRT curation signal requirement is not currently implemented.
76
-
77
73
Args:
78
74
start_date (date): The start date for the data range.
79
75
end_date (date): The end date for the data range.
80
-
81
76
Returns:
82
77
str: SQL query string for indexer eligibility data.
83
78
"""
84
79
start_date_str = start_date .strftime ("%Y-%m-%d" )
85
80
end_date_str = end_date .strftime ("%Y-%m-%d" )
86
-
87
81
return f"""
88
82
WITH
89
83
-- Get daily query metrics per indexer
@@ -107,7 +101,6 @@ def _get_indexer_eligibility_query(self, start_date: date, end_date: date) -> st
107
101
GROUP BY
108
102
day_partition, indexer
109
103
),
110
-
111
104
-- Determine which days count as 'online' (>= 1 good query on >= 10 subgraphs)
112
105
DaysOnline AS (
113
106
SELECT
@@ -120,7 +113,6 @@ def _get_indexer_eligibility_query(self, start_date: date, end_date: date) -> st
120
113
FROM
121
114
DailyMetrics
122
115
),
123
-
124
116
-- Calculate unique subgraphs served with at least one good query
125
117
UniqueSubgraphs AS (
126
118
SELECT
@@ -136,7 +128,6 @@ def _get_indexer_eligibility_query(self, start_date: date, end_date: date) -> st
136
128
GROUP BY
137
129
indexer
138
130
),
139
-
140
131
-- Calculate overall metrics per indexer
141
132
IndexerMetrics AS (
142
133
SELECT
@@ -154,7 +145,6 @@ def _get_indexer_eligibility_query(self, start_date: date, end_date: date) -> st
154
145
GROUP BY
155
146
d.indexer, ds.unique_good_response_subgraphs
156
147
)
157
-
158
148
-- Final result with eligibility determination
159
149
SELECT
160
150
indexer,
@@ -176,15 +166,12 @@ def fetch_indexer_issuance_eligibility_data(self, start_date: date, end_date: da
176
166
"""
177
167
Fetch data from Google BigQuery, used to determine indexer issuance eligibility, and compute
178
168
each indexer's issuance eligibility status.
179
-
180
169
Depends on:
181
170
- _get_indexer_eligibility_query()
182
171
- _read_gbq_dataframe()
183
-
184
172
Args:
185
173
start_date (date): The start date for the data to fetch from BigQuery.
186
174
end_date (date): The end date for the data to fetch from BigQuery.
187
-
188
175
Returns:
189
176
DataFrame: DataFrame containing a range of metrics for each indexer.
190
177
The DataFrame contains the following columns:
@@ -197,6 +184,5 @@ def fetch_indexer_issuance_eligibility_data(self, start_date: date, end_date: da
197
184
"""
198
185
# Construct the query
199
186
query = self ._get_indexer_eligibility_query (start_date , end_date )
200
-
201
187
# Return the results df
202
188
return self ._read_gbq_dataframe (query )
0 commit comments