Skip to content

Commit 0b340a0

Browse files
authored
Don't write the global config to file on server (#2491)
1 parent 00e934f commit 0b340a0

File tree

2 files changed

+16
-4
lines changed

2 files changed

+16
-4
lines changed

src/zenml/config/global_config.py

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -304,6 +304,16 @@ def _read_config(self) -> Dict[str, Any]:
304304

305305
def _write_config(self) -> None:
306306
"""Writes the global configuration options to disk."""
307+
# We never write the configuration file in a ZenML server environment
308+
# because this is a long-running process and the global configuration
309+
# variables are supplied via environment variables.
310+
if ENV_ZENML_SERVER in os.environ:
311+
logger.info(
312+
"Not writing the global configuration to disk in a ZenML "
313+
"server environment."
314+
)
315+
return
316+
307317
config_file = self._config_file
308318
yaml_dict = json.loads(self.json(exclude_none=True))
309319
logger.debug(f"Writing config to {config_file}")

src/zenml/zen_stores/sql_zen_store.py

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@
3939
)
4040
from uuid import UUID
4141

42-
from pydantic import SecretStr, root_validator, validator
42+
from pydantic import Field, SecretStr, root_validator, validator
4343
from sqlalchemy import asc, desc, func
4444
from sqlalchemy.engine import URL, Engine, make_url
4545
from sqlalchemy.exc import (
@@ -384,9 +384,11 @@ class SqlZenStoreConfiguration(StoreConfiguration):
384384

385385
backup_strategy: DatabaseBackupStrategy = DatabaseBackupStrategy.IN_MEMORY
386386
# database backup directory
387-
backup_directory: str = os.path.join(
388-
GlobalConfiguration().config_directory,
389-
SQL_STORE_BACKUP_DIRECTORY_NAME,
387+
backup_directory: str = Field(
388+
default_factory=lambda: os.path.join(
389+
GlobalConfiguration().config_directory,
390+
SQL_STORE_BACKUP_DIRECTORY_NAME,
391+
)
390392
)
391393
backup_database: Optional[str] = None
392394

0 commit comments

Comments
 (0)