Thanks @nevintan !
Unfortunately, I couldn’t get this working with the batch_spec_passthrough
but got an error instead.
Here’s my code:
checkpoint = context.add_or_update_checkpoint(
name="example checkpoint",
batch_request={
'datasource_name': 'example',
'data_asset_name': 'fruits',
'batch_spec_passthrough': {
'data_asset_name': "fruits",
},
},
expectation_suite_name="example suite",
)
This results in example_checkpoint.yml looking like this:
...
batch_request:
datasource_name: example
data_asset_name: fruits
batch_spec_passthrough:
data_asset_name: fruits
...
Is this correct? As far as I can tell, this matches Example 1 from the mentioned thread.
However, running checkpoint.run()
throws a ValidationError
, stack trace below.
---------------------------------------------------------------------------
ValidationError Traceback (most recent call last)
Cell In[22], line 1
----> 1 checkpoint.run()
File ~/code/gx-exploration/.venv/lib/python3.10/site-packages/great_expectations/core/usage_statistics/usage_statistics.py:266, in usage_statistics_enabled_method.<locals>.usage_statistics_wrapped_method(*args, **kwargs)
263 args_payload = args_payload_fn(*args, **kwargs) or {}
264 nested_update(event_payload, args_payload)
--> 266 result = func(*args, **kwargs)
267 message["success"] = True
268 except Exception:
File ~/code/gx-exploration/.venv/lib/python3.10/site-packages/great_expectations/checkpoint/checkpoint.py:315, in BaseCheckpoint.run(self, template_name, run_name_template, expectation_suite_name, batch_request, validator, action_list, evaluation_parameters, runtime_configuration, validations, profilers, run_id, run_name, run_time, result_format, expectation_suite_ge_cloud_id)
305 self._run_validation(
306 substituted_runtime_config=substituted_runtime_config,
307 async_validation_operator_results=async_validation_operator_results,
(...)
312 validation_dict=validation_dict,
313 )
314 else:
--> 315 self._run_validation(
316 substituted_runtime_config=substituted_runtime_config,
317 async_validation_operator_results=async_validation_operator_results,
318 async_executor=async_executor,
319 result_format=result_format,
320 run_id=run_id,
321 )
323 checkpoint_run_results: dict = {}
324 async_validation_operator_result: AsyncResult
File ~/code/gx-exploration/.venv/lib/python3.10/site-packages/great_expectations/checkpoint/checkpoint.py:454, in BaseCheckpoint._run_validation(self, substituted_runtime_config, async_validation_operator_results, async_executor, result_format, run_id, idx, validation_dict)
449 validation_dict = CheckpointValidationConfig(
450 id=substituted_runtime_config.get("default_validation_id")
451 )
453 try:
--> 454 substituted_validation_dict: dict = get_substituted_validation_dict(
455 substituted_runtime_config=substituted_runtime_config,
456 validation_dict=validation_dict,
457 )
458 validate_validation_dict(
459 validation_dict=substituted_validation_dict,
460 batch_request_required=(not self._validator),
461 )
463 batch_request: Union[
464 BatchRequest, FluentBatchRequest, RuntimeBatchRequest, None
465 ] = substituted_validation_dict.get("batch_request")
File ~/code/gx-exploration/.venv/lib/python3.10/site-packages/great_expectations/checkpoint/util.py:193, in get_substituted_validation_dict(substituted_runtime_config, validation_dict)
189 def get_substituted_validation_dict(
190 substituted_runtime_config: dict, validation_dict: CheckpointValidationConfig
191 ) -> dict:
192 substituted_validation_dict = {
--> 193 "batch_request": get_substituted_batch_request(
194 substituted_runtime_config=substituted_runtime_config,
195 validation_batch_request=validation_dict.get("batch_request"),
196 ),
197 "expectation_suite_name": validation_dict.get("expectation_suite_name")
198 or substituted_runtime_config.get("expectation_suite_name"),
199 "expectation_suite_ge_cloud_id": validation_dict.get(
200 "expectation_suite_ge_cloud_id"
201 )
202 or substituted_runtime_config.get("expectation_suite_ge_cloud_id"),
203 "action_list": get_updated_action_list(
204 base_action_list=substituted_runtime_config.get("action_list", []),
205 other_action_list=validation_dict.get("action_list", {}),
206 ),
207 "evaluation_parameters": nested_update(
208 substituted_runtime_config.get("evaluation_parameters") or {},
209 validation_dict.get("evaluation_parameters", {}),
210 dedup=True,
211 ),
212 "runtime_configuration": nested_update(
213 substituted_runtime_config.get("runtime_configuration") or {},
214 validation_dict.get("runtime_configuration", {}),
215 dedup=True,
216 ),
217 "include_rendered_content": validation_dict.get("include_rendered_content")
218 or substituted_runtime_config.get("include_rendered_content")
219 or None,
220 }
222 for attr in ("name", "id"):
223 if validation_dict.get(attr) is not None:
File ~/code/gx-exploration/.venv/lib/python3.10/site-packages/great_expectations/checkpoint/util.py:268, in get_substituted_batch_request(substituted_runtime_config, validation_batch_request)
259 raise gx_exceptions.CheckpointError(
260 f'BatchRequest attribute "{key}" was provided with different values'
261 )
263 effective_batch_request: dict = {
264 **validation_batch_request,
265 **substituted_runtime_batch_request,
266 }
--> 268 return materialize_batch_request(batch_request=effective_batch_request)
File ~/code/gx-exploration/.venv/lib/python3.10/site-packages/great_expectations/core/batch.py:942, in materialize_batch_request(batch_request)
939 else:
940 batch_request_class = BatchRequest
--> 942 return batch_request_class(**effective_batch_request)
File ~/code/gx-exploration/.venv/lib/python3.10/site-packages/great_expectations/datasource/fluent/batch_request.py:91, in BatchRequest.__init__(self, **kwargs)
89 if "batch_slice" in kwargs:
90 _batch_slice_input = kwargs.pop("batch_slice")
---> 91 super().__init__(**kwargs)
92 self._batch_slice_input = _batch_slice_input
File ~/code/gx-exploration/.venv/lib/python3.10/site-packages/pydantic/v1/main.py:341, in BaseModel.__init__(__pydantic_self__, **data)
339 values, fields_set, validation_error = validate_model(__pydantic_self__.__class__, data)
340 if validation_error:
--> 341 raise validation_error
342 try:
343 object_setattr(__pydantic_self__, '__dict__', values)
ValidationError: 1 validation error for BatchRequest
batch_spec_passthrough
extra fields not permitted (type=value_error.extra)
GX version: 0.18.12
Python: 3.10.13
OS: Linux