-
Notifications
You must be signed in to change notification settings - Fork 14.6k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add LocalFilesystemToGoogleDriveOperator
#22219
Conversation
`api_version` parameter is passed through the hook and the hook already has the api_version default. One less magic number to manage.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
One small comment, otherwise looks good to me 🚀
The PR is likely OK to be merged with just subset of tests for default Python and Database versions without running the full matrix of tests, because it does not modify the core of Airflow. If the committers decide that the full tests matrix is needed, they will add the label 'full tests needed'. Then you should rebase to the latest main or amend the last commit of the PR, and push it with --force-with-lease. |
Co-authored-by: Tomek Urbaszek <[email protected]>
Added it so we might add it to the new release of providers :) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
it would be a problem in line 104: remote_location=str(self.drive_folder / local_path.name),
since str
doesn't have a name
parameter.
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
will merge when CI is green
except FileNotFoundError: | ||
self.log.warning("File %s can't be found", local_path) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I prefer not to be picky and catch all OSError
but maybe that is just me :)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
FileNotFoundError
seemed like the main error cause in my case, but it'd be better to catch all OSError
s. How about adding OSError
after FileNotFoundError
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
FileNotFoundError
is subclasses of OSError
.
So catching OSError
is enough
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
CI indeed help us :)
|
LocalFilesystemToGoogleDriveOperator
except FileNotFoundError: | ||
self.log.warning("File can't be found: %s", local_path) | ||
except OSError: | ||
self.log.warning("An OSError occurred for file: %s", local_path) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
merged this one too fast :)
We should do something like:
except FileNotFoundError as e:
self.log.info('File not found: %s: %s', local_path, e)
raise
except OSError as e:
self.log.info('An OSError occurred for file: %s: %s', local_path, e)
raise
or
except OSError as e:
raise AirflowException(
f'Exception: There was exception related to file in path {local_path} '
f'full error is ({e}).'
)
Would you mind open a follow up PR?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Raise would fail the dag too early, however the intention was failing after seeing the whole landscape. That's why we logged the problems and raised as a result, if user doesn't want to ignore.
Operator to upload a list of files to a Google Drive folder, alongside a file which can be used to have more Google Drive operators.