From 5e455aeddf3ebc506cd0923104bc4fcabdb6d94c Mon Sep 17 00:00:00 2001 From: Wei Ouyang Date: Sun, 6 Oct 2024 22:04:40 -0700 Subject: [PATCH] Use in-memory sql for artifacts --- hypha/artifact.py | 6 +++++- hypha/server.py | 14 +++++++------- 2 files changed, 12 insertions(+), 8 deletions(-) diff --git a/hypha/artifact.py b/hypha/artifact.py index 3ea16721..c4c3984f 100644 --- a/hypha/artifact.py +++ b/hypha/artifact.py @@ -69,7 +69,11 @@ def __init__( ): """Set up controller with SQLAlchemy database and S3 for file storage.""" if database_uri is None: - raise ValueError("Database URI is required.") + # create an in-memory SQLite database for testing + database_uri = "sqlite+aiosqlite:///:memory:" + logger.warning( + "Using in-memory SQLite database for artifact manager, all data will be lost on restart!!!" + ) self.engine = create_async_engine(database_uri, echo=False) self.SessionLocal = async_sessionmaker( self.engine, expire_on_commit=False, class_=AsyncSession diff --git a/hypha/server.py b/hypha/server.py index 2972e257..bc4475c1 100644 --- a/hypha/server.py +++ b/hypha/server.py @@ -101,12 +101,12 @@ def start_builtin_services( executable_path=args.executable_path, ) - artifact_manager = ArtifactController( - store, - s3_controller=s3_controller, - workspace_bucket=args.workspace_bucket, - database_uri=args.database_uri, - ) + artifact_manager = ArtifactController( + store, + s3_controller=s3_controller, + workspace_bucket=args.workspace_bucket, + database_uri=args.database_uri, + ) if args.enable_server_apps: assert args.enable_s3, "Server apps require S3 to be enabled" @@ -378,7 +378,7 @@ def get_argparser(add_help=True): "--database-uri", type=str, default=None, - help="set database URI for the server", + help="set database URI for the artifact manager", ) parser.add_argument( "--workspace-bucket",