-
Notifications
You must be signed in to change notification settings - Fork 1
Add s3_bucket_exists on storage backend #1
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
base: s3-improve-get-bucket
Are you sure you want to change the base?
Add s3_bucket_exists on storage backend #1
Conversation
| ) | ||
|
|
||
|
|
||
| def action_ensure_bucket_exists(self): |
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.
to clarify:
- btn
action_ensure_bucket_existsto test if the bucket exists by calling_ensure_bucket_exists
I am not sure how do we want to test bucket connection here, I assumed that we want to start flow for getting bucket and forcing flag to True so we make sure call to head_bucket is made.
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.
TBH I forgot I added a generic way for defining validation of backends. Please check action_test_config in storage_backend -> it works if you define a validate_config method on the adapter.
Which means that we can:
- rename
s3_bucket_existstovalidatedand move it to storage_backend and letaction_test_configset it to True or False when needed (do this in its own commit pls) - define
validate_configand make it call_check_bucket_exists - get rid of the custom btn
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.
@simahawk just checking both modules, in storage_backend there is already a field 'has_validation'. Are we sure we want another field with basically same functionality there?
7bc809f to
7c06954
Compare
7c06954 to
3e0f851
Compare
f8d2050 to
122d400
Compare
Codecov Report
@@ Coverage Diff @@
## s3-improve-get-bucket #1 +/- ##
=========================================================
- Coverage 86.51% 86.34% -0.17%
=========================================================
Files 41 41
Lines 1305 1311 +6
=========================================================
+ Hits 1129 1132 +3
- Misses 176 179 +3
Continue to review full report at Codecov.
|
| ) | ||
| has_validation = fields.Boolean(compute="_compute_has_validation") | ||
|
|
||
| validated = fields.Boolean(string="Validated",compute="_compute_has_validation") |
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.
what is this? It should be a normal stored field, not computed :/
| for rec in self: | ||
| adapter = self._get_adapter() | ||
| rec.has_validation = hasattr(adapter, "validate_config") | ||
| rec.validated = rec.has_validation = hasattr(adapter, "validate_config") |
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.
pls rollback this
| s3 = boto3.resource("s3", **params) | ||
| bucket_name = self.collection.aws_bucket | ||
| bucket = self._get_or_create_bucket(s3, bucket_name, **params) | ||
| self.collection.validated = True |
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.
this writes on EVERY lookup for the bucket, pls drop it
| s3.meta.client.head_bucket(Bucket=bucket_name) | ||
| # The call above is expensive, avoid it when possible. | ||
| EXISTING_BUCKETS.append(bucket_name) | ||
| self.collection.validated = True |
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.
you are writing on this a second time because is done already on line 148.
Drop this and rely only on the flag that this method should return and update the flag only in validate_config
Uh oh!
There was an error while loading. Please reload this page.