baha-bouali commented on code in PR #70628:
URL: https://github.com/apache/airflow/pull/70628#discussion_r3669910533
##########
providers/common/ai/src/airflow/providers/common/ai/operators/document_loader.py:
##########
@@ -148,11 +152,10 @@ def __init__(
self.json_text_field = json_text_field
def execute(self, context: Context) -> list[dict[str, Any]]:
- # source_path/file_type are template fields; validate after rendering,
not in __init__.
- if self.source_path is not None and self.source_bytes is not None:
- raise ValueError("Provide exactly one of 'source_path' or
'source_bytes', not both.")
- if self.source_path is None and self.source_bytes is None:
- raise ValueError("Provide exactly one of 'source_path' or
'source_bytes'.")
+ # source_path/source_bytes provision is checked in __init__ (that's
just "was an
+ # argument passed"). file_type is different: it backs the assert
below, and since
+ # file_type is itself a template field, whether it was *actually*
supplied is only
+ # knowable after rendering -- so this one check has to stay here, not
in __init__.
if self.source_bytes is not None and self.file_type is None:
raise ValueError("'file_type' is required when using
'source_bytes' (e.g. '.pdf').")
Review Comment:
I think it is fixed now. I reworded the comment and added back the
source_path guard, thanks for catching this! Let me know if something is still
wrong
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]