Skip to content

Commit f0dcd0e

Browse files
authored
Support pg8000 to support Google cloud sql (#76)
* Support pg8000 to Google support Signed-off-by: kerthcet <[email protected]> * fix lint Signed-off-by: kerthcet <[email protected]> --------- Signed-off-by: kerthcet <[email protected]>
1 parent fab4c3b commit f0dcd0e

File tree

6 files changed

+56
-5
lines changed

6 files changed

+56
-5
lines changed

.env.example

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
11
# We use PG by default as the metadata database.
22
METADATA_DB_URL=postgresql+psycopg2://alphatrion:alphatr1on@localhost:5432/alphatrion
3-
ARTIFACT_REGISTRY_URL=http://localhost:5000/
43
LOG_LEVEL=INFO
4+
# Default: true, ARTIFACT_REGISTRY_URL should not be empty.
5+
ENABLE_ARTIFACT_STORAGE=true
6+
ARTIFACT_REGISTRY_URL=http://localhost:5000/

alphatrion/consts.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,3 @@
11
METADATA_DB_URL = "METADATA_DB_URL"
22
ARTIFACT_REGISTRY_URL = "ARTIFACT_REGISTRY_URL"
3+
ENABLE_ARTIFACT_STORAGE = "ENABLE_ARTIFACT_STORAGE"

alphatrion/log/log.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,12 @@ async def log_artifact(
2727
if runtime is None:
2828
raise RuntimeError("Runtime is not initialized. Please call init() first.")
2929

30+
if not runtime.artifact_storage_enabled():
31+
raise RuntimeError(
32+
"Artifact storage is not enabled in the runtime."
33+
"Set ENABLE_ARTIFACT_STORAGE=true in the environment variables."
34+
)
35+
3036
# We use experiment ID as the repo name rather than the experiment name,
3137
# because experiment name is not unique
3238
exp = runtime.current_exp

alphatrion/runtime/runtime.py

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -51,9 +51,14 @@ def __init__(
5151
self._metadb = SQLStore(
5252
os.getenv(consts.METADATA_DB_URL), init_tables=init_tables
5353
)
54-
self._artifact = Artifact(
55-
project_id=self._project_id, insecure=artifact_insecure
56-
)
54+
55+
if self.artifact_storage_enabled():
56+
self._artifact = Artifact(
57+
project_id=self._project_id, insecure=artifact_insecure
58+
)
59+
60+
def artifact_storage_enabled(self) -> bool:
61+
return os.getenv(consts.ENABLE_ARTIFACT_STORAGE, "true").lower() == "true"
5762

5863
# current_exp is the current running experiment.
5964
@property

pyproject.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ dependencies = [
1515
"traceloop-sdk (>=0.47.5,<1.0.0)",
1616
"openai (>=2.6.1,<3.0.0)",
1717
"alembic (>=1.17.1,<2.0.0)",
18+
"pg8000>=1.31.5",
1819
]
1920

2021
[dependency-groups]

uv.lock

Lines changed: 37 additions & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)