Skip to content

Commit

Permalink
use local tempfile and upload_fobj when dumping odb config
Browse files Browse the repository at this point in the history
  • Loading branch information
pmrowla committed Feb 15, 2021
1 parent 304afbb commit 507dab5
Showing 1 changed file with 8 additions and 2 deletions.
10 changes: 8 additions & 2 deletions dvc/odb/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,13 +37,19 @@ def load_config(path_info: "PathInfo", fs: "BaseFileSystem",) -> dict:
def dump_config(
config: dict, path_info: "PathInfo", fs: "BaseFileSystem",
):
from tempfile import NamedTemporaryFile

from dvc.utils.serialize import modify_yaml

logger.debug("Writing ODB config '%s'", path_info)
if not fs.exists(path_info.parent):
fs.makedirs(path_info.parent)
with modify_yaml(path_info, fs=fs) as data:
data.update(config)

with NamedTemporaryFile() as tmp:
with modify_yaml(tmp.name) as data:
data.update(config)
tmp.seek(0)
fs.upload_fobj(tmp, path_info)


def migrate_config(config: dict) -> bool:
Expand Down

0 comments on commit 507dab5

Please sign in to comment.