Skip to content

Commit 0fb1621

Browse files
Fixing lint error
1 parent 458f9f4 commit 0fb1621

1 file changed

Lines changed: 18 additions & 24 deletions

File tree

  • src/datacustomcode/templates/function/example/chunking_with_prediction

src/datacustomcode/templates/function/example/chunking_with_prediction/entrypoint.py

Lines changed: 18 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -15,8 +15,17 @@
1515
"""
1616

1717
import logging
18-
from typing import Any, Dict, Optional
18+
from typing import (
19+
Any,
20+
Dict,
21+
Optional,
22+
)
1923

24+
from datacustomcode.einstein_predictions.types import (
25+
PredictionColumBuilder,
26+
PredictionRequestBuilder,
27+
PredictionType,
28+
)
2029
from datacustomcode.function import Runtime
2130
from datacustomcode.function.feature_types.chunking import (
2231
ChunkType,
@@ -25,12 +34,6 @@
2534
SearchIndexChunkingV1Response,
2635
)
2736

28-
from datacustomcode.einstein_predictions.types import (
29-
PredictionColumBuilder,
30-
PredictionRequestBuilder,
31-
PredictionType,
32-
)
33-
3437
logger = logging.getLogger(__name__)
3538
logging.basicConfig(level=logging.INFO)
3639

@@ -74,7 +77,9 @@ def predict_sale_price(
7477
)
7578
else:
7679
# Skip unsupported types
77-
logger.warning(f"Skipping field {column_name} with unsupported type {type(value)}")
80+
logger.warning(
81+
f"Skipping field {column_name} with unsupported type {type(value)}"
82+
)
7883
continue
7984

8085
prediction_columns.append(column)
@@ -95,6 +100,10 @@ def predict_sale_price(
95100
return None
96101

97102
# Parse regression response
103+
if prediction_response.data is None:
104+
logger.warning("Prediction response data is None")
105+
return None
106+
98107
results = prediction_response.data.get("results", [])
99108
if not results:
100109
logger.warning("No results in prediction response")
@@ -179,8 +188,6 @@ def function(
179188
"metadata": {
180189
"source_dmo_fields": {
181190
"Year_Built__c": 1990,
182-
"address": "123 Main St",
183-
"city": "San Francisco"
184191
}
185192
}
186193
}
@@ -195,7 +202,6 @@ def function(
195202
"seq_no": 1,
196203
"citations": {
197204
"Year_Built__c": "1990",
198-
"address": "123 Main St",
199205
"predicted_sale_price": "$350,000.00",
200206
"predicted_sale_price_raw": "350000.0",
201207
"prediction_status": "success"
@@ -211,9 +217,6 @@ def function(
211217
Returns:
212218
Properties enriched with predicted sale prices
213219
"""
214-
logger.info(
215-
f"Processing {len(request.input)} properties for price prediction"
216-
)
217220

218221
enriched_properties = []
219222
seq_no = 1
@@ -222,9 +225,6 @@ def function(
222225
text = doc.text
223226
metadata = doc.metadata
224227

225-
logger.info(f"Property {doc_idx + 1}: {text[:100]}...")
226-
227-
# Get source_dmo_fields
228228
source_dmo_fields = {}
229229
if metadata and metadata.source_dmo_fields:
230230
source_dmo_fields = dict(metadata.source_dmo_fields)
@@ -241,12 +241,6 @@ def function(
241241
)
242242
enriched_properties.append(property_output)
243243

244-
logger.info(
245-
f"Property {seq_no}: Predicted price = "
246-
f"{citations.get('predicted_sale_price', 'N/A')}"
247-
)
248244
seq_no += 1
249245

250-
logger.info(f"Total properties enriched: {len(enriched_properties)}")
251-
252-
return SearchIndexChunkingV1Response(output=enriched_properties)
246+
return SearchIndexChunkingV1Response(output=enriched_properties)

0 commit comments

Comments
 (0)