-
Notifications
You must be signed in to change notification settings - Fork 18
feat(storage): implement support for storing artifacts to S3 #328
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
Conversation
for more information, see https://pre-commit.ci
|
I can dismiss this CodeQL alert if you want, the upload is already on a password protected section, and requires |
Yes, was trying to fix that error but so far without any success. |
b-rowan
left a comment
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.
Couple of styling changes to fix, content looks fine to me though.
Only issue we might have, and this is something we should test against, is that I cant tell if this will break the Remote URL upload.
|
You may want to run |
|
Hi @b-rowan, first of all - thank you for a detailed review, I updated and fixed all of it. Also, I tested both storage adapters with default and remote URL file as well and you were right - the I used Please check the PR again when you'll have time and I'm opened to comments if there is still something needed to be fixed. |
b-rowan
left a comment
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.
Small fix here, and I think the async with can be removed since we don't need to do any io when the storage starts. I have attached a patch that I tested with and found to work.
Subject: [PATCH] refactor: remove unneeded async with clause
---
Index: conftest.py
IDEA additional info:
Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP
<+>UTF-8
===================================================================
diff --git a/conftest.py b/conftest.py
--- a/conftest.py (revision 0da04206ec16a18a47fac9ed26dbe67a4e044af1)
+++ b/conftest.py (revision 5d459fd368c2c98b310cf19db045eda244365527)
@@ -35,7 +35,6 @@
@pytest_asyncio.fixture(scope="function")
async def test_app():
- from goosebit.storage import storage
from goosebit.users import create_initial_user
async with RegisterTortoise(
@@ -45,8 +44,7 @@
await Tortoise.generate_schemas()
await create_initial_user(username="testing@goosebit.test", hashed_pwd=PWD_CXT.hash("test"))
- async with storage:
- yield app
+ yield app
@pytest_asyncio.fixture(scope="function")
Index: goosebit/__init__.py
IDEA additional info:
Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP
<+>UTF-8
===================================================================
diff --git a/goosebit/__init__.py b/goosebit/__init__.py
--- a/goosebit/__init__.py (revision 0da04206ec16a18a47fac9ed26dbe67a4e044af1)
+++ b/goosebit/__init__.py (revision 5d459fd368c2c98b310cf19db045eda244365527)
@@ -16,7 +16,6 @@
from goosebit import api, db, ui, updater
from goosebit.auth import get_user_from_request, login_user, redirect_if_authenticated
from goosebit.settings import PWD_CXT, config
-from goosebit.storage import storage
from goosebit.ui.nav import nav
from goosebit.ui.static import static
from goosebit.ui.templates import templates
@@ -31,11 +30,10 @@
if not db_ready:
logger.exception("DB does not exist, try running `poetry run aerich upgrade`.")
- async with storage:
- logger.debug(f"Initialized storage backend: {config.storage.backend}")
+ logger.debug(f"Initialized storage backend: {config.storage.backend}")
- if db_ready:
- yield
+ if db_ready:
+ yield
await db.close()
Index: goosebit/storage/__init__.py
IDEA additional info:
Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP
<+>UTF-8
===================================================================
diff --git a/goosebit/storage/__init__.py b/goosebit/storage/__init__.py
--- a/goosebit/storage/__init__.py (revision 0da04206ec16a18a47fac9ed26dbe67a4e044af1)
+++ b/goosebit/storage/__init__.py (revision 5d459fd368c2c98b310cf19db045eda244365527)
@@ -12,7 +12,7 @@
class GoosebitStorage:
def __init__(self, config: GooseBitSettings):
self.config = config
- self._backend: StorageProtocol | None = None
+ self._backend: StorageProtocol = self._create_backend()
def _create_backend(self) -> StorageProtocol:
@@ -35,13 +35,6 @@
else:
raise ValueError(f"Unknown storage backend type: {self.config.storage.backend}")
- async def __aenter__(self) -> "GoosebitStorage":
- self._backend = self._create_backend()
- return self
-
- async def __aexit__(self, *_) -> None:
- self._backend = None
-
@property
def backend(self) -> StorageProtocol:
if self._backend is None:
|
@b-rowan seems like the patches you sent are already applied. I fixed that path concatenation in |
| uvicorn = "^0.34.0" | ||
|
|
||
| asyncpg = { version = "^0.30.0", optional = true } | ||
| boto3 = "^1.40.4" |
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.
Not a big fan of the hard dependency on the AWS SDK.
Can't we make it optional like we did for Postgres?
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 have no objections making it optional.
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.
Sounds good to me. I'll throw something together here quickly.
As discussed here I'm opening an implementation to support storing artifacts to S3 bucket.